Skip to content

Commit

Permalink
Make "getAllFindings" test consistent by ordering result
Browse files Browse the repository at this point in the history
Signed-off-by: RBickert <[email protected]>
  • Loading branch information
rbt-mm committed Aug 29, 2023
1 parent bfb6c14 commit 7c8792a
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ public void getFindingsByProjectWithComponentLatestVersionWithoutRepositoryMetaC

@Test
public void getAllFindings() {
Project p1 = qm.createProject("Acme Example", null, "1.0", null, null, null, true, false);
Project p1_child = qm.createProject("Acme Example", null, "1.0", null, p1, null, true, false);
Project p2 = qm.createProject("Acme Example", null, "1.0", null, null, null, true, false);
Project p1 = qm.createProject("Acme Example 1", null, "1.0", null, null, null, true, false);
Project p1_child = qm.createProject("Acme Example 2", null, "1.0", null, p1, null, true, false);
Project p2 = qm.createProject("Acme Example 3", null, "1.0", null, null, null, true, false);
Component c1 = createComponent(p1, "Component A", "1.0");
Component c2 = createComponent(p1, "Component B", "1.0");
Component c3 = createComponent(p1_child, "Component C", "1.0");
Expand All @@ -357,7 +357,10 @@ public void getAllFindings() {
qm.addVulnerability(v2, c3, AnalyzerIdentity.NONE);
qm.addVulnerability(v3, c2, AnalyzerIdentity.NONE);
qm.addVulnerability(v4, c5, AnalyzerIdentity.NONE);
Response response = target(V1_FINDING).request()
Response response = target(V1_FINDING)
.queryParam("sortName", "component.projectName")
.queryParam("sortOrder", "asc")
.request()
.header(X_API_KEY, apiKey)
.get(Response.class);
Assert.assertEquals(200, response.getStatus(), 0);
Expand All @@ -374,13 +377,13 @@ public void getAllFindings() {
Assert.assertEquals(p1.getVersion() ,json.getJsonObject(1).getJsonObject("component").getString("projectVersion"));
Assert.assertEquals(p1.getUuid().toString(), json.getJsonObject(1).getJsonObject("component").getString("project"));
Assert.assertEquals(date.getTime() ,json.getJsonObject(2).getJsonObject("vulnerability").getJsonNumber("published").longValue());
Assert.assertEquals(p1_child.getName() ,json.getJsonObject(2).getJsonObject("component").getString("projectName"));
Assert.assertEquals(p1_child.getVersion() ,json.getJsonObject(2).getJsonObject("component").getString("projectVersion"));
Assert.assertEquals(p1_child.getUuid().toString(), json.getJsonObject(2).getJsonObject("component").getString("project"));
Assert.assertEquals(p1.getName() ,json.getJsonObject(2).getJsonObject("component").getString("projectName"));
Assert.assertEquals(p1.getVersion() ,json.getJsonObject(2).getJsonObject("component").getString("projectVersion"));
Assert.assertEquals(p1.getUuid().toString(), json.getJsonObject(2).getJsonObject("component").getString("project"));
Assert.assertEquals(date.getTime() ,json.getJsonObject(3).getJsonObject("vulnerability").getJsonNumber("published").longValue());
Assert.assertEquals(p1.getName() ,json.getJsonObject(3).getJsonObject("component").getString("projectName"));
Assert.assertEquals(p1.getVersion() ,json.getJsonObject(3).getJsonObject("component").getString("projectVersion"));
Assert.assertEquals(p1.getUuid().toString(), json.getJsonObject(3).getJsonObject("component").getString("project"));
Assert.assertEquals(p1_child.getName() ,json.getJsonObject(3).getJsonObject("component").getString("projectName"));
Assert.assertEquals(p1_child.getVersion() ,json.getJsonObject(3).getJsonObject("component").getString("projectVersion"));
Assert.assertEquals(p1_child.getUuid().toString(), json.getJsonObject(3).getJsonObject("component").getString("project"));
Assert.assertEquals(date.getTime() ,json.getJsonObject(4).getJsonObject("vulnerability").getJsonNumber("published").longValue());
Assert.assertEquals(p2.getName() ,json.getJsonObject(4).getJsonObject("component").getString("projectName"));
Assert.assertEquals(p2.getVersion() ,json.getJsonObject(4).getJsonObject("component").getString("projectVersion"));
Expand Down

0 comments on commit 7c8792a

Please sign in to comment.