Search in sources :

Example 1 with ItemAttributesRQ

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

the class TestNGService 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.setName(parameters.getLaunchName());
    rq.setStartTime(Calendar.getInstance().getTime());
    Set<ItemAttributesRQ> attributes = new HashSet<>(parameters.getAttributes());
    rq.setAttributes(attributes);
    rq.setMode(parameters.getLaunchRunningMode());
    rq.setRerun(parameters.isRerun());
    if (isNotBlank(parameters.getRerunOf())) {
        rq.setRerunOf(parameters.getRerunOf());
    }
    if (isNotBlank(parameters.getDescription())) {
        rq.setDescription(parameters.getDescription());
    }
    if (null != parameters.getSkippedAnIssue()) {
        ItemAttributesRQ skippedIssueAttribute = new ItemAttributesRQ();
        skippedIssueAttribute.setKey(SKIPPED_ISSUE_KEY);
        skippedIssueAttribute.setValue(parameters.getSkippedAnIssue().toString());
        skippedIssueAttribute.setSystem(true);
        attributes.add(skippedIssueAttribute);
    }
    attributes.addAll(SystemAttributesExtractor.extract(AGENT_PROPERTIES_FILE, TestNGService.class.getClassLoader()));
    return rq;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)

Example 2 with ItemAttributesRQ

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

the class AttributeTest method verify_class_level_attributes_bypass.

@Test
public void verify_class_level_attributes_bypass() {
    TestUtils.runTests(Collections.singletonList(TestReportPortalListener.class), ClassLevelAttributesTest.class);
    // Start parent suite
    verify(launch).startTestItem(any());
    ArgumentCaptor<StartTestItemRQ> captor = ArgumentCaptor.forClass(StartTestItemRQ.class);
    // Start test and step
    verify(launch, times(2)).startTestItem(any(), captor.capture());
    StartTestItemRQ testRequest = extractRequest(captor, "test");
    assertThat(testRequest.getAttributes(), hasSize(1));
    ItemAttributesRQ attribute = testRequest.getAttributes().iterator().next();
    assertThat(attribute.getKey(), equalTo(ClassLevelAttributesTest.KEY));
    assertThat(attribute.getValue(), equalTo(ClassLevelAttributesTest.VALUE));
}
Also used : ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) ClassLevelAttributesTest(com.epam.reportportal.testng.integration.feature.attributes.ClassLevelAttributesTest) Test(org.junit.jupiter.api.Test)

Example 3 with ItemAttributesRQ

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

the class BuildTestTest method testSkippedIssue.

@Test
public void testSkippedIssue() {
    ItemAttributesRQ itemAttributeResource = new ItemAttributesRQ();
    itemAttributeResource.setKey(SKIPPED_ISSUE_KEY);
    itemAttributeResource.setValue(String.valueOf(true));
    itemAttributeResource.setSystem(true);
    ListenerParameters parameters = new ListenerParameters();
    parameters.setSkippedAnIssue(true);
    parameters.setAttributes(new HashSet<>());
    StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
    assertTrue(startLaunchRQ.getAttributes().contains(itemAttributeResource));
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Test(org.junit.jupiter.api.Test)

Example 4 with ItemAttributesRQ

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

the class SaucelabsIntegrationTest method sendFinishRequest.

private void sendFinishRequest(TestItemTree.TestItemLeaf testResultLeaf, String sauceLabsJobId) {
    FinishTestItemRQ finishTestItemRQ = new FinishTestItemRQ();
    finishTestItemRQ.setStatus("PASSED");
    finishTestItemRQ.setEndTime(Calendar.getInstance().getTime());
    finishTestItemRQ.setAttributes(Sets.newHashSet(new ItemAttributesRQ("SLID", sauceLabsJobId)));
    ItemTreeReporter.finishItem(TestNGService.getReportPortal().getClient(), finishTestItemRQ, ITEM_TREE.getLaunchId(), testResultLeaf).cache().blockingGet();
}
Also used : ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ)

Example 5 with ItemAttributesRQ

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

the class LaunchControllerTest method happyCreateLaunch.

@Test
void happyCreateLaunch() throws Exception {
    String name = "some launch name";
    StartLaunchRQ startLaunchRQ = new StartLaunchRQ();
    startLaunchRQ.setDescription("some description");
    startLaunchRQ.setName(name);
    startLaunchRQ.setStartTime(new Date());
    startLaunchRQ.setMode(DEFAULT);
    startLaunchRQ.setAttributes(Sets.newHashSet(new ItemAttributesRQ("key", "value")));
    mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/launch/").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startLaunchRQ)).contentType(APPLICATION_JSON)).andExpect(status().isCreated());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) 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