Search in sources :

Example 1 with SuggestInfo

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()));
}
Also used : StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) java.util(java.util) ArgumentMatchers(org.mockito.ArgumentMatchers) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) Issue(com.epam.ta.reportportal.ws.model.issue.Issue) TestItem(com.epam.ta.reportportal.entity.item.TestItem) BulkInfoUpdateRQ(com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) DefineIssueRQ(com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ) UnlinkExternalIssueRQ(com.epam.ta.reportportal.ws.model.item.UnlinkExternalIssueRQ) ParameterResource(com.epam.ta.reportportal.ws.model.ParameterResource) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) UpdateItemAttributeRQ(com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ) UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) IssueDefinition(com.epam.ta.reportportal.ws.model.issue.IssueDefinition) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) SuggestInfo(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Mockito.times(org.mockito.Mockito.times) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Sql(org.springframework.test.context.jdbc.Sql) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) LinkExternalIssueRQ(com.epam.ta.reportportal.ws.model.item.LinkExternalIssueRQ) Sets(com.google.common.collect.Sets) ZoneId(java.time.ZoneId) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) Assertions(org.junit.jupiter.api.Assertions) SuggestInfo(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with SuggestInfo

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());
}
Also used : SuggestRq(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestRq) Project(com.epam.ta.reportportal.entity.project.Project) SuggestInfo(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo) Log(com.epam.ta.reportportal.entity.log.Log) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 3 with SuggestInfo

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());
}
Also used : SuggestRq(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestRq) Project(com.epam.ta.reportportal.entity.project.Project) SuggestInfo(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo) Log(com.epam.ta.reportportal.entity.log.Log) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 4 with SuggestInfo

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());
}
Also used : SuggestRq(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestRq) Project(com.epam.ta.reportportal.entity.project.Project) SuggestInfo(com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Aggregations

SuggestInfo (com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestInfo)4 TestItem (com.epam.ta.reportportal.entity.item.TestItem)4 Launch (com.epam.ta.reportportal.entity.launch.Launch)4 Test (org.junit.jupiter.api.Test)4 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)3 SuggestRq (com.epam.ta.reportportal.core.analyzer.auto.client.model.SuggestRq)3 Project (com.epam.ta.reportportal.entity.project.Project)3 Log (com.epam.ta.reportportal.entity.log.Log)2 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1 Cluster (com.epam.ta.reportportal.entity.cluster.Cluster)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)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 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)1 ParameterResource (com.epam.ta.reportportal.ws.model.ParameterResource)1 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)1 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1