Search in sources :

Example 1 with CreateClustersRQ

use of com.epam.ta.reportportal.ws.model.launch.cluster.CreateClustersRQ in project service-api by reportportal.

the class UpdateLaunchHandlerImplTest method createClustersLaunchInProgress.

@Test
void createClustersLaunchInProgress() {
    final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.CUSTOMER, 1L);
    when(getLaunchHandler.getLaunch(1L)).thenReturn(getLaunch(StatusEnum.IN_PROGRESS, LaunchModeEnum.DEFAULT).get());
    final CreateClustersRQ createClustersRQ = new CreateClustersRQ();
    createClustersRQ.setLaunchId(1L);
    createClustersRQ.setRemoveNumbers(false);
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.createClusters(createClustersRQ, extractProjectDetails(rpUser, "test_project"), rpUser));
    assertEquals("Incorrect Request. Cannot analyze launch in progress.", exception.getMessage());
    verify(launchAccessValidator, times(1)).validate(any(Launch.class), any(ReportPortalUser.ProjectDetails.class), eq(rpUser));
}
Also used : CreateClustersRQ(com.epam.ta.reportportal.ws.model.launch.cluster.CreateClustersRQ) TestProjectExtractor.extractProjectDetails(com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) 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)

Example 2 with CreateClustersRQ

use of com.epam.ta.reportportal.ws.model.launch.cluster.CreateClustersRQ in project service-api by reportportal.

the class UpdateLaunchHandlerImplTest method createClusters.

@Test
void createClusters() {
    final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.CUSTOMER, 1L);
    final Project project = new Project();
    project.setId(1L);
    when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(project);
    when(getLaunchHandler.getLaunch(1L)).thenReturn(getLaunch(StatusEnum.PASSED, LaunchModeEnum.DEFAULT).get());
    final CreateClustersRQ createClustersRQ = new CreateClustersRQ();
    createClustersRQ.setLaunchId(1L);
    createClustersRQ.setRemoveNumbers(true);
    handler.createClusters(createClustersRQ, extractProjectDetails(rpUser, "test_project"), rpUser);
    verify(launchAccessValidator, times(1)).validate(any(Launch.class), any(ReportPortalUser.ProjectDetails.class), eq(rpUser));
    final ArgumentCaptor<GenerateClustersConfig> argumentCaptor = ArgumentCaptor.forClass(GenerateClustersConfig.class);
    verify(clusterGenerator, times(1)).generate(argumentCaptor.capture());
    final GenerateClustersConfig config = argumentCaptor.getValue();
    assertEquals(1L, config.getProject());
    assertEquals(1L, config.getLaunchId());
    assertEquals(createClustersRQ.isRemoveNumbers(), config.isCleanNumbers());
    assertFalse(config.isForUpdate());
    assertEquals(ProjectAttributeEnum.NUMBER_OF_LOG_LINES.getDefaultValue(), String.valueOf(config.getAnalyzerConfig().getNumberOfLogLines()));
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) TestProjectExtractor.extractProjectDetails(com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails) CreateClustersRQ(com.epam.ta.reportportal.ws.model.launch.cluster.CreateClustersRQ) 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) GenerateClustersConfig(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 LaunchTestUtil.getLaunch (com.epam.ta.reportportal.core.launch.impl.LaunchTestUtil.getLaunch)2 Launch (com.epam.ta.reportportal.entity.launch.Launch)2 TestProjectExtractor.extractProjectDetails (com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails)2 CreateClustersRQ (com.epam.ta.reportportal.ws.model.launch.cluster.CreateClustersRQ)2 Test (org.junit.jupiter.api.Test)2 GenerateClustersConfig (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1