-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge develop to main for release 104 (#123)
Fix StringIndexOutOfBoundsException for license #122
- Loading branch information
1 parent
e627d17
commit 73a3d20
Showing
2 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
get-metrics/src/test/java/org/sonatype/cs/getmetrics/util/ParseReasonsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.sonatype.cs.getmetrics.util; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonArray; | ||
|
||
public class ParseReasonsTest { | ||
@Test | ||
void testEmptyLicenseString() { | ||
JsonArray reasons = | ||
Json.createArrayBuilder().add(Json.createObjectBuilder().add("reason", "")).build(); | ||
|
||
String actualReason = ParseReasons.getLicense(reasons); | ||
Assertions.assertEquals("", actualReason); | ||
} | ||
|
||
@Test | ||
void testSingleLicenseString() { | ||
JsonArray reasons = | ||
Json.createArrayBuilder() | ||
.add(Json.createObjectBuilder().add("reason", "(license)")) | ||
.build(); | ||
|
||
String actualReason = ParseReasons.getLicense(reasons); | ||
Assertions.assertEquals("license", actualReason); | ||
} | ||
|
||
@Test | ||
void testMultipltLicenseString() { | ||
JsonArray reasons = | ||
Json.createArrayBuilder() | ||
.add(Json.createObjectBuilder().add("reason", "(license)")) | ||
.add(Json.createObjectBuilder().add("reason", "(license2)")) | ||
.build(); | ||
|
||
String actualReason = ParseReasons.getLicense(reasons); | ||
Assertions.assertEquals("license:license2", actualReason); | ||
} | ||
} |