Search in sources :

Example 6 with LaunchActivityResource

use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource 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 7 with LaunchActivityResource

use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource 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 8 with LaunchActivityResource

use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource 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 9 with LaunchActivityResource

use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource 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)

Example 10 with LaunchActivityResource

use of com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource in project service-api by reportportal.

the class LaunchEventsTest method getLaunch.

private static LaunchActivityResource getLaunch(String name) {
    LaunchActivityResource launch = new LaunchActivityResource();
    launch.setId(2L);
    launch.setName(name);
    launch.setProjectId(3L);
    return launch;
}
Also used : LaunchActivityResource(com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource)

Aggregations

LaunchActivityResource (com.epam.ta.reportportal.ws.model.activity.LaunchActivityResource)10 LaunchFinishedEvent (com.epam.ta.reportportal.core.events.activity.LaunchFinishedEvent)9 Launch (com.epam.ta.reportportal.entity.launch.Launch)8 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