use of com.epam.ta.reportportal.ws.model.Page in project service-api by reportportal.
the class UserControllerTest method findUsers.
@Test
void findUsers() throws Exception {
MvcResult mvcResult = mockMvc.perform(get("/v1/user/search?term=e").with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isOk()).andReturn();
Page userResources = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), Page.class);
Assertions.assertNotNull(userResources);
Assertions.assertEquals(2, userResources.getContent().size());
}
use of com.epam.ta.reportportal.ws.model.Page in project service-api by reportportal.
the class GetLaunchHandlerImplTest method getClusterInfo.
@Test
void getClusterInfo() {
long projectId = 1L;
ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.MEMBER, projectId);
String launchId = "1";
Launch launch = new Launch();
launch.setProjectId(projectId);
launch.setMode(LaunchModeEnum.DEBUG);
when(launchRepository.findById(Long.parseLong(launchId))).thenReturn(Optional.of(launch));
final Pageable pageable = PageRequest.of(1, 2);
final Page<ClusterInfoResource> expected = new Page<>(List.of(new ClusterInfoResource(), new ClusterInfoResource()), 2, 1, 10);
when(getClusterHandler.getResources(launch, pageable)).thenReturn(expected);
final Iterable<ClusterInfoResource> result = handler.getClusters(launchId, extractProjectDetails(user, "test_project"), pageable);
final Page<ClusterInfoResource> castedResult = (Page<ClusterInfoResource>) result;
assertEquals(expected.getPage().getNumber(), castedResult.getPage().getNumber());
assertEquals(expected.getPage().getSize(), castedResult.getPage().getSize());
assertEquals(expected.getPage().getTotalElements(), castedResult.getPage().getTotalElements());
assertEquals(10, castedResult.getPage().getTotalElements());
assertEquals(1, castedResult.getPage().getNumber());
assertEquals(2, castedResult.getPage().getSize());
assertEquals(2, castedResult.getContent().size());
}
Aggregations