use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemControllerTest method startRootItemPositive.
@Test
void startRootItemPositive() throws Exception {
StartTestItemRQ rq = new StartTestItemRQ();
rq.setLaunchUuid("a7b66ef2-db30-4db7-94df-f5f7786b398a");
rq.setName("RootItem");
rq.setType("SUITE");
rq.setParameters(getParameters());
rq.setUniqueId(UUID.randomUUID().toString());
rq.setStartTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/item").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(rq)).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 startChildTestItemShouldReturnErrorWhenNameIsGreaterThanOneThousandTwentyFourCharacters.
@Test
public void startChildTestItemShouldReturnErrorWhenNameIsGreaterThanOneThousandTwentyFourCharacters() throws Exception {
// GIVEN
StartTestItemRQ startTestItemRQ = prepareTestItem();
startTestItemRQ.setName(LONG_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + ITEM_PATH + PARENT_ID_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());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemControllerValidationTest method startRootTestItemShouldReturnErrorWhenNameIsEmpty.
@Test
public void startRootTestItemShouldReturnErrorWhenNameIsEmpty() throws Exception {
// GIVEN
StartTestItemRQ startTestItemRQ = prepareTestItem();
startTestItemRQ.setName(EMPTY);
// 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_IS_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemControllerValidationTest method prepareTestItem.
private StartTestItemRQ prepareTestItem() {
StartTestItemRQ startTestItemRQ = new StartTestItemRQ();
startTestItemRQ.setLaunchUuid("a7b66ef2-db30-4db7-94df-f5f7786b398a");
startTestItemRQ.setType("SUITE");
startTestItemRQ.setUniqueId(UUID.randomUUID().toString());
startTestItemRQ.setStartTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
return startTestItemRQ;
}
use of com.epam.ta.reportportal.ws.model.StartTestItemRQ in project service-api by reportportal.
the class TestItemControllerValidationTest method startRootTestItemShouldReturnErrorWhenNameConsistsOfWhitespaces.
@Test
public void startRootTestItemShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
// GIVEN
StartTestItemRQ startTestItemRQ = prepareTestItem();
startTestItemRQ.setName(WHITESPACES_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_IS_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
Aggregations