Skip to content

Commit e48cd88

Browse files
committed
Feature request #86: Added a new test case to verify functionality.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent 9ffbc5d commit e48cd88

21 files changed

+21
-3658
lines changed

src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.ibm.cldk;
22

3+
import com.google.gson.Gson;
4+
import com.google.gson.JsonElement;
5+
import com.google.gson.JsonObject;
36
import org.junit.jupiter.api.BeforeAll;
47
import org.junit.jupiter.api.Test;
58
import org.junit.jupiter.api.Assertions;
@@ -15,8 +18,11 @@
1518
import java.nio.file.Path;
1619
import java.nio.file.Paths;
1720
import java.text.MessageFormat;
21+
import java.util.Map;
1822
import java.util.Properties;
1923

24+
import static com.ibm.cldk.CodeAnalyzer.gson;
25+
import static org.junit.Assert.assertTrue;
2026
import static org.junit.jupiter.api.Assertions.assertThrows;
2127

2228
@Testcontainers
@@ -61,7 +67,8 @@ public class CodeAnalyzerIntegrationTest {
6167
.withCommand("-c", "while true; do sleep 1; done")
6268
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("build/libs")), "/opt/jars")
6369
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-corrupt-test")), "/test-applications/mvnw-corrupt-test")
64-
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-working-test")), "/test-applications/mvnw-working-test");
70+
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-working-test")), "/test-applications/mvnw-working-test")
71+
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/daytrader8")), "/test-applications/daytrader8");
6572

6673

6774
@BeforeAll
@@ -145,4 +152,17 @@ void corruptMavenShouldNotTerminateWithErrorWhenMavenIsNotPresentUnlessAnalysisL
145152
Assertions.assertEquals(1, runCodeAnalyzer.getExitCode());
146153
Assertions.assertTrue(runCodeAnalyzer.getStderr().contains("java.lang.RuntimeException"));
147154
}
155+
156+
@Test
157+
void shouldBeAbleToGenerateAnalysisArtifactForDaytrader8() throws Exception {
158+
var runCodeAnalyzerOnDaytrader8 = mavenContainer.execInContainer(
159+
"java",
160+
"-jar",
161+
String.format("/opt/jars/codeanalyzer-%s.jar", codeanalyzerVersion),
162+
"--input=/test-applications/daytrader8",
163+
"--analysis-level=1"
164+
);
165+
Assertions.assertTrue(runCodeAnalyzerOnDaytrader8.getStdout().contains("\"is_entry_point_class\": true"), "No entry point classes found");
166+
Assertions.assertTrue(runCodeAnalyzerOnDaytrader8.getStdout().contains("\"is_entry_point\": true"), "No entry point methods found");
167+
}
148168
}

0 commit comments

Comments
 (0)