use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class LaunchAutoAnalysisSubscriber method handleEvent.
@Override
public void handleEvent(LaunchFinishedEvent launchFinishedEvent, Project project, Launch launch) {
AnalyzerConfig analyzerConfig = AnalyzerUtils.getAnalyzerConfig(project);
if (BooleanUtils.isTrue(analyzerConfig.getIsAutoAnalyzerEnabled())) {
List<Long> itemIds = analyzeCollectorFactory.getCollector(AnalyzeItemsMode.TO_INVESTIGATE).collectItems(project.getId(), launch.getId(), launchFinishedEvent.getUser());
logIndexer.indexLaunchLogs(project.getId(), launch.getId(), analyzerConfig).join();
analyzerServiceAsync.analyze(launch, itemIds, analyzerConfig).thenRunAsync(() -> eventPublisher.publishEvent(new LaunchAutoAnalysisFinishEvent(launch.getId()))).join();
// TODO provide executor
CompletableFuture.supplyAsync(() -> logIndexer.indexItemsLogs(project.getId(), launch.getId(), itemIds, analyzerConfig));
} else {
logIndexer.indexLaunchLogs(project.getId(), launch.getId(), analyzerConfig);
eventPublisher.publishEvent(new LaunchAutoAnalysisFinishEvent(launch.getId()));
}
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class AnalyzerServiceServiceTest method analyze.
@Test
void analyze() {
int itemsCount = 2;
Launch launch = launch();
List<TestItem> items = testItemsTI(itemsCount);
items.forEach(item -> item.setLaunchId(launch.getId()));
AnalyzerConfig analyzerConfig = analyzerConfig();
final IndexLaunch indexLaunch = new IndexLaunch();
indexLaunch.setLaunchId(launch.getId());
indexLaunch.setAnalyzerConfig(analyzerConfig);
final List<IndexTestItem> indexTestItems = items.stream().map(AnalyzerUtils::fromTestItem).peek(item -> item.setLogs(errorLogs(2))).collect(Collectors.toList());
indexLaunch.setTestItems(indexTestItems);
when(testItemRepository.findAllById(anyList())).thenReturn(items);
when(launchPreparerService.prepare(any(Launch.class), anyList(), any(AnalyzerConfig.class))).thenReturn(Optional.of(indexLaunch));
when(analyzerServiceClient.analyze(any())).thenReturn(analyzedItems(itemsCount));
when(issueTypeHandler.defineIssueType(anyLong(), eq("pb001"))).thenReturn(issueProductBug().getIssueType());
issuesAnalyzer.runAnalyzers(launch, items.stream().map(TestItem::getItemId).collect(Collectors.toList()), analyzerConfig);
verify(analyzerServiceClient, times(1)).analyze(any());
verify(testItemRepository, times(itemsCount)).save(any());
verify(messageBus, times(4)).publishActivity(any());
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class AnalyzerServiceServiceTest method analyzerConfig.
private AnalyzerConfig analyzerConfig() {
AnalyzerConfig analyzerConfig = new AnalyzerConfig();
analyzerConfig.setAnalyzerMode(ALL_LAUNCHES.getValue());
return analyzerConfig;
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class AnalyzerUtilsTest method testAnalyzerConfig.
@Test
void testAnalyzerConfig() {
AnalyzerConfig config = AnalyzerUtils.getAnalyzerConfig(project());
assertEquals(String.valueOf(config.getIsAutoAnalyzerEnabled()), ProjectAttributeEnum.AUTO_ANALYZER_ENABLED.getDefaultValue());
assertEquals(String.valueOf(config.getNumberOfLogLines()), ProjectAttributeEnum.NUMBER_OF_LOG_LINES.getDefaultValue());
assertEquals(config.getAnalyzerMode(), ProjectAttributeEnum.AUTO_ANALYZER_MODE.getDefaultValue());
assertEquals(String.valueOf(config.getMinShouldMatch()), ProjectAttributeEnum.MIN_SHOULD_MATCH.getDefaultValue());
assertEquals(String.valueOf(config.getSearchLogsMinShouldMatch()), ProjectAttributeEnum.SEARCH_LOGS_MIN_SHOULD_MATCH.getDefaultValue());
assertEquals(String.valueOf(config.isIndexingRunning()), ProjectAttributeEnum.INDEXING_RUNNING.getDefaultValue());
assertEquals(String.valueOf(config.isAllMessagesShouldMatch()), ProjectAttributeEnum.ALL_MESSAGES_SHOULD_MATCH.getDefaultValue());
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class LogIndexerServiceTest method analyzerConfig.
private AnalyzerConfig analyzerConfig() {
AnalyzerConfig analyzerConfig = new AnalyzerConfig();
analyzerConfig.setAnalyzerMode(ALL_LAUNCHES.getValue());
return analyzerConfig;
}
Aggregations