Search in sources :

Example 21 with ItemAttributesRQ

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

the class LaunchBuilderTest method addStartRqTest.

@Test
void addStartRqTest() {
    final StartLaunchRQ request = new StartLaunchRQ();
    final String uuid = "uuid";
    request.setUuid(uuid);
    request.setMode(Mode.DEFAULT);
    final String description = "description";
    request.setDescription(description);
    final String name = "name";
    request.setName(name);
    final LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    request.setStartTime(TO_DATE.apply(now));
    request.setAttributes(Sets.newHashSet(new ItemAttributesRQ("key", "value")));
    final Launch launch = new LaunchBuilder().addStartRQ(request).addAttributes(request.getAttributes()).get();
    assertEquals(name, launch.getName());
    assertEquals(uuid, launch.getUuid());
    assertEquals(description, launch.getDescription());
    assertEquals(now, launch.getStartTime());
    assertTrue(launch.getAttributes().contains(new ItemAttribute("key", "value", false)));
    assertEquals(LaunchModeEnum.DEFAULT, launch.getMode());
}
Also used : LocalDateTime(java.time.LocalDateTime) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Example 22 with ItemAttributesRQ

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

the class TestItemBuilderTest method testItemBuilder.

@Test
void testItemBuilder() {
    final Launch launch = new Launch();
    launch.setId(1L);
    launch.setName("name");
    final ParameterResource parameterResource = new ParameterResource();
    parameterResource.setKey("key");
    parameterResource.setValue("value");
    final String description = "description";
    final String typeValue = "step";
    final TestItem testItem = new TestItemBuilder().addDescription(description).addType(typeValue).addLaunchId(launch.getId()).addParameters(Collections.singletonList(parameterResource)).addAttributes(Sets.newHashSet(new ItemAttributesRQ("key", "value"))).addParentId(1L).get();
    assertThat(testItem.getLaunchId()).isEqualToComparingFieldByField(launch.getId());
    assertEquals(description, testItem.getDescription());
    assertEquals(TestItemTypeEnum.STEP, testItem.getType());
    final Parameter param = new Parameter();
    param.setKey("key");
    param.setValue("value");
    assertTrue(testItem.getParameters().contains(param));
    assertThat(testItem.getAttributes()).containsExactly(new ItemAttribute("key", "value", false));
    assertNotNull(testItem.getParentId());
}
Also used : ParameterResource(com.epam.ta.reportportal.ws.model.ParameterResource) Parameter(com.epam.ta.reportportal.entity.item.Parameter) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 23 with ItemAttributesRQ

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

the class ContentUtils method getAttributesInRange.

public static Set<ItemAttributesRQ> getAttributesInRange(int limit) {
    List<Pair<String, String>> content = readAttributes("demo/content/attributes.txt");
    int fromIndex = random.nextInt(content.size() - limit);
    return content.subList(fromIndex, fromIndex + limit).stream().map(it -> {
        if (it.getKey().isEmpty()) {
            return new ItemAttributesRQ(null, it.getValue());
        } else {
            return new ItemAttributesRQ(it.getKey(), it.getValue());
        }
    }).collect(Collectors.toSet());
}
Also used : TestItemTypeEnum(com.epam.ta.reportportal.entity.enums.TestItemTypeEnum) IntStream(java.util.stream.IntStream) Issue(com.epam.ta.reportportal.ws.model.issue.Issue) CaseFormat(com.google.common.base.CaseFormat) UTF_8(java.nio.charset.StandardCharsets.UTF_8) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) Range(com.google.common.collect.Range) ClassPathResource(org.springframework.core.io.ClassPathResource) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Set(java.util.Set) IOException(java.io.IOException) InputStreamReader(java.io.InputStreamReader) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) SplittableRandom(java.util.SplittableRandom) Preconditions(com.google.common.base.Preconditions) BufferedReader(java.io.BufferedReader) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Pair(org.apache.commons.lang3.tuple.Pair)

Example 24 with ItemAttributesRQ

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

the class CustomAttributeReporter method buildStartLaunchRq.

@Override
protected StartLaunchRQ buildStartLaunchRq(Date startTime, ListenerParameters parameters) {
    StartLaunchRQ rq = super.buildStartLaunchRq(startTime, parameters);
    getCustomLaunchAttributes().forEach((key, value) -> rq.getAttributes().add(new ItemAttributesRQ(key, value)));
    return rq;
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)

Example 25 with ItemAttributesRQ

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

the class AttributesTest method verify_class_level_attributes.

@Test
public void verify_class_level_attributes() {
    TestUtils.runClasses(ClassLevelAttributesTest.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(), hasSize(1));
    ItemAttributesRQ attribute = testRequest.getAttributes().iterator().next();
    assertThat(attribute.getKey(), equalTo(ClassLevelAttributesTest.KEY));
    assertThat(attribute.getValue(), equalTo(ClassLevelAttributesTest.VALUE));
    StartTestItemRQ stepRequest = extractRequest(captor, "step");
    assertThat(stepRequest.getAttributes(), anyOf(nullValue(), emptyIterable()));
}
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)

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