Search in sources :

Example 1 with LaunchRepository

use of com.epam.ta.reportportal.dao.LaunchRepository 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)

Aggregations

ReportPortalUserUtil.getRpUser (com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)1 RerunHandler (com.epam.ta.reportportal.core.launch.rerun.RerunHandler)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 UserRepository (com.epam.ta.reportportal.dao.UserRepository)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 ProjectRole (com.epam.ta.reportportal.entity.project.ProjectRole)1 UserRole (com.epam.ta.reportportal.entity.user.UserRole)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 TestProjectExtractor.extractProjectDetails (com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails)1 Mode (com.epam.ta.reportportal.ws.model.launch.Mode)1 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)1 StartLaunchRS (com.epam.ta.reportportal.ws.model.launch.StartLaunchRS)1 Date (java.util.Date)1 Assertions (org.junit.jupiter.api.Assertions)1 Test (org.junit.jupiter.api.Test)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 InjectMocks (org.mockito.InjectMocks)1 Mock (org.mockito.Mock)1