From d9acaecbea348800eea4a0d7b1349aa51d8b0464 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 13 Oct 2021 13:10:55 +0200 Subject: [PATCH 1/5] Fix missing constructure/methodes in native image. Signed-off-by: Dennis Labordus --- app/pom.xml | 1 - .../rest/CompasReflectionConfiguration.java | 22 +++++++++++++++++++ app/src/main/resources/reflection-config.json | 7 ------ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java delete mode 100644 app/src/main/resources/reflection-config.json diff --git a/app/pom.xml b/app/pom.xml index d7933c05..6b392636 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -161,7 +161,6 @@ SPDX-License-Identifier: Apache-2.0 native true - -H:ReflectionConfigurationFiles=reflection-config.json diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java new file mode 100644 index 00000000..b2960a43 --- /dev/null +++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2021 Alliander N.V. +// +// SPDX-License-Identifier: Apache-2.0 +package org.lfenergy.compas.scl.data.rest; + +import io.quarkus.runtime.annotations.RegisterForReflection; +import org.lfenergy.compas.core.jaxrs.model.ErrorMessage; +import org.lfenergy.compas.core.jaxrs.model.ErrorResponse; +import org.lfenergy.compas.scl.data.model.SclMetaInfo; + +/** + * Configure class for Quarkus Native Build to be included. + */ +@RegisterForReflection( + targets = { + SclMetaInfo.class, + ErrorMessage.class, + ErrorResponse.class, + org.lfenergy.compas.scl.data.model.ObjectFactory.class + }) +public class CompasReflectionConfiguration { +} diff --git a/app/src/main/resources/reflection-config.json b/app/src/main/resources/reflection-config.json deleted file mode 100644 index 2b569450..00000000 --- a/app/src/main/resources/reflection-config.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "name" : "org.lfenergy.compas.scl.data.model.ObjectFactory", - "allDeclaredMethods" : true, - "allPublicMethods" : true - } -] \ No newline at end of file From c2999a5d33017563c148646eba40dd8bf47ee4b8 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 13 Oct 2021 16:07:10 +0200 Subject: [PATCH 2/5] Added Test for Sonar. Signed-off-by: Dennis Labordus --- .../data/rest/CompasReflectionConfigurationTest.java | 10 ++++++++++ .../rest/CompasSclDataServiceConfigurationTest.java | 11 +++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java new file mode 100644 index 00000000..69aec226 --- /dev/null +++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java @@ -0,0 +1,10 @@ +package org.lfenergy.compas.scl.data.rest; + +import org.junit.jupiter.api.Test; + +class CompasReflectionConfigurationTest { + @Test + void constructor_WhenCalled_ThenNoExceptions() { + new CompasReflectionConfiguration(); + } +} \ No newline at end of file diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java index 7cb39cc0..86a35ac5 100644 --- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java +++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java @@ -8,20 +8,23 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; class CompasSclDataServiceConfigurationTest { - private CompasSclDataServiceConfiguration configuration = new CompasSclDataServiceConfiguration(); + @Test + void constructor_WhenCalled_ThenNoExceptions() { + new CompasSclDataServiceConfiguration(); + } @Test void createElementConverter_WhenCalled_ThenObjectReturned() { - assertNotNull(configuration.createElementConverter()); + assertNotNull(new CompasSclDataServiceConfiguration().createElementConverter()); } @Test void creatSclElementProcessor_WhenCalled_ThenObjectReturned() { - assertNotNull(configuration.creatSclElementProcessor()); + assertNotNull(new CompasSclDataServiceConfiguration().creatSclElementProcessor()); } @Test void createSclDataModelMarshaller_WhenCalled_ThenObjectReturned() { - assertNotNull(configuration.createSclDataModelMarshaller()); + assertNotNull(new CompasSclDataServiceConfiguration().createSclDataModelMarshaller()); } } \ No newline at end of file From d8a789ce5025d7c386bdbedb30c0c75e14ae3f7a Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 13 Oct 2021 16:08:47 +0200 Subject: [PATCH 3/5] Use full names of classes. Signed-off-by: Dennis Labordus --- .../scl/data/rest/CompasReflectionConfiguration.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java b/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java index b2960a43..19b1660e 100644 --- a/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java +++ b/app/src/main/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfiguration.java @@ -4,18 +4,15 @@ package org.lfenergy.compas.scl.data.rest; import io.quarkus.runtime.annotations.RegisterForReflection; -import org.lfenergy.compas.core.jaxrs.model.ErrorMessage; -import org.lfenergy.compas.core.jaxrs.model.ErrorResponse; -import org.lfenergy.compas.scl.data.model.SclMetaInfo; /** * Configure class for Quarkus Native Build to be included. */ @RegisterForReflection( targets = { - SclMetaInfo.class, - ErrorMessage.class, - ErrorResponse.class, + org.lfenergy.compas.core.jaxrs.model.ErrorMessage.class, + org.lfenergy.compas.core.jaxrs.model.ErrorResponse.class, + org.lfenergy.compas.scl.data.model.SclMetaInfo.class, org.lfenergy.compas.scl.data.model.ObjectFactory.class }) public class CompasReflectionConfiguration { From 6ac56ff36b8d5af60db2f2fa6ecb9c93aa3db3c3 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 13 Oct 2021 16:10:30 +0200 Subject: [PATCH 4/5] Added re-use policy. Signed-off-by: Dennis Labordus --- .../scl/data/rest/CompasReflectionConfigurationTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java index 69aec226..ef89b0bd 100644 --- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java +++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2021 Alliander N.V. +// +// SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.scl.data.rest; import org.junit.jupiter.api.Test; From 8a97d94494e031a11ccf8248f533a8e4d7ea3a46 Mon Sep 17 00:00:00 2001 From: Dennis Labordus Date: Wed, 13 Oct 2021 16:15:07 +0200 Subject: [PATCH 5/5] Added Test for Sonar. Signed-off-by: Dennis Labordus --- .../scl/data/rest/CompasReflectionConfigurationTest.java | 5 ++++- .../scl/data/rest/CompasSclDataServiceConfigurationTest.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java index ef89b0bd..e6f37daa 100644 --- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java +++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasReflectionConfigurationTest.java @@ -5,9 +5,12 @@ import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; + class CompasReflectionConfigurationTest { @Test void constructor_WhenCalled_ThenNoExceptions() { - new CompasReflectionConfiguration(); + var config = new CompasReflectionConfiguration(); + assertNotNull(config); } } \ No newline at end of file diff --git a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java index 86a35ac5..4db4ff67 100644 --- a/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java +++ b/app/src/test/java/org/lfenergy/compas/scl/data/rest/CompasSclDataServiceConfigurationTest.java @@ -10,7 +10,8 @@ class CompasSclDataServiceConfigurationTest { @Test void constructor_WhenCalled_ThenNoExceptions() { - new CompasSclDataServiceConfiguration(); + var config = new CompasSclDataServiceConfiguration(); + assertNotNull(config); } @Test