diff --git a/pom.xml b/pom.xml index d4c71f9a..c57d6097 100644 --- a/pom.xml +++ b/pom.xml @@ -33,13 +33,7 @@ com.fasterxml.jackson.core jackson-databind - 2.11.4 - - - info.cukes - cucumber-junit - 1.2.6 - test + 2.13.1 org.projectlombok @@ -74,7 +68,7 @@ org.codehaus.mojo exec-maven-plugin - 1.2.1 + 3.0.0 diff --git a/src/main/java/com/checkmarx/ast/predicate/Predicate.java b/src/main/java/com/checkmarx/ast/predicate/Predicate.java index 8d9c8ab0..4a5a6373 100644 --- a/src/main/java/com/checkmarx/ast/predicate/Predicate.java +++ b/src/main/java/com/checkmarx/ast/predicate/Predicate.java @@ -4,8 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -22,31 +20,31 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class Predicate { - String ID; - String SimilarityID; - String ProjectID; - String State; - String Severity; - String Comment; - String CreatedBy; - String CreatedAt; - String UpdatedAt; + String id; + String similarityId; + String projectId; + String state; + String severity; + String comment; + String createdBy; + String createdAt; + String updatedAt; @JsonCreator - public Predicate(@JsonProperty("ID") String id, @JsonProperty("SimilarityID") String similarityID, - @JsonProperty("ProjectID") String projectID, @JsonProperty("State") String state, + public Predicate(@JsonProperty("ID") String id, @JsonProperty("SimilarityID") String similarityId, + @JsonProperty("ProjectID") String projectId, @JsonProperty("State") String state, @JsonProperty("Severity") String severity, @JsonProperty("Comment") String comment, - @JsonProperty("CreatedBy") String createdBy, @JsonProperty("CreatedAt") String CreatedAt, - @JsonProperty("UpdatedAt") String UpdatedAt) { - this.ID = id; - this.SimilarityID = similarityID; - this.ProjectID = projectID; - this.State = state; - this.Severity = severity; - this.Comment = comment; - this.CreatedBy = createdBy; - this.CreatedAt = CreatedAt; - this.UpdatedAt = UpdatedAt; + @JsonProperty("CreatedBy") String createdBy, @JsonProperty("CreatedAt") String createdAt, + @JsonProperty("UpdatedAt") String updatedAt) { + this.id = id; + this.similarityId = similarityId; + this.projectId = projectId; + this.state = state; + this.severity = severity; + this.comment = comment; + this.createdBy = createdBy; + this.createdAt = createdAt; + this.updatedAt = updatedAt; } public static T fromLine(String line) { @@ -59,27 +57,25 @@ public static List listFromLine(String line) { protected static T parse(String line, JavaType type) { T result = null; - if (!StringUtils.isBlank(line) && isValidJSON(line)) { - try { + try { + if (!StringUtils.isBlank(line) && isValidJSON(line)) { result = new ObjectMapper().readValue(line, type); - } catch (JsonProcessingException ignored) { } + } catch (IOException e) { + e.printStackTrace(); } return result; } private static boolean isValidJSON(final String json) { - boolean valid = false; try { - final JsonParser parser = new ObjectMapper().createParser(json); - //noinspection StatementWithEmptyBody - while (parser.nextToken() != null) { - } - valid = true; - } catch (IOException ignored) { + final ObjectMapper mapper = new ObjectMapper(); + mapper.readTree(json); + return true; + } catch (IOException e) { + return false; } - return valid; } } diff --git a/src/main/java/com/checkmarx/ast/project/Project.java b/src/main/java/com/checkmarx/ast/project/Project.java index e78fde84..9ff24963 100644 --- a/src/main/java/com/checkmarx/ast/project/Project.java +++ b/src/main/java/com/checkmarx/ast/project/Project.java @@ -20,19 +20,19 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class Project extends CxBaseObject { - String Name; - List Groups; + String name; + List groups; @JsonCreator - public Project(@JsonProperty("ID") String ID, - @JsonProperty("Name") String Name, - @JsonProperty("CreatedAt") String CreatedAt, - @JsonProperty("UpdatedAt") String UpdatedAt, - @JsonProperty("Tags") Map Tags, - @JsonProperty("Groups") List Groups) { - super(ID, CreatedAt, UpdatedAt, Tags); - this.Name = Name; - this.Groups = Groups; + public Project(@JsonProperty("ID") String id, + @JsonProperty("Name") String name, + @JsonProperty("CreatedAt") String createdAt, + @JsonProperty("UpdatedAt") String updatedAt, + @JsonProperty("Tags") Map tags, + @JsonProperty("Groups") List groups) { + super(id, createdAt, updatedAt, tags); + this.name = name; + this.groups = groups; } public static T fromLine(String line) { diff --git a/src/main/java/com/checkmarx/ast/results/result/Comments.java b/src/main/java/com/checkmarx/ast/results/result/Comments.java index 0d5f2eef..388931a0 100644 --- a/src/main/java/com/checkmarx/ast/results/result/Comments.java +++ b/src/main/java/com/checkmarx/ast/results/result/Comments.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import lombok.*; +import lombok.Value; @Value @JsonDeserialize() diff --git a/src/main/java/com/checkmarx/ast/results/result/Data.java b/src/main/java/com/checkmarx/ast/results/result/Data.java index 35e65f36..3641825d 100644 --- a/src/main/java/com/checkmarx/ast/results/result/Data.java +++ b/src/main/java/com/checkmarx/ast/results/result/Data.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import lombok.*; +import lombok.Value; import java.util.List; diff --git a/src/main/java/com/checkmarx/ast/results/result/Node.java b/src/main/java/com/checkmarx/ast/results/result/Node.java index 853d36e0..75d3ca7d 100644 --- a/src/main/java/com/checkmarx/ast/results/result/Node.java +++ b/src/main/java/com/checkmarx/ast/results/result/Node.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import lombok.*; +import lombok.Value; @Value @JsonDeserialize() diff --git a/src/main/java/com/checkmarx/ast/results/result/PackageData.java b/src/main/java/com/checkmarx/ast/results/result/PackageData.java index 741bc684..9f7abfe2 100644 --- a/src/main/java/com/checkmarx/ast/results/result/PackageData.java +++ b/src/main/java/com/checkmarx/ast/results/result/PackageData.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import lombok.*; +import lombok.Value; @Value @JsonDeserialize() diff --git a/src/main/java/com/checkmarx/ast/scan/Scan.java b/src/main/java/com/checkmarx/ast/scan/Scan.java index 4d6af806..2f22f710 100644 --- a/src/main/java/com/checkmarx/ast/scan/Scan.java +++ b/src/main/java/com/checkmarx/ast/scan/Scan.java @@ -22,24 +22,24 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class Scan extends CxBaseObject { - String ProjectID; - String Status; - String Initiator; - String Origin; - String Branch; + String projectId; + String status; + String initiator; + String origin; + String branch; @JsonCreator - public Scan(@JsonProperty("ID") String ID, @JsonProperty("ProjectID") String ProjectID, - @JsonProperty("Status") String Status, @JsonProperty("CreatedAt") String CreatedAt, - @JsonProperty("UpdatedAt") String UpdatedAt, @JsonProperty("Tags") Map Tags, - @JsonProperty("Initiator") String Initiator, @JsonProperty("Origin") String Origin, - @JsonProperty("Branch") String Branch) { - super(ID, CreatedAt, UpdatedAt, Tags); - this.ProjectID = ProjectID; - this.Status = Status; - this.Initiator = Initiator; - this.Origin = Origin; - this.Branch = Branch; + public Scan(@JsonProperty("ID") String id, @JsonProperty("ProjectID") String projectId, + @JsonProperty("Status") String status, @JsonProperty("CreatedAt") String createdAt, + @JsonProperty("UpdatedAt") String updatedAt, @JsonProperty("Tags") Map tags, + @JsonProperty("Initiator") String initiator, @JsonProperty("Origin") String origin, + @JsonProperty("Branch") String branch) { + super(id, createdAt, updatedAt, tags); + this.projectId = projectId; + this.status = status; + this.initiator = initiator; + this.origin = origin; + this.branch = branch; } public static T fromLine(String line) { diff --git a/src/main/java/com/checkmarx/ast/wrapper/CxBaseObject.java b/src/main/java/com/checkmarx/ast/wrapper/CxBaseObject.java index 998a81b3..9fc009d7 100644 --- a/src/main/java/com/checkmarx/ast/wrapper/CxBaseObject.java +++ b/src/main/java/com/checkmarx/ast/wrapper/CxBaseObject.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; @@ -20,20 +19,20 @@ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public abstract class CxBaseObject { - String ID; - String CreatedAt; - String UpdatedAt; - Map Tags; + String id; + String createdAt; + String updatedAt; + Map tags; @JsonCreator - public CxBaseObject(@JsonProperty("ID") String ID, - @JsonProperty("CreatedAt") String createdAt, - @JsonProperty("UpdatedAt") String updatedAt, - @JsonProperty("Tags") Map tags) { - this.ID = ID; - this.CreatedAt = createdAt; - this.UpdatedAt = updatedAt; - this.Tags = tags; + protected CxBaseObject(@JsonProperty("ID") String id, + @JsonProperty("CreatedAt") String createdAt, + @JsonProperty("UpdatedAt") String updatedAt, + @JsonProperty("Tags") Map tags) { + this.id = id; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.tags = tags; } protected static T parse(String line, JavaType type) { @@ -41,23 +40,20 @@ protected static T parse(String line, JavaType type) { if (!StringUtils.isBlank(line) && isValidJSON(line)) { try { result = new ObjectMapper().readValue(line, type); - } catch (JsonProcessingException ignored) { - + } catch (JsonProcessingException e) { + e.printStackTrace(); } } return result; } private static boolean isValidJSON(final String json) { - boolean valid = false; try { - final JsonParser parser = new ObjectMapper().createParser(json); - //noinspection StatementWithEmptyBody - while (parser.nextToken() != null) { - } - valid = true; - } catch (IOException ignored) { + final ObjectMapper mapper = new ObjectMapper(); + mapper.readTree(json); + return true; + } catch (IOException e) { + return false; } - return valid; } } diff --git a/src/main/java/com/checkmarx/ast/wrapper/CxConfig.java b/src/main/java/com/checkmarx/ast/wrapper/CxConfig.java index ab099c5f..e2207aa0 100644 --- a/src/main/java/com/checkmarx/ast/wrapper/CxConfig.java +++ b/src/main/java/com/checkmarx/ast/wrapper/CxConfig.java @@ -81,7 +81,6 @@ public InvalidCLIConfigException(String message) { @SuppressWarnings("ALL") public static class CxConfigBuilder { - private List additionalParameters; public CxConfigBuilder additionalParameters(String additionalParameters) { this.additionalParameters = parseAdditionalParameters(additionalParameters); diff --git a/src/main/java/com/checkmarx/ast/wrapper/CxThinWrapper.java b/src/main/java/com/checkmarx/ast/wrapper/CxThinWrapper.java index 5a870f73..931aed1b 100644 --- a/src/main/java/com/checkmarx/ast/wrapper/CxThinWrapper.java +++ b/src/main/java/com/checkmarx/ast/wrapper/CxThinWrapper.java @@ -23,7 +23,7 @@ public CxThinWrapper() throws IOException { public CxThinWrapper(@NonNull Logger logger) throws IOException { this.logger = logger; this.executable = Execution.getTempBinary(); - this.logger.info("Executable path: " + executable); + this.logger.info("Executable path: {} ", executable); } public String run(@NonNull String arguments) throws CxException, IOException, InterruptedException { @@ -31,6 +31,6 @@ public String run(@NonNull String arguments) throws CxException, IOException, In List argv = new ArrayList<>(); argv.add(executable); argv.addAll(Arrays.asList(arguments.split(" "))); - return Execution.executeCommand(argv, logger, (line) -> line); + return Execution.executeCommand(argv, logger, line -> line); } } diff --git a/src/main/java/com/checkmarx/ast/wrapper/CxWrapper.java b/src/main/java/com/checkmarx/ast/wrapper/CxWrapper.java index 6573a6c9..10a123e2 100644 --- a/src/main/java/com/checkmarx/ast/wrapper/CxWrapper.java +++ b/src/main/java/com/checkmarx/ast/wrapper/CxWrapper.java @@ -24,7 +24,7 @@ public class CxWrapper { private static final CollectionType BRANCHES_TYPE = TypeFactory.defaultInstance() - .constructCollectionType(List.class, String.class); + .constructCollectionType(List.class, String.class); @NonNull private final CxConfig cxConfig; @@ -44,9 +44,9 @@ public CxWrapper(@NonNull CxConfig cxConfig, @NonNull Logger logger) throws CxCo this.cxConfig = cxConfig; this.logger = logger; this.executable = StringUtils.isBlank(this.cxConfig.getPathToExecutable()) - ? Execution.getTempBinary() - : this.cxConfig.getPathToExecutable(); - this.logger.info("Executable path: " + executable); + ? Execution.getTempBinary() + : this.cxConfig.getPathToExecutable(); + this.logger.info("Executable path: {} ", executable); } public String authValidate() throws IOException, InterruptedException, CxException { @@ -56,7 +56,7 @@ public String authValidate() throws IOException, InterruptedException, CxExcepti arguments.add(CxConstants.CMD_AUTH); arguments.add(CxConstants.SUB_CMD_VALIDATE); - return Execution.executeCommand(withConfigArguments(arguments), logger, (line) -> line); + return Execution.executeCommand(withConfigArguments(arguments), logger, line -> line); } public Scan scanShow(@NonNull UUID scanId) throws IOException, InterruptedException, CxException { @@ -114,7 +114,7 @@ public Scan scanCreate(@NonNull Map params, String additionalPar public List triageShow(@NonNull UUID projectId, String similarityId, String scanType) throws IOException, InterruptedException, CxException { this.logger.info("Executing 'triage show' command using the CLI."); - this.logger.info("Fetching the list of predicates for projectId {} , similarityId {} and scan-type {}.,", projectId, similarityId, scanType); + this.logger.info("Fetching the list of predicates for projectId {} , similarityId {} and scan-type {}.", projectId, similarityId, scanType); List arguments = new ArrayList<>(); arguments.add(CxConstants.CMD_TRIAGE); @@ -146,14 +146,14 @@ public void triageUpdate(@NonNull UUID projectId, String similarityId, String sc arguments.add(scanType); arguments.add(CxConstants.STATE); arguments.add(state); - if(!StringUtils.isBlank(comment)) { + if (!StringUtils.isBlank(comment)) { arguments.add(CxConstants.COMMENT); arguments.add(comment); } arguments.add(CxConstants.SEVERITY); arguments.add(severity); - Execution.executeCommand(withConfigArguments(arguments), logger, (line) -> null); + Execution.executeCommand(withConfigArguments(arguments), logger, line -> null); } public Project projectShow(@NonNull UUID projectId) throws IOException, InterruptedException, CxException { @@ -197,8 +197,8 @@ public List projectBranches(@NonNull UUID projectId, String filter) arguments.addAll(filterArguments(filter)); return Execution.executeCommand(withConfigArguments(arguments), - logger, - (line) -> CxBaseObject.parse(line, BRANCHES_TYPE)); + logger, + line -> CxBaseObject.parse(line, BRANCHES_TYPE)); } public ResultsSummary resultsSummary(@NonNull UUID scanId) throws IOException, InterruptedException, CxException { @@ -232,8 +232,8 @@ public String results(@NonNull UUID scanId, ReportFormat reportFormat) arguments.add(tempDir); return Execution.executeCommand(withConfigArguments(arguments), - logger, tempDir, - fileName + reportFormat.getExtension()); + logger, tempDir, + fileName + reportFormat.getExtension()); } private List withConfigArguments(List commands) { diff --git a/src/test/java/com/checkmarx/ast/AuthTest.java b/src/test/java/com/checkmarx/ast/AuthTest.java index 68f3e685..f996f5f5 100644 --- a/src/test/java/com/checkmarx/ast/AuthTest.java +++ b/src/test/java/com/checkmarx/ast/AuthTest.java @@ -3,21 +3,20 @@ import com.checkmarx.ast.wrapper.CxConfig; import com.checkmarx.ast.wrapper.CxException; import com.checkmarx.ast.wrapper.CxWrapper; -import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.IOException; -public class AuthTest extends BaseTest { +class AuthTest extends BaseTest { @Test - public void testAuthValidate() throws CxException, IOException, InterruptedException { + void testAuthValidate() throws CxException, IOException, InterruptedException { Assertions.assertNotNull(wrapper.authValidate()); } @Test - public void testAuthFailure() { + void testAuthFailure() { CxConfig cxConfig = getConfig(); cxConfig.setBaseAuthUri("wrongAuth"); Assertions.assertThrows(CxException.class, () -> new CxWrapper(cxConfig, getLogger()).authValidate()); diff --git a/src/test/java/com/checkmarx/ast/BaseTest.java b/src/test/java/com/checkmarx/ast/BaseTest.java index 9ac4dc3a..1504587c 100644 --- a/src/test/java/com/checkmarx/ast/BaseTest.java +++ b/src/test/java/com/checkmarx/ast/BaseTest.java @@ -53,12 +53,12 @@ private static String getEnvOrNull(String key) { protected Map commonParams() { Map params = new HashMap<>(); - params.put(CxConstants.PROJECT_NAME, "AST-CLI-Java-Wrapper-Tests"); + params.put(CxConstants.PROJECT_NAME, "CLI-Java-Wrapper-Tests"); params.put(CxConstants.SOURCE, "."); params.put(CxConstants.FILE_FILTER, "!test"); params.put(CxConstants.BRANCH, "main"); params.put(CxConstants.SAST_PRESET_NAME, "Checkmarx Default"); - params.put(CxConstants.AGENT, "AST-CLI-Java-Wrapper"); + params.put(CxConstants.AGENT, "CLI-Java-Wrapper"); return params; } } diff --git a/src/test/java/com/checkmarx/ast/PredicateTest.java b/src/test/java/com/checkmarx/ast/PredicateTest.java index ec81a841..016a88da 100644 --- a/src/test/java/com/checkmarx/ast/PredicateTest.java +++ b/src/test/java/com/checkmarx/ast/PredicateTest.java @@ -11,37 +11,35 @@ import java.util.List; import java.util.UUID; -import static org.junit.Assert.fail; - -public class PredicateTest extends BaseTest { +class PredicateTest extends BaseTest { @Test - public void testTriageShow() throws Exception { + void testTriageShow() throws Exception { List scanList = wrapper.scanList(String.format("statuses=Completed")); Scan scan = scanList.get(0); Assertions.assertTrue(scanList.size() > 0); - String scanId = scanList.get(0).getID(); + String scanId = scanList.get(0).getId(); Results results = wrapper.results(UUID.fromString(scanId)); Result result = results.getResults().stream().filter(res -> res.getType().equalsIgnoreCase(CxConstants.SAST)).findFirst().get(); - List predicates = wrapper.triageShow(UUID.fromString(scan.getProjectID()), result.getSimilarityId(), result.getType()); + List predicates = wrapper.triageShow(UUID.fromString(scan.getProjectId()), result.getSimilarityId(), result.getType()); Assertions.assertNotNull(predicates); } @Test - public void testTriageUpdate() throws Exception { + void testTriageUpdate() throws Exception { List scanList = wrapper.scanList(String.format("statuses=Completed")); Scan scan = scanList.get(0); Assertions.assertTrue(scanList.size() > 0); - String scanId = scanList.get(0).getID(); + String scanId = scanList.get(0).getId(); Results results = wrapper.results(UUID.fromString(scanId)); Result result = results.getResults().stream().filter(res -> res.getType().equalsIgnoreCase(CxConstants.SAST)).findFirst().get(); try { - wrapper.triageUpdate(UUID.fromString(scan.getProjectID()), result.getSimilarityId(), result.getType(), "to_verify", "Edited via Java Wrapper", "high"); + wrapper.triageUpdate(UUID.fromString(scan.getProjectId()), result.getSimilarityId(), result.getType(), "to_verify", "Edited via Java Wrapper", "high"); } catch (Exception e) { Assertions.fail("Triage update failed. Should not throw exception"); } diff --git a/src/test/java/com/checkmarx/ast/ProjectTest.java b/src/test/java/com/checkmarx/ast/ProjectTest.java index a2ef6764..9a7fc5d6 100644 --- a/src/test/java/com/checkmarx/ast/ProjectTest.java +++ b/src/test/java/com/checkmarx/ast/ProjectTest.java @@ -10,28 +10,28 @@ import java.util.Map; import java.util.UUID; -public class ProjectTest extends BaseTest { +class ProjectTest extends BaseTest { @Test - public void testProjectShow() throws Exception { + void testProjectShow() throws Exception { List projectList = wrapper.projectList(); Assertions.assertTrue(projectList.size() > 0); - Project project = wrapper.projectShow(UUID.fromString(projectList.get(0).getID())); - Assertions.assertEquals(projectList.get(0).getID(), project.getID()); + Project project = wrapper.projectShow(UUID.fromString(projectList.get(0).getId())); + Assertions.assertEquals(projectList.get(0).getId(), project.getId()); } @Test - public void testProjectList() throws Exception { + void testProjectList() throws Exception { List projectList = wrapper.projectList("limit=10"); Assertions.assertTrue(projectList.size() <= 10); } @Test - public void testProjectBranches() throws Exception { + void testProjectBranches() throws Exception { Map params = commonParams(); params.put(CxConstants.BRANCH, "test"); Scan scan = wrapper.scanCreate(params); - List branches = wrapper.projectBranches(UUID.fromString(scan.getProjectID()), ""); + List branches = wrapper.projectBranches(UUID.fromString(scan.getProjectId()), ""); Assertions.assertTrue(branches.size() >= 1); Assertions.assertTrue(branches.contains("test")); } diff --git a/src/test/java/com/checkmarx/ast/ResultTest.java b/src/test/java/com/checkmarx/ast/ResultTest.java index a904d674..34583cf3 100644 --- a/src/test/java/com/checkmarx/ast/ResultTest.java +++ b/src/test/java/com/checkmarx/ast/ResultTest.java @@ -10,40 +10,40 @@ import java.util.List; import java.util.UUID; -public class ResultTest extends BaseTest { +class ResultTest extends BaseTest { @Test - public void testResultsHTML() throws Exception { + void testResultsHTML() throws Exception { List scanList = wrapper.scanList(); Assertions.assertTrue(scanList.size() > 0); - String scanId = scanList.get(0).getID(); + String scanId = scanList.get(0).getId(); String results = wrapper.results(UUID.fromString(scanId), ReportFormat.summaryHTML); Assertions.assertTrue(results.length() > 0); } @Test - public void testResultsJSON() throws Exception { + void testResultsJSON() throws Exception { List scanList = wrapper.scanList(); Assertions.assertTrue(scanList.size() > 0); - String scanId = scanList.get(0).getID(); + String scanId = scanList.get(0).getId(); String results = wrapper.results(UUID.fromString(scanId), ReportFormat.json); Assertions.assertTrue(results.length() > 0); } @Test - public void testResultsSummaryJSON() throws Exception { + void testResultsSummaryJSON() throws Exception { List scanList = wrapper.scanList(); Assertions.assertTrue(scanList.size() > 0); - String scanId = scanList.get(0).getID(); + String scanId = scanList.get(0).getId(); ResultsSummary results = wrapper.resultsSummary(UUID.fromString(scanId)); Assertions.assertNotNull(results.getScanId()); } @Test() - public void testResultsStructure() throws Exception { + void testResultsStructure() throws Exception { List scanList = wrapper.scanList(); Assertions.assertTrue(scanList.size() > 0); - String scanId = scanList.get(0).getID(); + String scanId = scanList.get(0).getId(); Results results = wrapper.results(UUID.fromString(scanId)); results.getResults().stream().filter(result -> "sast".equalsIgnoreCase(result.getType())).findFirst(); Assertions.assertEquals(results.getTotalCount(), results.getResults().size()); diff --git a/src/test/java/com/checkmarx/ast/ScanTest.java b/src/test/java/com/checkmarx/ast/ScanTest.java index e18ceb8a..985611e2 100644 --- a/src/test/java/com/checkmarx/ast/ScanTest.java +++ b/src/test/java/com/checkmarx/ast/ScanTest.java @@ -8,27 +8,27 @@ import java.util.Map; import java.util.UUID; -public class ScanTest extends BaseTest { +class ScanTest extends BaseTest { @Test - public void testScanShow() throws Exception { + void testScanShow() throws Exception { List scanList = wrapper.scanList(); Assertions.assertTrue(scanList.size() > 0); - Scan scan = wrapper.scanShow(UUID.fromString(scanList.get(0).getID())); - Assertions.assertEquals(scanList.get(0).getID(), scan.getID()); + Scan scan = wrapper.scanShow(UUID.fromString(scanList.get(0).getId())); + Assertions.assertEquals(scanList.get(0).getId(), scan.getId()); } @Test - public void testScanList() throws Exception { + void testScanList() throws Exception { List cxOutput = wrapper.scanList("limit=10"); Assertions.assertTrue(cxOutput.size() <= 10); } @Test - public void testScanCreate() throws Exception { + void testScanCreate() throws Exception { Map params = commonParams(); Scan scan = wrapper.scanCreate(params); - Assertions.assertEquals("Completed", wrapper.scanShow(UUID.fromString(scan.getID())).getStatus()); + Assertions.assertEquals("Completed", wrapper.scanShow(UUID.fromString(scan.getId())).getStatus()); } } diff --git a/src/test/java/com/checkmarx/ast/ThinWrapperTest.java b/src/test/java/com/checkmarx/ast/ThinWrapperTest.java index e9e25609..afcacd3f 100644 --- a/src/test/java/com/checkmarx/ast/ThinWrapperTest.java +++ b/src/test/java/com/checkmarx/ast/ThinWrapperTest.java @@ -4,7 +4,6 @@ import com.checkmarx.ast.wrapper.CxException; import com.checkmarx.ast.wrapper.CxThinWrapper; import lombok.SneakyThrows; -import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test;