use of com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient 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());
}
Aggregations