Search in sources :

Example 1 with AnalyzeLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ in project service-api by reportportal.

the class LaunchAutoAnalysisStrategyTest method analyzeTest.

@Test
void analyzeTest() {
    when(analyzerServiceAsync.hasAnalyzers()).thenReturn(true);
    when(launchRepository.findById(1L)).thenReturn(Optional.of(launch));
    when(launch.getId()).thenReturn(1L);
    when(launch.getProjectId()).thenReturn(1L);
    when(launch.getMode()).thenReturn(LaunchModeEnum.DEFAULT);
    when(projectRepository.findById(1L)).thenReturn(Optional.of(project));
    when(project.getId()).thenReturn(1L);
    when(project.getProjectAttributes()).thenReturn(Sets.newHashSet());
    when(analyzeCollectorFactory.getCollector(any(AnalyzeItemsMode.class))).thenReturn(analyzeItemsCollector);
    ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
    when(analyzeItemsCollector.collectItems(1L, 1L, user)).thenReturn(Lists.newArrayList());
    ReportPortalUser.ProjectDetails projectDetails = new ReportPortalUser.ProjectDetails(1L, "name", ProjectRole.PROJECT_MANAGER);
    AnalyzeLaunchRQ analyzeLaunchRQ = new AnalyzeLaunchRQ();
    analyzeLaunchRQ.setLaunchId(1L);
    analyzeLaunchRQ.setAnalyzerHistoryMode("ALL");
    analyzeLaunchRQ.setAnalyzeItemsModes(Lists.newArrayList("TO_INVESTIGATE"));
    analyzeLaunchRQ.setAnalyzerTypeName("patternAnalyzer");
    launchAutoAnalysisStrategy.analyze(analyzeLaunchRQ, projectDetails, user);
    verify(eventPublisher, times(1)).publishEvent(any(AnalysisEvent.class));
}
Also used : AnalyzeLaunchRQ(com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ) AnalysisEvent(com.epam.ta.reportportal.core.events.AnalysisEvent) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) AnalyzeItemsMode(com.epam.ta.reportportal.core.analyzer.auto.strategy.analyze.AnalyzeItemsMode) Test(org.junit.jupiter.api.Test)

Example 2 with AnalyzeLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ in project service-api by reportportal.

the class LaunchPatternAnalysisStrategyTest method analyzeTest.

@Test
void analyzeTest() {
    when(launchRepository.findById(1L)).thenReturn(Optional.of(launch));
    when(launch.getProjectId()).thenReturn(1L);
    when(launch.getMode()).thenReturn(LaunchModeEnum.DEFAULT);
    when(projectRepository.findById(1L)).thenReturn(Optional.of(project));
    ProjectAttribute projectAttribute = new ProjectAttribute();
    projectAttribute.setValue("true");
    Attribute attribute = new Attribute();
    projectAttribute.setAttribute(attribute);
    when(project.getProjectAttributes()).thenReturn(Sets.newHashSet(projectAttribute));
    ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
    ReportPortalUser.ProjectDetails projectDetails = new ReportPortalUser.ProjectDetails(1L, "name", ProjectRole.PROJECT_MANAGER);
    AnalyzeLaunchRQ analyzeLaunchRQ = new AnalyzeLaunchRQ();
    analyzeLaunchRQ.setLaunchId(1L);
    analyzeLaunchRQ.setAnalyzeItemsModes(Lists.newArrayList("TO_INVESTIGATE"));
    analyzeLaunchRQ.setAnalyzerTypeName("patternAnalyzer");
    launchPatternAnalysisStrategy.analyze(analyzeLaunchRQ, projectDetails, user);
    verify(patternAnalyzer, times(1)).analyzeTestItems(launch, Sets.newHashSet(AnalyzeItemsMode.TO_INVESTIGATE));
}
Also used : Attribute(com.epam.ta.reportportal.entity.attribute.Attribute) ProjectAttribute(com.epam.ta.reportportal.entity.project.ProjectAttribute) AnalyzeLaunchRQ(com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) ProjectAttribute(com.epam.ta.reportportal.entity.project.ProjectAttribute) Test(org.junit.jupiter.api.Test)

Example 3 with AnalyzeLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ in project service-api by reportportal.

the class LaunchControllerTest method getSuggestedItemsAnalyzerNotDeployed.

@Test
void getSuggestedItemsAnalyzerNotDeployed() throws Exception {
    AnalyzeLaunchRQ analyzeLaunchRQ = new AnalyzeLaunchRQ();
    analyzeLaunchRQ.setLaunchId(1L);
    analyzeLaunchRQ.setAnalyzeItemsModes(Collections.singletonList("TO_INVESTIGATE"));
    analyzeLaunchRQ.setAnalyzerTypeName("autoAnalyzer");
    analyzeLaunchRQ.setAnalyzerHistoryMode("ALL");
    mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/launch/analyze").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(analyzeLaunchRQ)).contentType(APPLICATION_JSON)).andExpect(result -> assertTrue(result.getResolvedException() instanceof ReportPortalException)).andExpect(result -> assertEquals("Impossible interact with integration. There are no analyzer services are deployed.", result.getResolvedException().getMessage()));
}
Also used : UpdateLaunchRQ(com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_PROJECT_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID) java.util(java.util) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) DeleteBulkRQ(com.epam.ta.reportportal.ws.model.DeleteBulkRQ) BulkInfoUpdateRQ(com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ) BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) DEFAULT(com.epam.ta.reportportal.ws.model.launch.Mode.DEFAULT) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) Lists(com.google.common.collect.Lists) Collectors.toMap(java.util.stream.Collectors.toMap) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) UpdateItemAttributeRQ(com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) DEBUG(com.epam.ta.reportportal.ws.model.launch.Mode.DEBUG) Filter(com.epam.ta.reportportal.commons.querygen.Filter) LaunchModeEnum(com.epam.ta.reportportal.entity.enums.LaunchModeEnum) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) Sets(com.google.common.collect.Sets) ZoneId(java.time.ZoneId) AnalyzeLaunchRQ(com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ) Test(org.junit.jupiter.api.Test) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Stream(java.util.stream.Stream) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) Assertions(org.junit.jupiter.api.Assertions) AnalyzeLaunchRQ(com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

AnalyzeLaunchRQ (com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ)3 Test (org.junit.jupiter.api.Test)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)1 CRITERIA_PROJECT_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID)1 AnalyzeItemsMode (com.epam.ta.reportportal.core.analyzer.auto.strategy.analyze.AnalyzeItemsMode)1 AnalysisEvent (com.epam.ta.reportportal.core.events.AnalysisEvent)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 Attribute (com.epam.ta.reportportal.entity.attribute.Attribute)1 LaunchModeEnum (com.epam.ta.reportportal.entity.enums.LaunchModeEnum)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 ProjectAttribute (com.epam.ta.reportportal.entity.project.ProjectAttribute)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)1 BulkInfoUpdateRQ (com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ)1 BulkRQ (com.epam.ta.reportportal.ws.model.BulkRQ)1 DeleteBulkRQ (com.epam.ta.reportportal.ws.model.DeleteBulkRQ)1 FinishExecutionRQ (com.epam.ta.reportportal.ws.model.FinishExecutionRQ)1