Search in sources :

Example 26 with StartTestItemRQ

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

the class TestItemControllerValidationTest method startChildTestItemShouldReturnErrorWhenNameIsEmpty.

@Test
public void startChildTestItemShouldReturnErrorWhenNameIsEmpty() throws Exception {
    // GIVEN
    StartTestItemRQ startTestItemRQ = prepareTestItem();
    startTestItemRQ.setName(EMPTY);
    // 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 27 with StartTestItemRQ

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

the class TestItemBuilderTest method testCaseIdGeneratedFromCodeRefAndParamsTest.

@Test
void testCaseIdGeneratedFromCodeRefAndParamsTest() {
    StartTestItemRQ request = new StartTestItemRQ();
    request.setName("item");
    request.setType("step");
    String codeRef = "com.epam.ta.reportportal.core.item.identity.TestCaseIdHandlerImplTest";
    request.setCodeRef(codeRef);
    ParameterResource param1 = new ParameterResource();
    param1.setKey("key1");
    String value1 = "value1";
    param1.setValue(value1);
    ParameterResource param2 = new ParameterResource();
    param2.setKey("key2");
    String value2 = "value2";
    param2.setValue(value2);
    ParameterResource param3 = new ParameterResource();
    param1.setKey("key3");
    request.setParameters(Lists.newArrayList(param1, param2, param3));
    TestItem item = new TestItemBuilder().addStartItemRequest(request).get();
    String expected = codeRef + "[" + value1 + "," + value2 + ",null]";
    assertEquals(expected, item.getTestCaseId());
    assertEquals(expected.hashCode(), item.getTestCaseHash());
}
Also used : ParameterResource(com.epam.ta.reportportal.ws.model.ParameterResource) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 28 with StartTestItemRQ

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

the class TestItemBuilderTest method addStartRqTest.

@Test
void addStartRqTest() {
    final StartTestItemRQ rq = new StartTestItemRQ();
    rq.setType("step");
    final ParameterResource parameterResource = new ParameterResource();
    parameterResource.setKey("key");
    parameterResource.setValue("value");
    rq.setParameters(Collections.singletonList(parameterResource));
    final String uuid = "uuid";
    rq.setUniqueId(uuid);
    final String description = "description";
    rq.setDescription(description);
    final LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    rq.setStartTime(TO_DATE.apply(now));
    final String name = "name";
    rq.setName(name);
    final TestItem testItem = new TestItemBuilder().addStartItemRequest(rq).get();
    assertEquals(TestItemTypeEnum.STEP, testItem.getType());
    final Parameter param = new Parameter();
    param.setKey("key");
    param.setValue("value");
    assertTrue(testItem.getParameters().contains(param));
    assertEquals(uuid, testItem.getUniqueId());
    assertEquals(description, testItem.getDescription());
    assertEquals(now, testItem.getStartTime());
    assertEquals(name, testItem.getName());
}
Also used : LocalDateTime(java.time.LocalDateTime) ParameterResource(com.epam.ta.reportportal.ws.model.ParameterResource) Parameter(com.epam.ta.reportportal.entity.item.Parameter) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 29 with StartTestItemRQ

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

the class StartTestItemHandlerAsyncImplTest method startRootItem.

@Test
void startRootItem() {
    StartTestItemRQ request = new StartTestItemRQ();
    ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    startTestItemHandlerAsync.startRootItem(user, user.getProjectDetails().get("test_project"), request);
    verify(amqpTemplate).convertAndSend(any(), any(), any(), any());
    verify(reportingQueueService).getReportingQueueKey(any());
}
Also used : ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 30 with StartTestItemRQ

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

the class StartTestItemHandlerAsyncImplTest method startChildItem.

@Test
void startChildItem() {
    StartTestItemRQ request = new StartTestItemRQ();
    ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    startTestItemHandlerAsync.startChildItem(user, user.getProjectDetails().get("test_project"), request, "123");
    verify(amqpTemplate).convertAndSend(any(), any(), any(), any());
    verify(reportingQueueService).getReportingQueueKey(any());
}
Also used : ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) 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