Search in sources :

Example 1 with UpdateTestItemRQ

use of com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ in project service-api by reportportal.

the class TestItemControllerTest method updateTestItemPositive.

@Test
void updateTestItemPositive() throws Exception {
    UpdateTestItemRQ rq = new UpdateTestItemRQ();
    rq.setDescription("updated");
    rq.setAttributes(Sets.newHashSet(new ItemAttributeResource("test", "test")));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/item/1/update").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(rq))).andExpect(status().isOk());
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with UpdateTestItemRQ

use of com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ in project service-api by reportportal.

the class TestItemControllerTest method changeStatusFromPassedToSkippedWithoutIssue.

@Sql("/db/test-item/item-change-status-from-passed.sql")
@Test
void changeStatusFromPassedToSkippedWithoutIssue() throws Exception {
    UpdateTestItemRQ request = new UpdateTestItemRQ();
    request.setStatus("skipped");
    mockMvc.perform(put(SUPERADMIN_PROJECT_BASE_URL + "/item/9/update").with(token(oAuthHelper.getSuperadminToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
    Optional<TestItem> updatedItem = testItemRepository.findById(9L);
    assertTrue(updatedItem.isPresent());
    assertEquals(StatusEnum.SKIPPED, updatedItem.get().getItemResults().getStatus());
    assertNull(updatedItem.get().getItemResults().getIssue());
    assertEquals(StatusEnum.FAILED, testItemRepository.findById(updatedItem.get().getParentId()).get().getItemResults().getStatus());
    Launch launch = launchRepository.findById(updatedItem.get().getLaunchId()).get();
    assertEquals(StatusEnum.FAILED, launch.getStatus());
    verify(messageBus, times(2)).publishActivity(ArgumentMatchers.any());
}
Also used : UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 3 with UpdateTestItemRQ

use of com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ in project service-api by reportportal.

the class TestItemControllerTest method changeStatusFromPassedToSkipped.

@Sql("/db/test-item/item-change-status-from-passed.sql")
@Test
void changeStatusFromPassedToSkipped() throws Exception {
    UpdateTestItemRQ request = new UpdateTestItemRQ();
    request.setStatus("skipped");
    mockMvc.perform(put(SUPERADMIN_PROJECT_BASE_URL + "/item/6/update").with(token(oAuthHelper.getSuperadminToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
    Optional<TestItem> updatedItem = testItemRepository.findById(6L);
    assertTrue(updatedItem.isPresent());
    assertEquals(StatusEnum.SKIPPED, updatedItem.get().getItemResults().getStatus());
    assertEquals(TestItemIssueGroup.TO_INVESTIGATE, updatedItem.get().getItemResults().getIssue().getIssueType().getIssueGroup().getTestItemIssueGroup());
    assertEquals(StatusEnum.FAILED, testItemRepository.findById(updatedItem.get().getParentId()).get().getItemResults().getStatus());
    Launch launch = launchRepository.findById(updatedItem.get().getLaunchId()).get();
    assertEquals(StatusEnum.FAILED, launch.getStatus());
    verify(messageBus, times(2)).publishActivity(ArgumentMatchers.any());
}
Also used : UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 4 with UpdateTestItemRQ

use of com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ in project service-api by reportportal.

the class TestItemControllerTest method changeStatusFromSkippedToPassed.

@Sql("/db/test-item/item-change-status-from-skipped.sql")
@Test
void changeStatusFromSkippedToPassed() throws Exception {
    UpdateTestItemRQ request = new UpdateTestItemRQ();
    request.setStatus("passed");
    mockMvc.perform(put(SUPERADMIN_PROJECT_BASE_URL + "/item/6/update").with(token(oAuthHelper.getSuperadminToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
    Optional<TestItem> updatedItem = testItemRepository.findById(6L);
    assertTrue(updatedItem.isPresent());
    assertEquals(StatusEnum.PASSED, updatedItem.get().getItemResults().getStatus());
    assertNull(updatedItem.get().getItemResults().getIssue());
    assertEquals(StatusEnum.PASSED, testItemRepository.findById(updatedItem.get().getParentId()).get().getItemResults().getStatus());
    Launch launch = launchRepository.findById(updatedItem.get().getLaunchId()).get();
    assertEquals(StatusEnum.PASSED, launch.getStatus());
    verify(messageBus, times(2)).publishActivity(ArgumentMatchers.any());
}
Also used : UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Example 5 with UpdateTestItemRQ

use of com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ in project service-api by reportportal.

the class TestItemControllerTest method changeStatusFromSkippedToFailed.

@Sql("/db/test-item/item-change-status-from-skipped.sql")
@Test
void changeStatusFromSkippedToFailed() throws Exception {
    UpdateTestItemRQ request = new UpdateTestItemRQ();
    request.setStatus("failed");
    mockMvc.perform(put(SUPERADMIN_PROJECT_BASE_URL + "/item/6/update").with(token(oAuthHelper.getSuperadminToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
    Optional<TestItem> updatedItem = testItemRepository.findById(6L);
    assertTrue(updatedItem.isPresent());
    assertEquals(StatusEnum.FAILED, updatedItem.get().getItemResults().getStatus());
    assertEquals(TestItemIssueGroup.TO_INVESTIGATE, updatedItem.get().getItemResults().getIssue().getIssueType().getIssueGroup().getTestItemIssueGroup());
    assertEquals(StatusEnum.FAILED, testItemRepository.findById(updatedItem.get().getParentId()).get().getItemResults().getStatus());
    Launch launch = launchRepository.findById(updatedItem.get().getLaunchId()).get();
    assertEquals(StatusEnum.FAILED, launch.getStatus());
    verify(messageBus, times(1)).publishActivity(ArgumentMatchers.any());
}
Also used : UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test) Sql(org.springframework.test.context.jdbc.Sql)

Aggregations

UpdateTestItemRQ (com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ)21 Test (org.junit.jupiter.api.Test)20 TestItem (com.epam.ta.reportportal.entity.item.TestItem)18 Launch (com.epam.ta.reportportal.entity.launch.Launch)17 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)12 Sql (org.springframework.test.context.jdbc.Sql)10 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)9 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)8 ReportPortalUserUtil.getRpUser (com.epam.ta.reportportal.ReportPortalUserUtil.getRpUser)4 TestItemResults (com.epam.ta.reportportal.entity.item.TestItemResults)4 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)4 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)3 TestItemService (com.epam.ta.reportportal.core.item.TestItemService)3 StatusChangingStrategy (com.epam.ta.reportportal.core.item.impl.status.StatusChangingStrategy)3 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)3 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)3 ItemAttribute (com.epam.ta.reportportal.entity.ItemAttribute)3 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)3 TestItemTypeEnum (com.epam.ta.reportportal.entity.enums.TestItemTypeEnum)3 ProjectRole (com.epam.ta.reportportal.entity.project.ProjectRole)3