-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x1174 Allow certain characters in replicate number
Can contain _-. (underscore, hyphen, full stop) in addition to letters and digits. Must start and end with a letter or digit. Cannot have two adjacent punctuation characters.
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
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
34 changes: 34 additions & 0 deletions
34
src/test/java/uk/ac/sanger/sccp/stan/config/TestFieldValidation.java
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,34 @@ | ||
package uk.ac.sanger.sccp.stan.config; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import uk.ac.sanger.sccp.stan.service.Validator; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class TestFieldValidation { | ||
FieldValidation fieldValidation; | ||
|
||
@BeforeEach | ||
void setup() { | ||
fieldValidation = new FieldValidation(); | ||
} | ||
|
||
@Test | ||
public void testReplicateNumber() { | ||
Validator<String> val = fieldValidation.replicateValidator(); | ||
final Consumer<String> problemConsumer = msg -> {}; | ||
String[] valid = {"1", "A", "1A", "A1", "11aabb33", "1-4-A", "B.5.C", "X_X_7_7", "1-B.C_E"}; | ||
for (String string : valid) { | ||
assertTrue(val.validate(string, problemConsumer), string); | ||
} | ||
String[] invalid = {"", "*", "A*", " 1", "A ", "-1", "A.", "1A..N", "A-_4"}; | ||
for (String string : invalid) { | ||
assertFalse(val.validate(string, problemConsumer), string); | ||
} | ||
} | ||
|
||
} |
17e8520
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me