-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to KiwiJdbc to get string values with option to trim (#1059)
Add stringOrNullIfBlank method to KiwiJdbc. If the value returned from the database is null or blank (whitespace only), this method returns null. If the value from the database is not blank, the string is returned after applying a StringTrimOption to it. This option can either preserve leading and trailing whitespace, or remove it. All intermediate whitespace (i.e. between words) is preserved. Also added BlankStringSource, which is copied from kiwi-test in order to avoid a circular dependency between kiwi and kiwi-test. Closes #1049
- Loading branch information
1 parent
1f6282b
commit 1a05fc0
Showing
3 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.kiwiproject.util; | ||
|
||
import org.junit.jupiter.params.provider.ArgumentsSource; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* {@code @BlankStringSource} is an {@link ArgumentsSource} which provides blank strings. | ||
* <p> | ||
* Usage: | ||
* <pre> | ||
* {@literal @}ParameterizedTest | ||
* {@literal @}BlankStringSource | ||
* void testThatEachProvidedArgumentIsBlank(String blankString) 1 | ||
* assertThat(blankString).isBlank(); | ||
* // or whatever else you need to test where you need a blank String... | ||
* } | ||
* </pre> | ||
* | ||
* <p> | ||
* <strong>NOTE:</strong> This is a duplicate of the kiwi-test version. It is included here to prevent a circular dependency. | ||
*/ | ||
@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@ArgumentsSource(BlankStringArgumentsProvider.class) | ||
public @interface BlankStringSource { | ||
} |