Search in sources :

Example 1 with ClusterInfoResource

use of com.epam.ta.reportportal.ws.model.launch.cluster.ClusterInfoResource 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

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 Page (com.epam.ta.reportportal.ws.model.Page)1 ClusterInfoResource (com.epam.ta.reportportal.ws.model.launch.cluster.ClusterInfoResource)1 Test (org.junit.jupiter.api.Test)1 Pageable (org.springframework.data.domain.Pageable)1