Skip to content

Commit 9358d41

Browse files
add unit test
1 parent bb64033 commit 9358d41

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

detectable/src/test/java/com/blackduck/integration/detectable/detectables/gradle/unit/GradleReportParserTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,27 @@ public void getLineLevelTest() {
7373
assertEquals(0, gradleReportLineParser.parseLine(("\\--- org.apache.commons:commons-compress:1.13"), Collections.emptyMap()).getLevel());
7474
}
7575

76+
@Test
77+
void failedSuffixIsStrippedFromVersion() {
78+
GradleReportLineParser gradleReportLineParser = new GradleReportLineParser();
79+
String line = "+--- org.apache.commons:commons-email:1.2 FAILED";
80+
GradleTreeNode node = gradleReportLineParser.parseLine(line, Collections.emptyMap());
81+
82+
assertTrue(node.getGav().isPresent());
83+
84+
GradleGav gav = node.getGav().get();
85+
assertEquals("org.apache.commons", gav.getGroup());
86+
assertEquals("commons-email", gav.getName());
87+
assertEquals("1.2", gav.getVersion(), "Expected version to exclude 'FAILED'");
88+
}
89+
90+
@Test
91+
void missingVersionHandledAsUnknownNode() {
92+
GradleReportLineParser parser = new GradleReportLineParser();
93+
String line = "+--- org.apache.commons:commons-lang3:";
94+
GradleTreeNode node = parser.parseLine(line, Collections.emptyMap());
95+
96+
assertEquals(GradleTreeNode.NodeType.UNKNOWN, node.getNodeType());
97+
assertFalse(node.getGav().isPresent());
98+
}
7699
}

0 commit comments

Comments
 (0)