Search in sources :

Example 6 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class IssuesValidate method getOctaneIssuesPushed.

private OctaneIssuesPushed getOctaneIssuesPushed(String output) throws IOException {
    OctaneIssuesPushed octaneIssuesPushed = null;
    try {
        ObjectMapper objectMapper = new ObjectMapper();
        RawPushedIssues rawPushedIssues = objectMapper.readValue(output, RawPushedIssues.class);
        StringWriter stringWriter = new StringWriter();
        objectMapper.writeValue(stringWriter, rawPushedIssues.data);
        stringWriter.flush();
        String issuesArrayAsString = stringWriter.toString();
        OctaneIssue[] octaneIssuesArray = DTOFactory.getInstance().dtoCollectionFromJson(issuesArrayAsString, OctaneIssue[].class);
        octaneIssuesPushed = new OctaneIssuesPushed();
        octaneIssuesPushed.octaneIssues = Arrays.asList(octaneIssuesArray);
    } catch (IOException e) {
        e.printStackTrace();
        throw e;
    }
    return octaneIssuesPushed;
}
Also used : StringWriter(java.io.StringWriter) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue)

Example 7 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class PackIssuesToSendToOctaneTest method packIssuesToNewAndUpdate.

@Test
public void packIssuesToNewAndUpdate() throws IOException {
    Issues issues = sscIssuesToPack();
    Map<Integer, IssueDetails> idToDetails = getAllData();
    PackIssuesToOctaneUtils.SortedIssues<Issues.Issue> issueSortedIssues = PackIssuesToOctaneUtils.packToOctaneIssues(issues.getData(), new ArrayList<>(), true);
    Assert.assertEquals(2, issueSortedIssues.issuesToUpdate.size());
    Assert.assertEquals(2, issueSortedIssues.issuesRequiredExtendedData.size());
    Assert.assertEquals(0, issueSortedIssues.issuesToClose.size());
    List<OctaneIssue> openOctaneIssues = createOctaneIssues(issueSortedIssues.issuesToUpdate, "Tag", idToDetails);
    validateIssueMap(openOctaneIssues.get(0), "list_node.issue_state_node.new", "\\ABC\\DEF\\GHIJ.java", "1", "Kingdom1", "Issue1");
    validateIssueMap(openOctaneIssues.get(1), "list_node.issue_state_node.existing", "\\ABC\\DEF\\GHIJ\\KLM.java", "2", "Kingdom2", "Issue2");
    validateRemoteIdAndExtendedIssues(openOctaneIssues.get(0), "RemoteId1", idToDetails.get(1));
    validateRemoteIdAndExtendedIssues(openOctaneIssues.get(1), "RemoteId2", idToDetails.get(2));
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) IssueDetails(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.IssueDetails) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Example 8 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class PackIssuesToSendToOctaneTest method packSomeToCloseAndSomeToNewAndUpdate.

@Test
public void packSomeToCloseAndSomeToNewAndUpdate() throws IOException {
    List<String> existingInOctane = Arrays.asList("XYZ", "LMNO", "RemoteId2");
    Issues issues = sscIssuesToPack();
    PackIssuesToOctaneUtils.SortedIssues<Issues.Issue> issueSortedIssues = PackIssuesToOctaneUtils.packToOctaneIssues(issues.getData(), existingInOctane, true);
    List<OctaneIssue> octaneIssues = createOctaneIssues(issueSortedIssues.issuesToUpdate, "Tag", new HashMap<>());
    Assert.assertEquals(2, octaneIssues.size());
    Assert.assertEquals(2, issueSortedIssues.issuesToClose.size());
    validateIssueMap(octaneIssues.get(0), "list_node.issue_state_node.new", "\\ABC\\DEF\\GHIJ.java", "1", "Kingdom1", "Issue1");
    validateIssueMap(octaneIssues.get(1), "list_node.issue_state_node.existing", "\\ABC\\DEF\\GHIJ\\KLM.java", "2", "Kingdom2", "Issue2");
    validateIssueMap(issueSortedIssues.issuesToClose.get(0), "list_node.issue_state_node.closed", null, "-1", null, null);
    Assert.assertEquals(issueSortedIssues.issuesToClose.get(0).getRemoteId(), "XYZ");
    validateIssueMap(issueSortedIssues.issuesToClose.get(1), "list_node.issue_state_node.closed", null, "-1", null, null);
    Assert.assertEquals(issueSortedIssues.issuesToClose.get(1).getRemoteId(), "LMNO");
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Example 9 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class VulnerabilitiesTests method simpleFields.

@Test
public void simpleFields() {
    Issues.Issue issue = new Issues.Issue();
    issue.fullFileName = "fullFileName";
    issue.lineNumber = 100;
    issue.issueInstanceId = "ID_ID_ID";
    issue.foundDate = "2018-09-12T14:01:20.590+0000";
    issue.hRef = "hRef";
    Issues sscIssues = new Issues();
    sscIssues.setData(Arrays.asList(issue));
    SSCHandler sscHandler = new SSCHandler();
    List<OctaneIssue> octaneIssues = createOctaneIssues(sscIssues.getData(), "Tag", new HashMap<>());
    Assert.assertEquals(octaneIssues.get(0).getPrimaryLocationFull(), "fullFileName");
    Assert.assertEquals(String.valueOf(octaneIssues.get(0).getLine()), String.valueOf(100));
    Assert.assertEquals(octaneIssues.get(0).getRemoteId(), "ID_ID_ID");
    Assert.assertNotNull(octaneIssues.get(0).getIntroducedDate());
    Assert.assertEquals(octaneIssues.get(0).getExternalLink(), "hRef");
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Example 10 with OctaneIssue

use of com.hp.octane.integrations.dto.securityscans.OctaneIssue in project octane-ci-java-sdk by MicroFocus.

the class VulnerabilitiesTests method extendedData.

@Test
public void extendedData() {
    Issues.Issue issue = new Issues.Issue();
    issue.issueName = "name";
    issue.likelihood = "likelihood";
    issue.impact = "impact";
    issue.kingdom = "kingdom";
    issue.confidance = "confidence";
    issue.removedDate = "removedDate";
    Issues sscIssues = new Issues();
    sscIssues.setData(Arrays.asList(issue));
    SSCHandler sscHandler = new SSCHandler();
    List<OctaneIssue> octaneIssues = createOctaneIssues(sscIssues.getData(), "Tag", new HashMap<>());
    Assert.assertEquals(octaneIssues.get(0).getExtendedData().get("issueName"), "name");
    Assert.assertEquals(octaneIssues.get(0).getExtendedData().get("likelihood"), "likelihood");
    Assert.assertEquals(octaneIssues.get(0).getExtendedData().get("kingdom"), "kingdom");
    Assert.assertEquals(octaneIssues.get(0).getExtendedData().get("impact"), "impact");
    Assert.assertEquals(octaneIssues.get(0).getExtendedData().get("confidence"), "confidence");
    Assert.assertEquals(octaneIssues.get(0).getExtendedData().get("removedDate"), "removedDate");
}
Also used : OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) SSCHandler(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler) SSCToOctaneIssueUtil.createOctaneIssues(com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues) Issues(com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues) OctaneIssue(com.hp.octane.integrations.dto.securityscans.OctaneIssue) Test(org.junit.Test)

Aggregations

OctaneIssue (com.hp.octane.integrations.dto.securityscans.OctaneIssue)15 Issues (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.Issues)7 SSCToOctaneIssueUtil.createOctaneIssues (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCToOctaneIssueUtil.createOctaneIssues)6 Test (org.junit.Test)6 SSCHandler (com.hp.octane.integrations.services.vulnerabilities.ssc.SSCHandler)4 DTOFactory (com.hp.octane.integrations.dto.DTOFactory)2 IOException (java.io.IOException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SSCProjectConfiguration (com.hp.octane.integrations.dto.securityscans.SSCProjectConfiguration)1 OctaneIssueImpl (com.hp.octane.integrations.dto.securityscans.impl.OctaneIssueImpl)1 ExistingIssuesInOctane (com.hp.octane.integrations.services.vulnerabilities.ExistingIssuesInOctane)1 PackIssuesToOctaneUtils (com.hp.octane.integrations.services.vulnerabilities.PackIssuesToOctaneUtils)1 Vulnerability (com.hp.octane.integrations.services.vulnerabilities.fod.dto.pojos.Vulnerability)1 VulnerabilityAllData (com.hp.octane.integrations.services.vulnerabilities.fod.dto.pojos.VulnerabilityAllData)1 SonarIssue (com.hp.octane.integrations.services.vulnerabilities.sonar.dto.SonarIssue)1 IssueDetails (com.hp.octane.integrations.services.vulnerabilities.ssc.dto.IssueDetails)1 InputStream (java.io.InputStream)1 StringWriter (java.io.StringWriter)1