1
1
package com .ibm .cldk ;
2
2
3
+ import com .google .gson .Gson ;
4
+ import com .google .gson .JsonElement ;
5
+ import com .google .gson .JsonObject ;
3
6
import org .junit .jupiter .api .BeforeAll ;
4
7
import org .junit .jupiter .api .Test ;
5
8
import org .junit .jupiter .api .Assertions ;
15
18
import java .nio .file .Path ;
16
19
import java .nio .file .Paths ;
17
20
import java .text .MessageFormat ;
21
+ import java .util .Map ;
18
22
import java .util .Properties ;
19
23
24
+ import static com .ibm .cldk .CodeAnalyzer .gson ;
25
+ import static org .junit .Assert .assertTrue ;
20
26
import static org .junit .jupiter .api .Assertions .assertThrows ;
21
27
22
28
@ Testcontainers
@@ -61,7 +67,8 @@ public class CodeAnalyzerIntegrationTest {
61
67
.withCommand ("-c" , "while true; do sleep 1; done" )
62
68
.withCopyFileToContainer (MountableFile .forHostPath (Paths .get (System .getProperty ("user.dir" )).resolve ("build/libs" )), "/opt/jars" )
63
69
.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" );
65
72
66
73
67
74
@ BeforeAll
@@ -145,4 +152,17 @@ void corruptMavenShouldNotTerminateWithErrorWhenMavenIsNotPresentUnlessAnalysisL
145
152
Assertions .assertEquals (1 , runCodeAnalyzer .getExitCode ());
146
153
Assertions .assertTrue (runCodeAnalyzer .getStderr ().contains ("java.lang.RuntimeException" ));
147
154
}
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_entrypoint_class\" : true" ), "No entry point classes found" );
166
+ Assertions .assertTrue (runCodeAnalyzerOnDaytrader8 .getStdout ().contains ("\" is_entrypoint\" : true" ), "No entry point methods found" );
167
+ }
148
168
}
0 commit comments