diff --git a/CHANGELOG.md b/CHANGELOG.md index eb603c5..d2abaf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,21 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### Fixed + +- test coverage for MicroProfileSchemaWrapperGenerator + ## [1.8.6] - 2024-11-15 ### Added -- added attributes to field : *openapiEnumeration* and *openapiFormat* +- added attributes to field : *openapiEnumeration* and *openapiFormat* ### Changed -- field attribute : *exampleData* renamed to *openapiExample* +- field attribute : *exampleData* renamed to *openapiExample* ## [1.8.5] - 2024-11-14 ### Added -- package-helper-microprofile, to add model wrapper with openapi annotation. +- package-helper-microprofile, to add model wrapper with openapi annotation. ### Fixed diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java index b9f32c9..ea8a1ee 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/DaogenBasicGenerator.java @@ -271,6 +271,10 @@ public String getEntityWrapperName() { return DaogenCatalogConstants.wrapperName( this.getCurrentEntity() ); } + public String getEntityMpSchemaName() { + return DaogenCatalogConstants.mpSchemaName( this.getCurrentEntity() ); + } + public String getEntityFacadeDefName() { return DaogenCatalogConstants.facadeDefName( this.getCurrentEntity() ); } diff --git a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/UnitTestHelper.java b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/UnitTestHelper.java index 55e9c01..96ae2bc 100644 --- a/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/UnitTestHelper.java +++ b/fj-daogen-base/src/main/java/org/fugerit/java/daogen/base/gen/util/UnitTestHelper.java @@ -23,6 +23,9 @@ public static void genInitBasicTest( DaogenBasicGenerator gen, int junitLevel ) gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_MODEL )+"."+gen.getEntityModelName(), gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER )+"."+gen.getEntityHelperName(), gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER )+"."+gen.getEntityWrapperName() ); + if ( StringUtils.isNotEmpty( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER_MICROPROFILE ) ) ) { + gen.getImportList().add( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER_MICROPROFILE )+"."+gen.getEntityMpSchemaName() ); + } if ( StringUtils.isNotEmpty( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_FACADE_DEF ) ) ) { GenUtils.addAll( gen.getImportList(), gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_FACADE_DEF )+"."+gen.getEntityFinderName() ); @@ -93,7 +96,13 @@ private static void createSampleEntityPrintAllMethod( DaogenBasicGenerator gen ) private static void createSampleEntityInstanceMethod( DaogenBasicGenerator gen, String assertionClass ) { // creates a new instance gen.getWriter().println( DaogenBasicGenerator.TAB+"public "+gen.getEntityModelName()+" newInstance() { " ); - gen.getWriter().println( DaogenBasicGenerator.TAB_2+""+gen.getEntityWrapperName()+" current = new "+gen.getEntityWrapperName()+"( new "+gen.getEntityHelperName()+DaogenBasicGenerator.COMMA_END_LIT ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+gen.getEntityModelName()+" model = new "+gen.getEntityHelperName()+"();" ); + if ( StringUtils.isNotEmpty( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER_MICROPROFILE ) ) ) { + gen.getWriter().println( DaogenBasicGenerator.TAB_2+gen.getEntityMpSchemaName()+" microprofile = new "+gen.getEntityMpSchemaName()+"( model );" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"model = microprofile;" ); + gen.getWriter().println( DaogenBasicGenerator.TAB_2+"logger.info( \"unwrap : {}\", microprofile.unwrap( microprofile ) );" ); + } + gen.getWriter().println( DaogenBasicGenerator.TAB_2+gen.getEntityWrapperName()+" current = new "+gen.getEntityWrapperName()+"( model );" ); boolean checkIsEmpty = BooleanUtils.isTrue( gen.getDaogenConfig().getGeneralProp( DaogenCatalogConstants.GEN_PROP_CHECK_EMPTY_INTERFACE ) ); if ( checkIsEmpty ) { gen.getWriter().println( DaogenBasicGenerator.TAB_2+assertionClass+".assertTrue( current.isEmpty() );" ); diff --git a/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/base/config/TestDaogenRun.java b/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/base/config/TestDaogenRun.java index 7241aea..80030dc 100644 --- a/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/base/config/TestDaogenRun.java +++ b/fj-daogen-base/src/test/java/test/org/fugerit/java/daogen/base/config/TestDaogenRun.java @@ -50,6 +50,8 @@ public void testDaoGenerationJdk17SpringBoot() throws IOException, ConfigExcepti DaogenCatalogConstants.GEN_PROP_CHECK_EMPTY_INTERFACE , BooleanUtils.BOOLEAN_FALSE ); overrideProperties.setProperty( DaogenCatalogConstants.GEN_PROP_DISABLE_SINGLETON , DaogenCatalogConstants.GEN_PROP_DISABLE_SINGLETON_ENABLED ); + overrideProperties.setProperty( + DaogenCatalogConstants.GEN_PROP_PACKAGE_HELPER_MICROPROFILE , "org.fugerit.java.daogen.sample.impl.helper" ); int result = this.testDaoGenerationWorker(file, overrideProperties); Assert.assertTrue( file.exists() ); Assert.assertEquals( Result.RESULT_CODE_OK, result ); diff --git a/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml b/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml index ea7b149..f6ead17 100644 --- a/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml +++ b/fj-daogen-base/src/test/resources/sample/daogenruntest-sample-daogen-config.xml @@ -19,7 +19,6 @@ struct_prefix="OBJ_" package-model="org.fugerit.java.daogen.sample.def.model" package-helper="org.fugerit.java.daogen.sample.impl.helper" - package-helper-microprofile="org.fugerit.java.daogen.sample.impl.helper" dao-helper-ng-mode="enabled" dao-wrapper-ng-mode="enabled" dao-finder-ng-mode="enabled" diff --git a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/AddressJunit4ModelTest.java b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/AddressJunit4ModelTest.java index 0547a0a..3d5059f 100644 --- a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/AddressJunit4ModelTest.java +++ b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/AddressJunit4ModelTest.java @@ -38,7 +38,8 @@ public void printAll( ModelAddress current ) { } public ModelAddress newInstance() { - WrapperAddress current = new WrapperAddress( new HelperAddress() ); + ModelAddress model = new HelperAddress(); + WrapperAddress current = new WrapperAddress( model ); Assert.assertTrue( current.isEmpty() ); current.setId(new java.math.BigDecimal( "1" )); Assert.assertFalse( current.isEmpty() ); diff --git a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/LogDataJunit4ModelTest.java b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/LogDataJunit4ModelTest.java index 08d650b..e95342d 100644 --- a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/LogDataJunit4ModelTest.java +++ b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/LogDataJunit4ModelTest.java @@ -35,7 +35,8 @@ public void printAll( ModelLogData current ) { } public ModelLogData newInstance() { - WrapperLogData current = new WrapperLogData( new HelperLogData() ); + ModelLogData model = new HelperLogData(); + WrapperLogData current = new WrapperLogData( model ); Assert.assertTrue( current.isEmpty() ); current.setId(new java.math.BigDecimal( "1" )); Assert.assertFalse( current.isEmpty() ); diff --git a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/TestTwoFieldKeyJunit4ModelTest.java b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/TestTwoFieldKeyJunit4ModelTest.java index 37793dd..72ac9e1 100644 --- a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/TestTwoFieldKeyJunit4ModelTest.java +++ b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/TestTwoFieldKeyJunit4ModelTest.java @@ -35,7 +35,8 @@ public void printAll( ModelTestTwoFieldKey current ) { } public ModelTestTwoFieldKey newInstance() { - WrapperTestTwoFieldKey current = new WrapperTestTwoFieldKey( new HelperTestTwoFieldKey() ); + ModelTestTwoFieldKey model = new HelperTestTwoFieldKey(); + WrapperTestTwoFieldKey current = new WrapperTestTwoFieldKey( model ); Assert.assertTrue( current.isEmpty() ); current.setIdOne(new java.math.BigDecimal( "1" )); Assert.assertFalse( current.isEmpty() ); diff --git a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UploadJunit4ModelTest.java b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UploadJunit4ModelTest.java index 090a452..ced4215 100644 --- a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UploadJunit4ModelTest.java +++ b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UploadJunit4ModelTest.java @@ -36,7 +36,8 @@ public void printAll( ModelUpload current ) { } public ModelUpload newInstance() { - WrapperUpload current = new WrapperUpload( new HelperUpload() ); + ModelUpload model = new HelperUpload(); + WrapperUpload current = new WrapperUpload( model ); Assert.assertTrue( current.isEmpty() ); current.setId(new java.math.BigDecimal( "1" )); Assert.assertFalse( current.isEmpty() ); diff --git a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserDataJunit4ModelTest.java b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserDataJunit4ModelTest.java index b561a80..fc1aa78 100644 --- a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserDataJunit4ModelTest.java +++ b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserDataJunit4ModelTest.java @@ -39,7 +39,8 @@ public void printAll( ModelUserData current ) { } public ModelUserData newInstance() { - WrapperUserData current = new WrapperUserData( new HelperUserData() ); + ModelUserData model = new HelperUserData(); + WrapperUserData current = new WrapperUserData( model ); Assert.assertTrue( current.isEmpty() ); current.setId(new java.math.BigDecimal( "1" )); Assert.assertFalse( current.isEmpty() ); diff --git a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserJunit4ModelTest.java b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserJunit4ModelTest.java index c39c08c..10b185c 100644 --- a/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserJunit4ModelTest.java +++ b/fj-daogen-sample/src/test/java/org/fugerit/java/daogen/sample/junit4test/model/UserJunit4ModelTest.java @@ -40,7 +40,8 @@ public void printAll( ModelUser current ) { } public ModelUser newInstance() { - WrapperUser current = new WrapperUser( new HelperUser() ); + ModelUser model = new HelperUser(); + WrapperUser current = new WrapperUser( model ); Assert.assertTrue( current.isEmpty() ); current.setId(new java.math.BigDecimal( "1" )); Assert.assertFalse( current.isEmpty() );