Skip to content

Commit 1a4bfdc

Browse files
committed
add FieldVerifier to validate on both sides
1 parent bc5f1d0 commit 1a4bfdc

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

intro-gwtboot-springboot-shared/pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
<version>1.0.0-RC5</version>
2525
<scope>provided</scope>
2626
</dependency>
27+
28+
<dependency>
29+
<groupId>org.junit.jupiter</groupId>
30+
<artifactId>junit-jupiter-engine</artifactId>
31+
<version>5.8.1</version>
32+
<scope>test</scope>
33+
</dependency>
2734
</dependencies>
2835

2936
<build>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.company.crm.shared;
2+
3+
public class FieldVerifier {
4+
5+
public static boolean isValidName(String name) {
6+
if (name == null) {
7+
return false;
8+
}
9+
return name.length() > 3;
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.company.crm.shared;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class FieldVerifierTest {
8+
9+
@Test
10+
void name_less_than_3_chars_not_valid() {
11+
boolean validName = FieldVerifier.isValidName("Lof");
12+
13+
assertTrue(!validName);
14+
}
15+
16+
@Test
17+
void name_longer_than_3_chars_valid() {
18+
boolean validName = FieldVerifier.isValidName("Lofi");
19+
20+
assertTrue(validName);
21+
}
22+
23+
}

0 commit comments

Comments
 (0)