use of com.hp.octane.integrations.dto.general.CIJobsList in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceTests method testJobsNoParamsAPI.
@Test
public void testJobsNoParamsAPI() {
TasksProcessor tasksProcessor = client.getTasksProcessor();
Assert.assertNotNull(tasksProcessor);
OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs?parameters=false");
OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
runCommonAsserts(resultAbridged, taskAbridged.getId(), HttpStatus.SC_OK);
CIJobsList ciJobsList = dtoFactory.dtoFromJson(resultAbridged.getBody(), CIJobsList.class);
Assert.assertNotNull(ciJobsList);
Assert.assertNotNull(ciJobsList.getJobs());
Assert.assertEquals(3, ciJobsList.getJobs().length);
for (PipelineNode ciJob : ciJobsList.getJobs()) {
Assert.assertNotNull(ciJob);
Assert.assertTrue(ciJob.getName().startsWith("Job "));
Assert.assertTrue(ciJob.getJobCiId().startsWith("job-"));
Assert.assertNotNull(ciJob.getParameters());
Assert.assertTrue(ciJob.getParameters().isEmpty());
}
}
use of com.hp.octane.integrations.dto.general.CIJobsList in project octane-ci-java-sdk by MicroFocus.
the class TaskingServiceTests method testJobsWithParamsAPI.
@Test
public void testJobsWithParamsAPI() {
TasksProcessor tasksProcessor = client.getTasksProcessor();
Assert.assertNotNull(tasksProcessor);
OctaneTaskAbridged taskAbridged = dtoFactory.newDTO(OctaneTaskAbridged.class).setId(UUID.randomUUID().toString()).setUrl(OctaneSPEndpointSimulator.getSimulatorUrl() + APIPrefix + "/jobs");
OctaneResultAbridged resultAbridged = tasksProcessor.execute(taskAbridged);
runCommonAsserts(resultAbridged, taskAbridged.getId(), HttpStatus.SC_OK);
CIJobsList ciJobsList = dtoFactory.dtoFromJson(resultAbridged.getBody(), CIJobsList.class);
Assert.assertNotNull(ciJobsList);
Assert.assertNotNull(ciJobsList.getJobs());
Assert.assertEquals(3, ciJobsList.getJobs().length);
for (PipelineNode ciJob : ciJobsList.getJobs()) {
Assert.assertNotNull(ciJob);
Assert.assertTrue(ciJob.getName().startsWith("Job "));
Assert.assertTrue(ciJob.getJobCiId().startsWith("job-"));
Assert.assertNotNull(ciJob.getParameters());
Assert.assertEquals(3, ciJob.getParameters().size());
for (CIParameter ciParameter : ciJob.getParameters()) {
Assert.assertNotNull(ciParameter);
Assert.assertNotNull(ciParameter.getName());
Assert.assertNotNull(ciParameter.getType());
Assert.assertNotNull(ciParameter.getValue());
}
}
}
use of com.hp.octane.integrations.dto.general.CIJobsList in project octane-gitlab-service by MicroFocus.
the class GitlabServices method getJobList.
CIJobsList getJobList() {
CIJobsList ciJobsList = dtoFactory.newDTO(CIJobsList.class);
List<PipelineNode> list = new ArrayList<>();
String projectNames = "";
try {
ProjectFilter filter = new ProjectFilter();
filter.withMinAccessLevel(AccessLevel.MAINTAINER);
List<Project> projectsFilters = gitLabApi.getProjectApi().getProjects(filter);
log.info("There are only " + projectsFilters.size() + " projects with access level => MAINTAINER for the integrated user");
for (Project project : projectsFilters) {
try {
ParsedPath parseProject = new ParsedPath(project, gitLabApi);
PipelineNode buildConf;
if (parseProject.isMultiBranch()) {
buildConf = dtoFactory.newDTO(PipelineNode.class).setJobCiId(parseProject.getJobCiId(true)).setName(project.getNameWithNamespace()).setMultiBranchType(MultiBranchType.MULTI_BRANCH_PARENT);
} else {
buildConf = dtoFactory.newDTO(PipelineNode.class).setJobCiId(parseProject.getJobCiId(false)).setName(project.getNameWithNamespace());
}
projectNames = projectNames + buildConf.getName() + ",";
list.add(buildConf);
} catch (Exception e) {
log.warn("Failed to add some tags to the job list", e);
}
}
} catch (Exception e) {
log.warn("Failed to add some jobs to the job list", e);
}
log.info("getJobList results:" + projectNames);
ciJobsList.setJobs(list.toArray(new PipelineNode[list.size()]));
return ciJobsList;
}
Aggregations