Skip to content

Commit d9bcfc2

Browse files
committed
enrich tests
Signed-off-by: Etienne Homer <[email protected]>
1 parent 0c9a55b commit d9bcfc2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/test/java/org/gridsuite/useradmin/server/UserAdminTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.test.context.junit4.SpringRunner;
2222
import org.springframework.test.web.servlet.MockMvc;
2323

24+
import java.time.LocalDateTime;
2425
import java.util.List;
2526
import java.util.UUID;
2627

@@ -104,10 +105,17 @@ public void testUserAdmin() throws Exception {
104105
mockMvc.perform(head("/" + UserAdminApi.API_VERSION + "/users/{sub}", "UNKNOWN"))
105106
.andExpect(status().isNoContent())
106107
.andReturn();
107-
108108
assertEquals(2, connectionRepository.findAll().size());
109109
assertTrue(connectionRepository.findBySub(USER_SUB).getConnectionAccepted());
110110
assertFalse(connectionRepository.findBySub("UNKNOWN").getConnectionAccepted());
111+
LocalDateTime firstConnectionDate = connectionRepository.findBySub(USER_SUB).getFirstConnexionDate();
112+
//firstConnectionDate and lastConnectionDate are equals cause this is the first connection for this user
113+
assertEquals(firstConnectionDate, connectionRepository.findBySub(USER_SUB).getLastConnexionDate());
114+
115+
mockMvc.perform(head("/" + UserAdminApi.API_VERSION + "/users/{sub}", USER_SUB))
116+
.andExpect(status().isOk())
117+
.andReturn();
118+
assertEquals(firstConnectionDate, connectionRepository.findBySub(USER_SUB).getFirstConnexionDate());
111119

112120
mockMvc.perform(delete("/" + UserAdminApi.API_VERSION + "/users/{id}", userId)
113121
.header("userId", ADMIN_USER)
@@ -123,7 +131,6 @@ public void testUserAdmin() throws Exception {
123131
.andReturn().getResponse().getContentAsString(),
124132
new TypeReference<>() {
125133
});
126-
127134
assertEquals(0, userEntities.size());
128135

129136
mockMvc.perform(delete("/" + UserAdminApi.API_VERSION + "/users/{id}", userId)

0 commit comments

Comments
 (0)