Search in sources :

Example 6 with LaunchFinishedEvent

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);
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) LaunchActivityResource(com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent) ProjectAttributeEnum(com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Example 7 with LaunchFinishedEvent

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));
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) LaunchActivityResource(com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent) ProjectAttributeEnum(com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Example 8 with LaunchFinishedEvent

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());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) LaunchActivityResource(com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent) ProjectAttributeEnum(com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Example 9 with LaunchFinishedEvent

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);
}
Also used : LaunchActivityResource(com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent)

Example 10 with LaunchFinishedEvent

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);
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) LaunchActivityResource(com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource) LaunchFinishedEvent(com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent) ProjectAttributeEnum(com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Aggregations

LaunchFinishedEvent (com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent)11 Launch (com.epam.ta.reportportal.entity.launch.Launch)10 LaunchActivityResource (com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource)9 Test (org.junit.jupiter.api.Test)8 ProjectAttributeEnum (com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum)7 Project (com.epam.ta.reportportal.entity.project.Project)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 LaunchBuilder (com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)2 LaunchFinishForcedEvent (com.epam.ta.reportportal.core.events.activity.LaunchFinishForcedEvent)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1 FinishLaunchRS (com.epam.ta.reportportal.ws.model.launch.FinishLaunchRS)1 Date (java.util.Date)1