Search in sources :

Example 1 with Artifacts

use of com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts in project octane-ci-java-sdk by MicroFocus.

the class SSCTestUtils method getArtificatResponse.

public static String getArtificatResponse(String status) throws IOException {
    Artifacts artifacts = new Artifacts();
    Artifacts.Artifact artifact = new Artifacts.Artifact();
    DateFormat sourceDateFormat = new SimpleDateFormat(DateUtils.sscFormat);
    artifact.uploadDate = sourceDateFormat.format(new Date());
    artifact.status = status;
    artifacts.setData(Arrays.asList(artifact));
    artifacts.setCount(1);
    return SSCTestUtils.getJson(artifacts);
}
Also used : Artifacts(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with Artifacts

use of com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts in project octane-ci-java-sdk by MicroFocus.

the class SSCInput method buildInputWithDefaults.

public static SSCInput buildInputWithDefaults(List<Issues.Issue> issuesToReturn) {
    SSCInput sscInput = new SSCInput();
    sscInput.withProject("project-a", 2);
    sscInput.withProjectVersion("version-a", 22);
    Artifacts artifacts = buildArtifactsInput(System.currentTimeMillis());
    sscInput.setArtifactsPage(artifacts);
    Issues issues = new Issues();
    issues.setData(new ArrayList<>());
    issues.getData().addAll(issuesToReturn);
    issues.setCount(issues.getData().size());
    sscInput.setIssuesToReturn(issues);
    return sscInput;
}
Also used : Artifacts(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues)

Example 3 with Artifacts

use of com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts in project octane-ci-java-sdk by MicroFocus.

the class SSCInput method createArtifacts.

public static Artifacts createArtifacts(long startTimeOfBuild, String artifactStatus) {
    Artifacts.Artifact artifact = new Artifacts.Artifact();
    artifact.id = 1;
    artifact.status = artifactStatus;
    DateFormat sourceDateFormat = new SimpleDateFormat(DateUtils.sscFormat);
    Date date = new Date(startTimeOfBuild + 7000);
    artifact.uploadDate = sourceDateFormat.format(date);
    Artifacts artifacts = new Artifacts();
    artifacts.setData(Arrays.asList(artifact));
    artifacts.setCount(1);
    return artifacts;
}
Also used : Artifacts(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 4 with Artifacts

use of com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts in project octane-ci-java-sdk by MicroFocus.

the class SSCHandler method isScanProcessFinished.

public boolean isScanProcessFinished() {
    logger.debug("enter isScanProcessFinished");
    Artifacts artifacts = sscProjectConnector.getArtifactsOfProjectVersion(this.projectVersion.id, 10);
    Artifacts.Artifact closestArtifact = getClosestArtifact(artifacts);
    if (closestArtifact == null) {
        logger.debug("Cannot find artifact of the run");
        return false;
    }
    if (closestArtifact.status.equals(ARTIFACT_STATUS_COMPLETE)) {
        logger.debug("artifact of the run is in completed");
        return true;
    }
    if (closestArtifact.status.equals(ARTIFACT_ERROR_PROCESSING)) {
        throw new PermanentException("artifact of the run faced error, polling should stop");
    }
    // todo , if there are more cases need to handle separately
    logger.debug("artifact of the run is not complete, polling should continue");
    return false;
}
Also used : Artifacts(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts) PermanentException(com.hp.octane.integrations.exceptions.PermanentException)

Aggregations

Artifacts (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Artifacts)4 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 PermanentException (com.hp.octane.integrations.exceptions.PermanentException)1 Issues (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues)1