@@ -209,6 +209,40 @@ public void testSorted() throws IOException {
209209 assertEquals ("aa" , reportLowest .getRef ().name ());
210210 assertEquals ("aaa" , reportLowest .getTransitive ().get (0 ).getRef ().name ());
211211 assertEquals ("aab" , reportLowest .getTransitive ().get (1 ).getRef ().name ());
212+
213+ assertEquals ("ISSUE-006" , reportHighest .getHighestVulnerability ().getId ());
214+ assertEquals ("ISSUE-001" , reportLowest .getHighestVulnerability ().getId ());
215+ }
216+
217+ @ Test
218+ public void testHighestVulnerabilityInDirectDependency () throws IOException {
219+ Map <String , List <Issue >> issues = Map .of (
220+ "pkg:npm/aa@1" , List .of (buildIssue (1 , 4f ),buildIssue (2 , 9f ),buildIssue (3 , 1f )));
221+ ProviderResponseHandler handler = new TestResponseHandler ();
222+
223+ ProviderReport response = handler .buildReport (
224+ new ProviderResponse (issues , null ), buildTree (), null , EMPTY_TRUSTED_CONTENT_RESPONSE );
225+
226+ assertOkStatus (response );
227+ DependencyReport highest = getValidSource (response ).getDependencies ().get (0 );
228+ assertEquals ("ISSUE-002" , highest .getHighestVulnerability ().getId ());
229+ assertEquals (9f , highest .getHighestVulnerability ().getCvssScore ());
230+ }
231+
232+ @ Test
233+ public void testHighestVulnerabilityInTransitiveDependency () throws IOException {
234+ Map <String , List <Issue >> issues = Map .of (
235+ "pkg:npm/aa@1" , Collections .emptyList (),
236+ "pkg:npm/aaa@1" , List .of (buildIssue (1 , 4f ),buildIssue (2 , 9f ),buildIssue (3 , 1f )));
237+ ProviderResponseHandler handler = new TestResponseHandler ();
238+
239+ ProviderReport response = handler .buildReport (
240+ new ProviderResponse (issues , null ), buildTree (), null , EMPTY_TRUSTED_CONTENT_RESPONSE );
241+
242+ assertOkStatus (response );
243+ DependencyReport highest = getValidSource (response ).getDependencies ().get (0 );
244+ assertEquals ("ISSUE-002" , highest .getHighestVulnerability ().getId ());
245+ assertEquals (9f , highest .getHighestVulnerability ().getCvssScore ());
212246 }
213247
214248 @ Test
0 commit comments