use of com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo in project service-api by reportportal.
the class TestItemControllerTest method handleSuggestChooseAnalyzerNotDeployed.
@Test
void handleSuggestChooseAnalyzerNotDeployed() throws Exception {
SuggestInfo suggestInfo = new SuggestInfo();
suggestInfo.setTestItem(1L);
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/item/suggest/choice").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(Lists.newArrayList(suggestInfo)))).andExpect(result -> assertTrue(result.getResolvedException() instanceof ReportPortalException)).andExpect(result -> assertEquals("Impossible interact with integration. There are no analyzer services with suggest items support deployed.", result.getResolvedException().getMessage()));
}
use of com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo in project service-api by reportportal.
the class SuggestItemServiceTest method suggestClusterItems.
@Test
void suggestClusterItems() {
final ReportPortalUser rpUser = getRpUser("owner", UserRole.USER, ProjectRole.MEMBER, 1L);
final Project project = new Project(1L, "default");
final Cluster cluster = new Cluster();
cluster.setId(1L);
cluster.setLaunchId(1L);
TestItem relevantItem = getRelevantItem();
Launch launch = new Launch();
launch.setId(1L);
final Log log = new Log();
SuggestInfo suggestInfo = new SuggestInfo();
suggestInfo.setRelevantItem(2L);
when(getClusterHandler.getById(1L)).thenReturn(cluster);
when(testItemRepository.findById(2L)).thenReturn(Optional.of(relevantItem));
when(getLaunchHandler.getLaunch(cluster.getLaunchId())).thenReturn(launch);
when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(project);
when(logRepository.findAllUnderTestItemByLaunchIdAndTestItemIdsAndLogLevelGte(launch.getId(), Collections.singletonList(relevantItem.getItemId()), ERROR_INT)).thenReturn(Collections.singletonList(log));
when(analyzerServiceClient.searchSuggests(any(SuggestRq.class))).thenReturn(Collections.singletonList(suggestInfo));
final List<SuggestedItem> suggestedItems = suggestItemService.suggestClusterItems(1L, ReportPortalUser.ProjectDetails.builder().withProjectId(1L).withProjectRole(ProjectRole.MEMBER.name()).build(), rpUser);
Assertions.assertEquals(1, suggestedItems.size());
}
use of com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo in project service-api by reportportal.
the class SuggestItemServiceTest method suggestItems.
@Test
void suggestItems() {
final ReportPortalUser rpUser = getRpUser("owner", UserRole.USER, ProjectRole.MEMBER, 1L);
final Project project = new Project(1L, "default");
TestItem testItem = new TestItem();
testItem.setItemId(1L);
testItem.setLaunchId(1L);
TestItem relevantItem = getRelevantItem();
Launch launch = new Launch();
launch.setId(1L);
final Log log = new Log();
SuggestInfo suggestInfo = new SuggestInfo();
suggestInfo.setRelevantItem(2L);
when(testItemRepository.findById(1L)).thenReturn(Optional.of(testItem));
when(testItemValidator.validate(any(TestItem.class))).thenReturn(true);
when(testItemRepository.findById(2L)).thenReturn(Optional.of(relevantItem));
when(getLaunchHandler.getLaunch(testItem.getLaunchId())).thenReturn(launch);
when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(project);
when(logRepository.findAllUnderTestItemByLaunchIdAndTestItemIdsAndLogLevelGte(launch.getId(), Collections.singletonList(testItem.getItemId()), ERROR_INT)).thenReturn(Collections.singletonList(log));
when(analyzerServiceClient.searchSuggests(any(SuggestRq.class))).thenReturn(Collections.singletonList(suggestInfo));
final List<SuggestedItem> suggestedItems = suggestItemService.suggestItems(1L, ReportPortalUser.ProjectDetails.builder().withProjectId(1L).withProjectRole(ProjectRole.MEMBER.name()).build(), rpUser);
Assertions.assertEquals(1, suggestedItems.size());
}
use of com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo in project service-api by reportportal.
the class SuggestItemServiceTest method suggestRemovedItems.
@Test
void suggestRemovedItems() {
final ReportPortalUser rpUser = getRpUser("owner", UserRole.USER, ProjectRole.MEMBER, 1L);
final Project project = new Project(1L, "default");
TestItem testItem = new TestItem();
testItem.setItemId(1L);
testItem.setLaunchId(1L);
Launch launch = new Launch();
launch.setId(1L);
SuggestInfo suggestInfo = new SuggestInfo();
suggestInfo.setRelevantItem(2L);
when(testItemRepository.findById(1L)).thenReturn(Optional.of(testItem));
when(testItemValidator.validate(any(TestItem.class))).thenReturn(true);
when(getLaunchHandler.getLaunch(testItem.getLaunchId())).thenReturn(launch);
when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(project);
when(testItemRepository.findById(2L)).thenReturn(Optional.empty());
when(analyzerServiceClient.searchSuggests(any(SuggestRq.class))).thenReturn(Collections.singletonList(suggestInfo));
final List<SuggestedItem> suggestedItems = suggestItemService.suggestItems(1L, ReportPortalUser.ProjectDetails.builder().withProjectId(1L).withProjectRole(ProjectRole.MEMBER.name()).build(), rpUser);
Assertions.assertTrue(suggestedItems.isEmpty());
}
Aggregations