Skip to content

Commit

Permalink
Test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Mar 31, 2024
1 parent d671263 commit d77df5f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/test/java/test/helper/generation/TestNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import java.util.stream.Collectors;

@Slf4j
public class TestNative {
class TestNative {


@Test
public void testReflectConfig() {
void testReflectConfig() {
try {
AccessingAllClassesInPackage helper = new AccessingAllClassesInPackage();
Set<Class<?>> set = helper.findAllClassesUsingClassLoader( "test.helper.generation.model" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,29 @@ void test1() throws MojoExecutionException, IOException {
Assertions.assertTrue( file.exists() );
}

@Test
void test2() throws MojoExecutionException, IOException {
MojoGenerate mojo = new MojoGenerate();
File file = new File( "target/override-test/native-image/reflect-config.json" );
file.delete();
mojo.setNativeHelperConfigPath( "src/test/resources/tool/config/native-helper-config.yaml" );
mojo.setReflectConfigJsonOutputPath( file.getCanonicalPath() );
mojo.execute();
Assertions.assertTrue( file.exists() );
}

@Test
void testFail1() throws MojoExecutionException, IOException {
MojoGenerate mojo = new MojoGenerate();
mojo.setNativeHelperConfigPath( "src/test/resources/tool/config/native-helper-config-fail.yaml" );
Assertions.assertThrows( MojoExecutionException.class, () -> mojo.execute() );
}

@Test
void testFail2() throws MojoExecutionException, IOException {
MojoGenerate mojo = new MojoGenerate();
mojo.setNativeHelperConfigPath( "src/test/resources/tool/config/native-helper-config-not-exists.yaml" );
Assertions.assertThrows( MojoExecutionException.class, () -> mojo.execute() );
}

}
17 changes: 17 additions & 0 deletions src/test/resources/tool/config/native-helper-config-fail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# native-helper-graalvm generation configuration
---
generate:
- className: org.fugerit.java.nhg.reflect.config.Entry
mode: getters
- className: org.fugerit.java.nhg.reflect.config.EntryCondition
mode: getters
- className: org.fugerit.java.nhg.reflect.config.EntryField
mode: getters
- className: org.fugerit.java.nhg.reflect.config.EntryMethod
mode: getters
- className: org.fugerit.java.nhg.config.model.NativeHelperConfig
mode: getters_setters
typeReachable: org.fugerit.java.nhg.config.NativeHelperFacade
- className: org.fugerit.java.nhg.config.model.GenerateConfig
mode: getters_setters
typeReachable: org.fugerit.java.nhg.config.NativeHelperFacade

0 comments on commit d77df5f

Please sign in to comment.