Search in sources :

Example 11 with ItemAttributesRQ

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

the class ReportPortalExtension method buildStartLaunchRq.

/**
 * Extension point to customize launch creation event/request
 *
 * @param parameters Launch Configuration parameters
 * @return Request to ReportPortal
 */
protected StartLaunchRQ buildStartLaunchRq(ListenerParameters parameters) {
    StartLaunchRQ rq = new StartLaunchRQ();
    rq.setMode(parameters.getLaunchRunningMode());
    rq.setDescription(parameters.getDescription());
    rq.setName(parameters.getLaunchName());
    Set<ItemAttributesRQ> attributes = new HashSet<>(parameters.getAttributes());
    attributes.addAll(collectSystemAttributes(parameters.getSkippedAnIssue()));
    rq.setAttributes(attributes);
    rq.setStartTime(Calendar.getInstance().getTime());
    rq.setRerun(parameters.isRerun());
    rq.setRerunOf(StringUtils.isEmpty(parameters.getRerunOf()) ? null : parameters.getRerunOf());
    return rq;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)

Example 12 with ItemAttributesRQ

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

the class AttributesTest method verify_method_level_attributes.

@Test
public void verify_method_level_attributes() {
    TestUtils.runClasses(MethodLevelAttributesTest.class);
    Launch launch = AttributesTestExtension.LAUNCH;
    ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test
    verify(launch).startTestItem(captor.capture());
    // Start step
    verify(launch).startTestItem(any(), captor.capture());
    StartTestItemRQ testRequest = extractRequest(captor, "suite");
    assertThat(testRequest.getAttributes(), anyOf(nullValue(), emptyIterable()));
    StartTestItemRQ stepRequest = extractRequest(captor, "step");
    assertThat(stepRequest.getAttributes(), hasSize(1));
    ItemAttributesRQ attribute = stepRequest.getAttributes().iterator().next();
    assertThat(attribute.getKey(), equalTo("myKey"));
    assertThat(attribute.getValue(), equalTo("myValue"));
}
Also used : ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Launch(com.epam.reportportal.service.Launch) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) MethodLevelAttributesTest(com.epam.reportportal.junit5.features.attributes.MethodLevelAttributesTest) Test(org.junit.jupiter.api.Test) ClassLevelAttributesTest(com.epam.reportportal.junit5.features.attributes.ClassLevelAttributesTest)

Example 13 with ItemAttributesRQ

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

the class RuntimeUpdatesTest method test_attribute_add.

@Test
public void test_attribute_add() {
    mockLogging(client);
    TestNG result = runTests(TestAttributeAdd.class);
    assertThat(result.getStatus(), equalTo(0));
    ArgumentCaptor<FinishTestItemRQ> finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
    verify(client).finishTestItem(same(stepUuid), finishCaptor.capture());
    FinishTestItemRQ finishItemRequest = finishCaptor.getValue();
    assertThat(finishItemRequest.getAttributes(), hasSize(1));
    ItemAttributesRQ attribute = finishItemRequest.getAttributes().iterator().next();
    assertThat(attribute.getKey(), equalTo("epic"));
    assertThat(attribute.getValue(), equalTo(TestAttributeAdd.EPIC));
}
Also used : TestNG(org.testng.TestNG) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 14 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_test_case_id_override.

@Test
public void test_allure_id_test_case_id_override() {
    runTests(Collections.singletonList(TestNgListener.class), TestAllureIdTestCaseIdOverride.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 Test Case ID"));
}
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 15 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_no_params.

@Test
public void test_allure_id_no_params() {
    runTests(Collections.singletonList(TestNgListener.class), TestAllureIdNoParams.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 no params ID"));
    assertThat(startMethod.getTestCaseId(), equalTo("My no params ID"));
}
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)

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