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());
}
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());
}
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());
}
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;
}
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()));
}
Aggregations