Search in sources :

Example 1 with CIJobsList

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());
    }
}
Also used : CIJobsList(com.hp.octane.integrations.dto.general.CIJobsList) OctaneResultAbridged(com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged) PipelineNode(com.hp.octane.integrations.dto.pipelines.PipelineNode) OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) Test(org.junit.Test)

Example 2 with CIJobsList

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());
        }
    }
}
Also used : CIJobsList(com.hp.octane.integrations.dto.general.CIJobsList) OctaneResultAbridged(com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged) PipelineNode(com.hp.octane.integrations.dto.pipelines.PipelineNode) OctaneTaskAbridged(com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged) CIParameter(com.hp.octane.integrations.dto.parameters.CIParameter) Test(org.junit.Test)

Example 3 with CIJobsList

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;
}
Also used : CIJobsList(com.hp.octane.integrations.dto.general.CIJobsList) Project(org.gitlab4j.api.models.Project) ParsedPath(com.microfocus.octane.gitlab.helpers.ParsedPath) ProjectFilter(org.gitlab4j.api.models.ProjectFilter) ArrayList(java.util.ArrayList) PipelineNode(com.hp.octane.integrations.dto.pipelines.PipelineNode) MalformedURLException(java.net.MalformedURLException) GitLabApiException(org.gitlab4j.api.GitLabApiException)

Aggregations

CIJobsList (com.hp.octane.integrations.dto.general.CIJobsList)3 PipelineNode (com.hp.octane.integrations.dto.pipelines.PipelineNode)3 OctaneResultAbridged (com.hp.octane.integrations.dto.connectivity.OctaneResultAbridged)2 OctaneTaskAbridged (com.hp.octane.integrations.dto.connectivity.OctaneTaskAbridged)2 Test (org.junit.Test)2 CIParameter (com.hp.octane.integrations.dto.parameters.CIParameter)1 ParsedPath (com.microfocus.octane.gitlab.helpers.ParsedPath)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 GitLabApiException (org.gitlab4j.api.GitLabApiException)1 Project (org.gitlab4j.api.models.Project)1 ProjectFilter (org.gitlab4j.api.models.ProjectFilter)1