Search in sources :

Example 1 with Page

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());
}
Also used : Page(com.epam.ta.reportportal.ws.model.Page) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with Page

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());
}
Also used : ClusterInfoResource(com.epam.ta.reportportal.ws.model.launch.cluster.ClusterInfoResource) Pageable(org.springframework.data.domain.Pageable) Page(com.epam.ta.reportportal.ws.model.Page) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) LaunchTestUtil.getLaunch(com.epam.ta.reportportal.core.launch.impl.LaunchTestUtil.getLaunch) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Aggregations

Page (com.epam.ta.reportportal.ws.model.Page)2 Test (org.junit.jupiter.api.Test)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 LaunchTestUtil.getLaunch (com.epam.ta.reportportal.core.launch.impl.LaunchTestUtil.getLaunch)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)1 ClusterInfoResource (com.epam.ta.reportportal.ws.model.launch.cluster.ClusterInfoResource)1 Pageable (org.springframework.data.domain.Pageable)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1