Search in sources :

Example 16 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.

the class AllureIdAnnotationTest method test_allure_id_with_params.

@Test
public void test_allure_id_with_params() {
    runTests(Collections.singletonList(TestNgListener.class), TestAllureIdParams.class);
    // Start launch
    verify(client).startLaunch(any());
    // Start parent suites
    verify(client).startTestItem(any());
    // Start test class
    verify(client).startTestItem(same(suitedUuid), any());
    ArgumentCaptor<StartTestItemRQ> startMethodCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test step
    verify(client).startTestItem(same(testClassUuid), startMethodCapture.capture());
    StartTestItemRQ startMethod = startMethodCapture.getValue();
    Set<ItemAttributesRQ> attributes = startMethod.getAttributes();
    List<ItemAttributesRQ> idAttributes = attributes.stream().filter(a -> "AS_ID".equals(a.getKey())).collect(Collectors.toList());
    assertThat(idAttributes, hasSize(1));
    ItemAttributesRQ id = idAttributes.get(0);
    assertThat(id.getValue(), equalTo("My ID"));
    assertThat(startMethod.getTestCaseId(), equalTo("My ID[Data step name]"));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TestAllureIdParams(com.epam.reportportal.testng.features.allureid.TestAllureIdParams) BeforeEach(org.junit.jupiter.api.BeforeEach) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) Set(java.util.Set) ReportPortal(com.epam.reportportal.service.ReportPortal) TestAllureIdTestCaseIdOverride(com.epam.reportportal.testng.features.allureid.TestAllureIdTestCaseIdOverride) TestAllureIdNoParams(com.epam.reportportal.testng.features.allureid.TestAllureIdNoParams) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) List(java.util.List) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestUtils(com.epam.reportportal.testng.util.TestUtils) Collections(java.util.Collections) ArgumentMatchers.same(org.mockito.ArgumentMatchers.same) Mockito.mock(org.mockito.Mockito.mock) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 17 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.

the class FlakyAnnotationTest method test_flaky_annotation_method_level_processing.

@Test
public void test_flaky_annotation_method_level_processing() {
    runTests(Collections.singletonList(TestNgListener.class), TestFlakyMethodLevel.class);
    // Start launch
    verify(client).startLaunch(any());
    // Start parent suites
    verify(client).startTestItem(any());
    // Start test class
    verify(client).startTestItem(same(suitedUuid), any());
    ArgumentCaptor<StartTestItemRQ> startMethodCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test step
    verify(client).startTestItem(same(testClassUuid), startMethodCapture.capture());
    StartTestItemRQ startMethod = startMethodCapture.getValue();
    Set<ItemAttributesRQ> attributes = startMethod.getAttributes();
    List<ItemAttributesRQ> flakyAttributes = attributes.stream().filter(a -> "flaky".equals(a.getValue())).collect(Collectors.toList());
    assertThat(flakyAttributes, hasSize(1));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) TestFlakyClassLevel(com.epam.reportportal.testng.features.flaky.TestFlakyClassLevel) Set(java.util.Set) ReportPortal(com.epam.reportportal.service.ReportPortal) TestFlakyMethodLevel(com.epam.reportportal.testng.features.flaky.TestFlakyMethodLevel) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) List(java.util.List) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestUtils(com.epam.reportportal.testng.util.TestUtils) Collections(java.util.Collections) ArgumentMatchers.same(org.mockito.ArgumentMatchers.same) Mockito.mock(org.mockito.Mockito.mock) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 18 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.

the class FlakyAnnotationTest method test_flaky_annotation_class_level_processing.

@Test
public void test_flaky_annotation_class_level_processing() {
    runTests(Collections.singletonList(TestNgListener.class), TestFlakyClassLevel.class);
    // Start launch
    verify(client).startLaunch(any());
    // Start parent suites
    verify(client).startTestItem(any());
    // Start test class
    verify(client).startTestItem(same(suitedUuid), any());
    ArgumentCaptor<StartTestItemRQ> startMethodCapture = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test step
    verify(client).startTestItem(same(testClassUuid), startMethodCapture.capture());
    StartTestItemRQ startMethod = startMethodCapture.getValue();
    Set<ItemAttributesRQ> attributes = startMethod.getAttributes();
    List<ItemAttributesRQ> flakyAttributes = attributes.stream().filter(a -> "flaky".equals(a.getValue())).collect(Collectors.toList());
    assertThat(flakyAttributes, hasSize(1));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ReportPortalClient(com.epam.reportportal.service.ReportPortalClient) TestFlakyClassLevel(com.epam.reportportal.testng.features.flaky.TestFlakyClassLevel) Set(java.util.Set) ReportPortal(com.epam.reportportal.service.ReportPortal) TestFlakyMethodLevel(com.epam.reportportal.testng.features.flaky.TestFlakyMethodLevel) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) List(java.util.List) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestUtils(com.epam.reportportal.testng.util.TestUtils) Collections(java.util.Collections) ArgumentMatchers.same(org.mockito.ArgumentMatchers.same) Mockito.mock(org.mockito.Mockito.mock) TestNgListener(com.epam.reportportal.testng.util.TestNgListener) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 19 with ItemAttributesRQ

use of com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ in project allure-java by reportportal.

the class AnnotationUtils method processPriority.

public static void processPriority(@Nonnull StartTestItemRQ rq, @Nullable Method source) {
    ofNullable(source).ifPresent(s -> {
        Severity annotation = ofNullable(s.getAnnotation(Severity.class)).orElseGet(() -> source.getDeclaringClass().getAnnotation(Severity.class));
        if (annotation != null) {
            // Allure don't know the difference between priority and severity (-‸ლ)
            ItemAttributesRQ attribute = new ItemAttributesRQ("priority", annotation.value().value());
            Set<ItemAttributesRQ> attributes = retrieveAttributes(rq);
            attributes.add(attribute);
        }
    });
}
Also used : Severity(io.qameta.allure.Severity) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)

Example 20 with ItemAttributesRQ

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

the class RerunHandlerImplTest method happyRerunLaunch.

@Test
void happyRerunLaunch() {
    StartLaunchRQ request = new StartLaunchRQ();
    String launchName = "launch";
    long projectId = 1L;
    request.setRerun(true);
    request.setName(launchName);
    request.setMode(Mode.DEFAULT);
    request.setDescription("desc");
    request.setAttributes(Sets.newHashSet(new ItemAttributesRQ("test", "test")));
    ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
    when(launchRepository.findLatestByNameAndProjectId("launch", projectId)).thenReturn(Optional.of(getLaunch("uuid")));
    final Launch launch = rerunHandler.handleLaunch(request, projectId, rpUser);
    assertNotNull(launch.getNumber());
    assertNotNull(launch.getId());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Aggregations

ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)33 Test (org.junit.jupiter.api.Test)19 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)13 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)11 Collectors (java.util.stream.Collectors)10 ReportPortal (com.epam.reportportal.service.ReportPortal)9 List (java.util.List)8 Set (java.util.Set)8 ReportPortalClient (com.epam.reportportal.service.ReportPortalClient)7 TestNgListener (com.epam.reportportal.testng.util.TestNgListener)7 TestUtils (com.epam.reportportal.testng.util.TestUtils)7 Collections (java.util.Collections)7 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)7 Matchers.hasSize (org.hamcrest.Matchers.hasSize)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 ArgumentCaptor (org.mockito.ArgumentCaptor)7 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)7 ArgumentMatchers.same (org.mockito.ArgumentMatchers.same)7 Mockito.mock (org.mockito.Mockito.mock)7 Mockito.verify (org.mockito.Mockito.verify)7