Search in sources :

Example 21 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project seleniumRobot by bhecquet.

the class ReportPortalService method getLaunchOverriddenProperties.

private static Supplier<Launch> getLaunchOverriddenProperties() {
    ListenerParameters parameters = new ListenerParameters(PropertiesLoader.load());
    parameters.setCallbackReportingEnabled(true);
    ReportPortal reportPortal = ReportPortal.builder().withParameters(parameters).build();
    StartLaunchRQ rq = buildStartLaunch(reportPortal.getParameters());
    rpLaunch = reportPortal.newLaunch(rq);
    return () -> rpLaunch;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) ReportPortal(com.epam.reportportal.service.ReportPortal)

Example 22 with StartLaunchRQ

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

the class StartLaunchHandlerImplTest method startLaunch.

@Test
void startLaunch() {
    final ReportPortalUser rpUser = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    StartLaunchRQ startLaunchRQ = new StartLaunchRQ();
    startLaunchRQ.setStartTime(new Date());
    startLaunchRQ.setName("test");
    Launch launch = new Launch();
    launch.setId(1L);
    when(launchRepository.save(any(Launch.class))).then(a -> {
        Launch l = a.getArgument(0);
        l.setId(1L);
        return l;
    }).thenReturn(launch);
    final StartLaunchRS startLaunchRS = startLaunchHandlerImpl.startLaunch(rpUser, extractProjectDetails(rpUser, "test_project"), startLaunchRQ);
    verify(launchRepository, times(1)).refresh(any(Launch.class));
    verify(eventPublisher, times(1)).publishEvent(any());
    assertNotNull(startLaunchRS);
}
Also used : InjectMocks(org.mockito.InjectMocks) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Launch(com.epam.ta.reportportal.entity.launch.Launch) Mock(org.mockito.Mock) Date(java.util.Date) UserRepository(com.epam.ta.reportportal.dao.UserRepository) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) RerunHandler(com.epam.ta.reportportal.core.launch.rerun.RerunHandler) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ProjectRole(com.epam.ta.reportportal.entity.project.ProjectRole) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) UserRole(com.epam.ta.reportportal.entity.user.UserRole) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Assertions(org.junit.jupiter.api.Assertions) TestProjectExtractor.extractProjectDetails(com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ReportPortalUserUtil.getRpUser(com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 23 with StartLaunchRQ

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

the class StartLaunchHandlerImplTest method accessDeniedForCustomerRoleAndDebugMode.

@Test
void accessDeniedForCustomerRoleAndDebugMode() {
    final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.CUSTOMER, 1L);
    StartLaunchRQ startLaunchRQ = new StartLaunchRQ();
    startLaunchRQ.setStartTime(new Date());
    startLaunchRQ.setMode(Mode.DEBUG);
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> startLaunchHandlerImpl.startLaunch(rpUser, extractProjectDetails(rpUser, "test_project"), startLaunchRQ));
    assertEquals("Forbidden operation.", exception.getMessage());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 24 with StartLaunchRQ

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

the class RerunHandlerImplTest method exceptionWhenLaunchIsNotStoredInDbByName.

@Test
void exceptionWhenLaunchIsNotStoredInDbByName() {
    StartLaunchRQ request = new StartLaunchRQ();
    String launchName = "launch";
    long projectId = 1L;
    request.setRerun(true);
    request.setName(launchName);
    ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
    when(launchRepository.findLatestByNameAndProjectId(launchName, projectId)).thenReturn(Optional.empty());
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> rerunHandler.handleLaunch(request, projectId, rpUser));
    assertEquals("Launch 'launch' not found. Did you use correct Launch ID?", exception.getMessage());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 25 with StartLaunchRQ

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

the class RerunHandlerImplTest method happyRerunLaunch.

@Test
void happyRerunLaunch() {
    StartLaunchRQ request = new StartLaunchRQ();
    String launchName = "launch";
    long projectId = 1L;
    request.setRerun(true);
    request.setName(launchName);
    request.setMode(Mode.DEFAULT);
    request.setDescription("desc");
    request.setAttributes(Sets.newHashSet(new ItemAttributesRQ("test", "test")));
    ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
    when(launchRepository.findLatestByNameAndProjectId("launch", projectId)).thenReturn(Optional.of(getLaunch("uuid")));
    final Launch launch = rerunHandler.handleLaunch(request, projectId, rpUser);
    assertNotNull(launch.getNumber());
    assertNotNull(launch.getId());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Aggregations

StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)35 Test (org.junit.jupiter.api.Test)20 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)10 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)9 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)7 Launch (com.epam.ta.reportportal.entity.launch.Launch)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)6 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)5 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)4 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 LaunchBuilder (com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)3 Date (java.util.Date)3 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)3 ReportPortal (com.epam.reportportal.service.ReportPortal)2 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)2 IdentityUtil (com.epam.ta.reportportal.core.item.identity.IdentityUtil)2 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)2 TestItem (com.epam.ta.reportportal.entity.item.TestItem)2 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)2