use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class StartTestItemHandlerImplTest method startChildItemWithNotExistedLaunch.
@Test
void startChildItemWithNotExistedLaunch() {
ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.MEMBER, 1L);
StartTestItemRQ startTestItemRQ = new StartTestItemRQ();
startTestItemRQ.setLaunchUuid("1");
startTestItemRQ.setStartTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
startTestItemRQ.setLaunchUuid("1");
when(launchRepository.findByUuid("1")).thenReturn(Optional.empty());
ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.startChildItem(rpUser, extractProjectDetails(rpUser, "test_project"), startTestItemRQ, "1"));
assertEquals("Launch '1' not found. Did you use correct Launch ID?", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemAsyncControllerTest method startRootItem.
@Test
void startRootItem() {
ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
StartTestItemRQ startTestItemRQ = new StartTestItemRQ();
ArgumentCaptor<ReportPortalUser> userArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.class);
ArgumentCaptor<ReportPortalUser.ProjectDetails> projectDetailsArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.ProjectDetails.class);
ArgumentCaptor<StartTestItemRQ> requestArgumentCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
when(projectExtractor.extractProjectDetails(any(ReportPortalUser.class), anyString())).thenReturn(user.getProjectDetails().get("test_project"));
testItemAsyncController.startRootItem("test_project", user, startTestItemRQ);
verify(startTestItemHandler).startRootItem(userArgumentCaptor.capture(), projectDetailsArgumentCaptor.capture(), requestArgumentCaptor.capture());
assertEquals(user, userArgumentCaptor.getValue());
assertEquals(user.getProjectDetails().get("test_project"), projectDetailsArgumentCaptor.getValue());
assertEquals(startTestItemRQ, requestArgumentCaptor.getValue());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemAsyncControllerTest method startChildItem.
@Test
void startChildItem() {
ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
StartTestItemRQ startTestItemRQ = new StartTestItemRQ();
String parentItem = "parent";
ArgumentCaptor<ReportPortalUser> userArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.class);
ArgumentCaptor<ReportPortalUser.ProjectDetails> projectDetailsArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.ProjectDetails.class);
ArgumentCaptor<StartTestItemRQ> requestArgumentCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
ArgumentCaptor<String> parentArgumentCaptor = ArgumentCaptor.forClass(String.class);
when(projectExtractor.extractProjectDetails(any(ReportPortalUser.class), anyString())).thenReturn(user.getProjectDetails().get("test_project"));
testItemAsyncController.startChildItem("test_project", user, parentItem, startTestItemRQ);
verify(startTestItemHandler).startChildItem(userArgumentCaptor.capture(), projectDetailsArgumentCaptor.capture(), requestArgumentCaptor.capture(), parentArgumentCaptor.capture());
assertEquals(user, userArgumentCaptor.getValue());
assertEquals(user.getProjectDetails().get("test_project"), projectDetailsArgumentCaptor.getValue());
assertEquals(startTestItemRQ, requestArgumentCaptor.getValue());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemControllerTest method startChildItemPositive.
@Test
void startChildItemPositive() throws Exception {
StartTestItemRQ rq = new StartTestItemRQ();
rq.setLaunchUuid("a7b66ef2-db30-4db7-94df-f5f7786b398a");
rq.setName("ChildItem");
rq.setType("TEST");
rq.setUniqueId(UUID.randomUUID().toString());
rq.setParameters(getParameters());
rq.setStartTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/item/0f7ca5bc-cfae-4cc1-9682-e59c2860131e").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getDefaultToken()))).andExpect(status().isCreated());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemControllerValidationTest method startRootTestItemShouldReturnErrorWhenNameIsGreaterThanOneThousandTwentyFourCharacters.
@Test
public void startRootTestItemShouldReturnErrorWhenNameIsGreaterThanOneThousandTwentyFourCharacters() throws Exception {
// GIVEN
StartTestItemRQ startTestItemRQ = prepareTestItem();
startTestItemRQ.setName(LONG_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + ITEM_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startTestItemRQ)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()).andReturn();
// THEN
ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
assertEquals(INCORRECT_REQUEST, error.getErrorType());
assertEquals(INCORRECT_REQUEST_MESSAGE + "[" + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
Aggregations