Search in sources :

Example 1 with AnalyzerServiceClient

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());
}
Also used : AnalyzedItemRs(com.epam.ta.reportportal.ws.model.analyzer.AnalyzedItemRs) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) java.util(java.util) Project(com.epam.ta.reportportal.entity.project.Project) IssueTypeHandler(com.epam.ta.reportportal.core.item.impl.IssueTypeHandler) TestItem(com.epam.ta.reportportal.entity.item.TestItem) LogLevel(com.epam.ta.reportportal.entity.enums.LogLevel) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) LaunchPreparerService(com.epam.ta.reportportal.core.analyzer.auto.impl.preparer.LaunchPreparerService) Launch(com.epam.ta.reportportal.entity.launch.Launch) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) ALL_LAUNCHES(com.epam.ta.reportportal.entity.AnalyzeMode.ALL_LAUNCHES) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) VerificationModeFactory.times(org.mockito.internal.verification.VerificationModeFactory.times) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PRODUCT_BUG(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup.PRODUCT_BUG) IndexLog(com.epam.ta.reportportal.ws.model.analyzer.IndexLog) AnalyzerServiceClient(com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) Test(org.junit.jupiter.api.Test)

Aggregations

AnalyzerServiceClient (com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient)1 LaunchPreparerService (com.epam.ta.reportportal.core.analyzer.auto.impl.preparer.LaunchPreparerService)1 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)1 IssueTypeHandler (com.epam.ta.reportportal.core.item.impl.IssueTypeHandler)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1 ALL_LAUNCHES (com.epam.ta.reportportal.entity.AnalyzeMode.ALL_LAUNCHES)1 LogLevel (com.epam.ta.reportportal.entity.enums.LogLevel)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 PRODUCT_BUG (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup.PRODUCT_BUG)1 TestItem (com.epam.ta.reportportal.entity.item.TestItem)1 TestItemResults (com.epam.ta.reportportal.entity.item.TestItemResults)1 IssueEntity (com.epam.ta.reportportal.entity.item.issue.IssueEntity)1 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 Project (com.epam.ta.reportportal.entity.project.Project)1 AnalyzedItemRs (com.epam.ta.reportportal.ws.model.analyzer.AnalyzedItemRs)1 IndexLaunch (com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch)1 IndexLog (com.epam.ta.reportportal.ws.model.analyzer.IndexLog)1 IndexTestItem (com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem)1 AnalyzerConfig (com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)1