Skip to content

Commit 95e2b89

Browse files
committed
Added test cases for null lastName, null firstName, email domain name
1 parent 0a4aa6c commit 95e2b89

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

jaxrs/resource-validation/src/test/java/org/javaee7/jaxrs/resource/validation/NameAddResourceTest.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ private Response postName(JsonObject name) {
6868
return target
6969
.request()
7070
.post(nameEntity);
71-
7271
}
7372

7473
private void assertStatus(Response response, Status expectedStatus) {
@@ -91,6 +90,17 @@ private void assertFailedValidation(Response response) {
9190
assertStatus(response, BAD_REQUEST);
9291
}
9392

93+
@Test
94+
public void shouldFailAtFirstNameNullValidation() throws Exception {
95+
JsonObject name = startValidName()
96+
.addNull("firstName")
97+
.build();
98+
99+
Response response = postName(name);
100+
101+
assertFailedValidation(response);
102+
}
103+
94104
@Test
95105
public void shouldFailAtLastNameSizeValidation() throws Exception {
96106
JsonObject name = startValidName()
@@ -103,7 +113,18 @@ public void shouldFailAtLastNameSizeValidation() throws Exception {
103113
}
104114

105115
@Test
106-
public void shouldFailAtEmailValidation() throws Exception {
116+
public void shouldFailAtLastNameNullValidation() throws Exception {
117+
JsonObject name = startValidName()
118+
.addNull("lastName")
119+
.build();
120+
121+
Response response = postName(name);
122+
123+
assertFailedValidation(response);
124+
}
125+
126+
@Test
127+
public void shouldFailAtEmailAtSymbolValidation() throws Exception {
107128
JsonObject name = startValidName()
108129
.add("email", "missing-at-symbol.com")
109130
.build();
@@ -113,4 +134,15 @@ public void shouldFailAtEmailValidation() throws Exception {
113134
assertFailedValidation(response);
114135
}
115136

137+
@Test
138+
public void shouldFailAtEmailComDomainValidation() throws Exception {
139+
JsonObject name = startValidName()
140+
.add("email", "other-than-com@domain.pl")
141+
.build();
142+
143+
Response response = postName(name);
144+
145+
assertFailedValidation(response);
146+
}
147+
116148
}

0 commit comments

Comments
 (0)