Search in sources :

Example 1 with LaunchActivityResource

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

Example 2 with LaunchActivityResource

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());
}
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 3 with LaunchActivityResource

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());
}
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 4 with LaunchActivityResource

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());
}
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 5 with LaunchActivityResource

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);
}
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

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