Search in sources :

Example 16 with UpdateTestItemRQ

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

the class TestItemControllerTest method changeStatusFromFailedToSkipped.

@Sql("/db/test-item/item-change-status-from-failed.sql")
@Test
void changeStatusFromFailedToSkipped() 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.AUTOMATION_BUG, 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)

Example 17 with UpdateTestItemRQ

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

the class TestItemControllerTest method changeStatusFromInterruptedToPassed.

@Sql("/db/test-item/item-change-status-from-interrupted.sql")
@Test
void changeStatusFromInterruptedToPassed() 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 18 with UpdateTestItemRQ

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

the class TestItemControllerTest method changeStatusNegative.

@Test
void changeStatusNegative() throws Exception {
    UpdateTestItemRQ request = new UpdateTestItemRQ();
    request.setStatus("failed");
    mockMvc.perform(put(SUPERADMIN_PROJECT_BASE_URL + "/item/5/update").with(token(oAuthHelper.getSuperadminToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().is(400));
}
Also used : UpdateTestItemRQ(com.epam.ta.reportportal.ws.model.item.UpdateTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 19 with UpdateTestItemRQ

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

the class TestItemControllerTest method changeStatusFromPassedToFailed.

@Sql("/db/test-item/item-change-status-from-passed.sql")
@Test
void changeStatusFromPassedToFailed() 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(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 20 with UpdateTestItemRQ

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

the class TestItemControllerTest method changeStatusFromFailedToPassed.

@Sql("/db/test-item/item-change-status-from-failed.sql")
@Test
void changeStatusFromFailedToPassed() 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)

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