use of com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent 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);
}
use of com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent in project service-api by reportportal.
the class LaunchPatternAnalysisSubscriberTest method shouldAnalyzeWhenEnabled.
@Test
public 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_PATTERN_ANALYZER_ENABLED, "true").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
patternAnalysisSubscriber.handleEvent(event, project, launch.get());
verify(patternAnalyzer, times(1)).analyzeTestItems(launch.get(), Collections.singleton(AnalyzeItemsMode.TO_INVESTIGATE));
}
use of com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent in project service-api by reportportal.
the class LaunchPatternAnalysisSubscriberTest method shouldNotAnalyzeWhenDisabled.
@Test
public 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_PATTERN_ANALYZER_ENABLED, "false").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
patternAnalysisSubscriber.handleEvent(event, project, launch.get());
verify(patternAnalyzer, times(0)).analyzeTestItems(launch.get(), Sets.newHashSet());
}
use of com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent in project service-api by reportportal.
the class InterruptBrokenLaunchesJob method publishFinishEvent.
private void publishFinishEvent(Launch launch) {
final LaunchActivityResource eventResource = TO_ACTIVITY_RESOURCE.apply(launch);
final LaunchFinishedEvent event = new LaunchFinishedEvent();
event.setLaunchActivityResource(eventResource);
eventPublisher.publishEvent(event);
}
use of com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent in project service-api by reportportal.
the class LaunchFinishedEventHandlerTest method shouldSendWhenAutoAnalyzedDisabledEnabled.
@Test
void shouldSendWhenAutoAnalyzedDisabledEnabled() {
LaunchActivityResource resource = new LaunchActivityResource();
resource.setId(1L);
resource.setName("name");
resource.setProjectId(1L);
LaunchFinishedEvent event = new LaunchFinishedEvent(resource, 1L, "user");
Launch launch = LaunchTestUtil.getLaunch(StatusEnum.FAILED, LaunchModeEnum.DEFAULT).get();
launch.setName("name1");
Map<ProjectAttributeEnum, String> mapping = ImmutableMap.<ProjectAttributeEnum, String>builder().put(ProjectAttributeEnum.NOTIFICATIONS_ENABLED, "true").put(ProjectAttributeEnum.AUTO_ANALYZER_ENABLED, "false").build();
Project project = new Project();
project.setId(1L);
project.setProjectAttributes(LaunchFinishedTestUtils.getProjectAttributes(mapping));
project.setSenderCases(LaunchFinishedTestUtils.getSenderCases());
when(launchRepository.findById(event.getLaunchActivityResource().getId())).thenReturn(Optional.ofNullable(launch));
when(projectRepository.findById(resource.getProjectId())).thenReturn(Optional.ofNullable(project));
launchFinishedEventHandler.onApplicationEvent(event);
verify(autoAnalysisSubscriber, times(1)).handleEvent(event, project, launch);
verify(notificationSubscriber, times(1)).handleEvent(event, project, launch);
}
Aggregations