use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ 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;
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ 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));
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project agent-java-testNG by reportportal.
the class BuildTestTest method testStartLaunchRq_NullDescription.
@Test
public void testStartLaunchRq_NullDescription() {
ListenerParameters parameters = new ListenerParameters();
StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
assertThat("Description should be null", startLaunchRQ.getDescription(), nullValue());
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project agent-java-testNG by reportportal.
the class BuildTestTest method testPredefinedAttributes.
@Test
public void testPredefinedAttributes() {
final ListenerParameters parameters = new ListenerParameters();
parameters.setSkippedAnIssue(null);
StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
assertThat(startLaunchRQ.getAttributes().size(), Matchers.is(3));
Set<String> keys = startLaunchRQ.getAttributes().stream().map(ItemAttributeResource::getKey).collect(toSet());
predefinedProperties.forEach((predefinedKey, predefinedValue) -> assertTrue(keys.contains(predefinedKey)));
startLaunchRQ.getAttributes().forEach(attribute -> {
assertThat(attribute.getValue(), matchesPattern(predefinedProperties.get(attribute.getKey())));
assertTrue(attribute.isSystem());
});
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.
the class StartLaunchHandlerImpl method startLaunch.
@Override
@Transactional
public StartLaunchRS startLaunch(ReportPortalUser user, ReportPortalUser.ProjectDetails projectDetails, StartLaunchRQ request) {
validateRoles(projectDetails, request);
final Launch savedLaunch = Optional.of(request.isRerun()).filter(Boolean::booleanValue).map(rerun -> rerunHandler.handleLaunch(request, projectDetails.getProjectId(), user)).orElseGet(() -> {
Launch launch = new LaunchBuilder().addStartRQ(request).addAttributes(request.getAttributes()).addProject(projectDetails.getProjectId()).addUserId(user.getUserId()).get();
launchRepository.save(launch);
launchRepository.refresh(launch);
return launch;
});
eventPublisher.publishEvent(new StartLaunchEvent(savedLaunch.getId()));
messageBus.publishActivity(new LaunchStartedEvent(TO_ACTIVITY_RESOURCE.apply(savedLaunch), user.getUserId(), user.getUsername()));
StartLaunchRS response = new StartLaunchRS();
response.setId(savedLaunch.getUuid());
response.setNumber(savedLaunch.getNumber());
return response;
}
Aggregations