add integration test to find all user controller with success
This commit is contained in:
parent
5d04c8dea6
commit
6a268f5cb3
1 changed files with 20 additions and 0 deletions
|
|
@ -14,6 +14,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import br.com.rayankonecny.userserviceapi.entity.User;
|
||||
import br.com.rayankonecny.userserviceapi.repository.UserRepository;
|
||||
|
||||
|
|
@ -50,4 +52,22 @@ public class UserControllerImpTest {
|
|||
.andExpect(jsonPath("$.timestamp").isNotEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFindAllWithSuccess() throws Exception {
|
||||
final var entity1 = generateMock(User.class);
|
||||
final var entity2 = generateMock(User.class);
|
||||
|
||||
userRepository.saveAll(List.of(entity1, entity2));
|
||||
|
||||
mockMvc.perform(get("/api/users"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$").isArray())
|
||||
.andExpect(jsonPath("$[0]").isNotEmpty())
|
||||
.andExpect(jsonPath("$[1]").isNotEmpty())
|
||||
.andExpect(jsonPath("$[0].profiles").isArray());
|
||||
|
||||
userRepository.deleteAll(List.of(entity1,entity2));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue