From 60e7d0f46ad917c43df1a60068bf4bd84e69de04 Mon Sep 17 00:00:00 2001 From: Immalla-Chen Date: Tue, 29 Oct 2024 18:54:04 -0700 Subject: [PATCH] fix test Signed-off-by: Immalla-Chen --- .../resources/v1/ComponentResourceTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/org/dependencytrack/resources/v1/ComponentResourceTest.java b/src/test/java/org/dependencytrack/resources/v1/ComponentResourceTest.java index a5d14a8783..53e6dc983c 100644 --- a/src/test/java/org/dependencytrack/resources/v1/ComponentResourceTest.java +++ b/src/test/java/org/dependencytrack/resources/v1/ComponentResourceTest.java @@ -26,6 +26,7 @@ import org.apache.http.HttpStatus; import org.dependencytrack.JerseyTestRule; import org.dependencytrack.ResourceTest; +import org.dependencytrack.model.Classifier; import org.dependencytrack.model.Component; import org.dependencytrack.model.ConfigPropertyConstants; import org.dependencytrack.model.ExternalReference; @@ -508,6 +509,7 @@ public void createComponentTest() { component.setName("My Component"); component.setVersion("1.0"); component.setAuthor("SampleAuthor"); + component.setClassifier(Classifier.APPLICATION); Response response = jersey.target(V1_COMPONENT + "/project/" + project.getUuid().toString()).request() .header(X_API_KEY, apiKey) .put(Entity.entity(component, MediaType.APPLICATION_JSON)); @@ -518,6 +520,7 @@ public void createComponentTest() { Assert.assertEquals("SampleAuthor" ,json.getJsonArray("authors").getJsonObject(0).getString("name")); Assert.assertEquals("SampleAuthor", json.getString("author")); Assert.assertEquals("1.0", json.getString("version")); + Assert.assertEquals("APPLICATION", json.getString("classifier")); Assert.assertTrue(UuidUtil.isValidUUID(json.getString("uuid"))); } @@ -528,6 +531,7 @@ public void createComponentUpperCaseHashTest() { component.setProject(project); component.setName("My Component"); component.setVersion("1.0"); + component.setClassifier(Classifier.APPLICATION); component.setSha1("640ab2bae07bedc4c163f679a746f7ab7fb5d1fa".toUpperCase()); component.setSha256("532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25".toUpperCase()); component.setSha3_256("c0a5cca43b8aa79eb50e3464bc839dd6fd414fae0ddf928ca23dcebf8a8b8dd0".toUpperCase()); @@ -544,6 +548,7 @@ public void createComponentUpperCaseHashTest() { Assert.assertNotNull(json); Assert.assertEquals("My Component", json.getString("name")); Assert.assertEquals("1.0", json.getString("version")); + Assert.assertEquals("APPLICATION", json.getString("classifier")); Assert.assertTrue(UuidUtil.isValidUUID(json.getString("uuid"))); Assert.assertEquals(component.getSha1(), json.getString("sha1")); Assert.assertEquals(component.getSha256(), json.getString("sha256")); @@ -574,6 +579,7 @@ public void updateComponentTest() { externalReference.setType(org.cyclonedx.model.ExternalReference.Type.WEBSITE); externalReference.setUrl("test.com"); jsonComponent.setExternalReferences(List.of(externalReference)); + jsonComponent.setClassifier(Classifier.APPLICATION); Response response = jersey.target(V1_COMPONENT).request() .header(X_API_KEY, apiKey) @@ -626,6 +632,7 @@ public void updateComponentInvalidLicenseExpressionTest() { "uuid": "%s", "name": "acme-lib", "version": "1.0.0", + "classifier":"APPLICATION", "licenseExpression": "(invalid" } """.formatted(component.getUuid()), MediaType.APPLICATION_JSON_TYPE));