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());
}
Aggregations