Search in sources :

Example 91 with StartTestItemRQ

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

the class TestItemControllerValidationTest method startChildTestItemShouldReturnErrorWhenNameConsistsOfWhitespaces.

@Test
public void startChildTestItemShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
    // GIVEN
    StartTestItemRQ startTestItemRQ = prepareTestItem();
    startTestItemRQ.setName(WHITESPACES_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_IS_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 92 with StartTestItemRQ

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

the class TestItemControllerValidationTest method startRootTestItemShouldReturnErrorWhenNameIsNull.

@Test
public void startRootTestItemShouldReturnErrorWhenNameIsNull() throws Exception {
    // GIVEN
    StartTestItemRQ startTestItemRQ = prepareTestItem();
    // 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_NULL_MESSAGE, error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 93 with StartTestItemRQ

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

the class TestItemControllerValidationTest method startChildTestItemShouldReturnErrorWhenNameIsNull.

@Test
public void startChildTestItemShouldReturnErrorWhenNameIsNull() throws Exception {
    // GIVEN
    StartTestItemRQ startTestItemRQ = prepareTestItem();
    // 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_IS_NULL_MESSAGE, error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 94 with StartTestItemRQ

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

the class TestItemBuilderTest method testCaseIdGeneratedFromCodeRefTest.

@Test
void testCaseIdGeneratedFromCodeRefTest() {
    StartTestItemRQ request = new StartTestItemRQ();
    request.setName("item");
    request.setType("step");
    String codeRef = "com.epam.ta.reportportal.core.item.identity.TestCaseIdHandlerImplTest";
    request.setCodeRef(codeRef);
    TestItem item = new TestItemBuilder().addStartItemRequest(request).get();
    assertEquals(codeRef, item.getTestCaseId());
    assertEquals(codeRef.hashCode(), item.getTestCaseHash());
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 95 with StartTestItemRQ

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

the class TestItemBuilderTest method providedTestCaseIdWith1025SymbolsTest.

@Test
void providedTestCaseIdWith1025SymbolsTest() {
    StartTestItemRQ request = new StartTestItemRQ();
    request.setName("item");
    request.setType("step");
    String testCaseId = RandomStringUtils.random(1025, true, true);
    request.setTestCaseId(testCaseId);
    TestItem item = new TestItemBuilder().addStartItemRequest(request).get();
    assertTrue(item.getTestCaseId().length() <= 1024);
    assertEquals(testCaseId.substring(0, 1010), item.getTestCaseId().substring(0, 1010));
    assertEquals("[" + testCaseId.substring(1011).hashCode() + "]", item.getTestCaseId().substring(1011));
    assertEquals(testCaseId.hashCode(), item.getTestCaseHash());
}
Also used : StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Aggregations

StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)159 Test (org.junit.jupiter.api.Test)124 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)30 List (java.util.List)21 TestNG (org.testng.TestNG)21 Launch (com.epam.reportportal.service.Launch)20 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)19 BeforeEach (org.junit.jupiter.api.BeforeEach)19 TestNgListener (com.epam.reportportal.testng.util.TestNgListener)18 Collectors (java.util.stream.Collectors)17 ArgumentCaptor (org.mockito.ArgumentCaptor)17 ReportPortal (com.epam.reportportal.service.ReportPortal)16 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)15 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)15 ArgumentMatchers.same (org.mockito.ArgumentMatchers.same)14 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)13 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)13 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)12 Set (java.util.Set)12 Nonnull (javax.annotation.Nonnull)12