use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource in project service-api by reportportal.
the class LaunchFinishedEventHandlerTest method shouldNotSendWhenLaunchInDebug.
@Test
void shouldNotSendWhenLaunchInDebug() {
LaunchActivityResource resource = new LaunchActivityResource();
resource.setId(1L);
resource.setName("name");
resource.setProjectId(1L);
LaunchFinishedEvent event = new LaunchFinishedEvent(resource, 1L, "user");
Optional<Launch> launch = LaunchTestUtil.getLaunch(StatusEnum.FAILED, LaunchModeEnum.DEBUG);
when(launchRepository.findById(event.getLaunchActivityResource().getId())).thenReturn(launch);
launchFinishedEventHandler.onApplicationEvent(event);
verify(projectRepository, times(0)).findById(launch.get().getId());
}
use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource in project service-api by reportportal.
the class LaunchAutoAnalysisSubscriberTest method shouldAnalyzeWhenEnabled.
@Test
void shouldAnalyzeWhenEnabled() {
LaunchActivityResource resource = new LaunchActivityResource();
resource.setId(1L);
resource.setName("name");
resource.setProjectId(1L);
LaunchFinishedEvent event = new LaunchFinishedEvent(resource, 1L, "user");
Optional<Launch> launch = LaunchTestUtil.getLaunch(StatusEnum.FAILED, LaunchModeEnum.DEFAULT);
Map<ProjectAttributeEnum, String> mapping = ImmutableMap.<ProjectAttributeEnum, String>builder().put(ProjectAttributeEnum.AUTO_ANALYZER_ENABLED, "true").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
when(analyzerServiceAsync.hasAnalyzers()).thenReturn(true);
when(analyzeCollectorFactory.getCollector(AnalyzeItemsMode.TO_INVESTIGATE)).thenReturn(analyzeItemsCollector);
when(analyzeItemsCollector.collectItems(any(), any(), any())).thenReturn(Lists.newArrayList(1L, 2L));
when(logIndexer.indexLaunchLogs(any(), any(), any())).thenReturn(indexed);
when(analyzerServiceAsync.analyze(any(), any(), any())).thenReturn(analyzed);
doNothing().when(eventPublisher).publishEvent(any());
autoAnalysisSubscriber.handleEvent(event, project, launch.get());
verify(logIndexer, times(1)).indexLaunchLogs(any(), any(), any());
verify(analyzerServiceAsync, times(1)).analyze(any(), any(), any());
verify(eventPublisher, times(1)).publishEvent(any());
}
use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource in project service-api by reportportal.
the class LaunchAutoAnalysisSubscriberTest method shouldNotAnalyzeWhenDisabled.
@Test
void shouldNotAnalyzeWhenDisabled() {
LaunchActivityResource resource = new LaunchActivityResource();
resource.setId(1L);
resource.setName("name");
resource.setProjectId(1L);
LaunchFinishedEvent event = new LaunchFinishedEvent(resource, 1L, "user");
Optional<Launch> launch = LaunchTestUtil.getLaunch(StatusEnum.FAILED, LaunchModeEnum.DEFAULT);
Map<ProjectAttributeEnum, String> mapping = ImmutableMap.<ProjectAttributeEnum, String>builder().put(ProjectAttributeEnum.AUTO_ANALYZER_ENABLED, "false").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
autoAnalysisSubscriber.handleEvent(event, project, launch.get());
verify(analyzerServiceAsync, times(0)).analyze(any(), any(), any());
verify(logIndexer, times(1)).indexLaunchLogs(any(), any(), any());
}
use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource in project service-api by reportportal.
the class LaunchNotificationSubscriberTest method shouldSendWhenNotificationsEnabled.
@Test
void shouldSendWhenNotificationsEnabled() {
LaunchActivityResource resource = new LaunchActivityResource();
resource.setId(1L);
resource.setName("name");
resource.setProjectId(1L);
LaunchFinishedEvent event = new LaunchFinishedEvent(resource, 1L, "user");
Optional<Launch> launch = LaunchTestUtil.getLaunch(StatusEnum.FAILED, LaunchModeEnum.DEFAULT);
launch.get().setName("name1");
Map<ProjectAttributeEnum, String> mapping = ImmutableMap.<ProjectAttributeEnum, String>builder().put(ProjectAttributeEnum.NOTIFICATIONS_ENABLED, "true").put(ProjectAttributeEnum.AUTO_ANALYZER_ENABLED, "true").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
project.setSenderCases(LaunchFinishedTestUtils.getSenderCases());
when(getIntegrationHandler.getEnabledByProjectIdOrGlobalAndIntegrationGroup(project.getId(), IntegrationGroupEnum.NOTIFICATION)).thenReturn(Optional.ofNullable(emailIntegration));
when(userRepository.findLoginById(any())).thenReturn(Optional.of("owner"));
when(mailServiceFactory.getDefaultEmailService(emailIntegration)).thenReturn(Optional.ofNullable(emailService));
launchNotificationSubscriber.handleEvent(event, project, launch.get());
verify(emailService, times(2)).sendLaunchFinishNotification(any(), any(), any(), any());
}
use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource in project service-api by reportportal.
the class LaunchNotificationSubscriberTest method shouldNotSendWhenNotificationsDisabled.
@Test
void shouldNotSendWhenNotificationsDisabled() {
LaunchActivityResource resource = new LaunchActivityResource();
resource.setId(1L);
resource.setName("name");
resource.setProjectId(1L);
LaunchFinishedEvent event = new LaunchFinishedEvent(resource, 1L, "user");
Optional<Launch> launch = LaunchTestUtil.getLaunch(StatusEnum.FAILED, LaunchModeEnum.DEFAULT);
Map<ProjectAttributeEnum, String> mapping = ImmutableMap.<ProjectAttributeEnum, String>builder().put(ProjectAttributeEnum.NOTIFICATIONS_ENABLED, "false").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
launchNotificationSubscriber.handleEvent(event, project, launch.get());
verify(getIntegrationHandler, times(0)).getEnabledByProjectIdOrGlobalAndIntegrationGroup(project.getId(), IntegrationGroupEnum.NOTIFICATION);
}
Aggregations