From dfbc4d74d99a5fab4a68ea968ca5a05a7d26b434 Mon Sep 17 00:00:00 2001 From: Stephan Schnabel Date: Mon, 14 Aug 2023 11:35:29 +0200 Subject: [PATCH] Maintenance: remove package handling for model examples, add test cases --- .../packages/model/MultipartTestExample.java | 13 +++++++++++++ .../model/NumberModelTestExample.java | 10 ++++++++++ .../model/ParameterModelTestExample.java | 19 +++++++++++++++++++ .../model/StringModelTestExample.java | 10 ++++++++++ .../AdditionalPropertiesModelTestExample.java | 3 --- ...tionalPropertiesModelValueTestExample.java | 3 --- .../EnumerationIntegerTestExample.java | 2 -- .../EnumerationModelTestExample.java | 7 ++----- .../EnumerationNumberTestExample.java | 2 -- .../EnumerationStringDefaultTestExample.java | 2 -- .../EnumerationStringTestExample.java | 2 -- .../nomicronaut/FirstModelTestExample.java | 3 --- .../InheritanceExtendedTestExample.java | 3 --- .../InheritanceSimpleTestExample.java | 3 --- .../InheritanceWithEnumType1TestExample.java | 3 --- .../InheritanceWithEnumType2TestExample.java | 3 --- .../InheritanceWithEnumType3TestExample.java | 3 --- ...nheritanceWithEnumTypeEnumTestExample.java | 2 -- .../InheritanceWithEnumTypeTestExample.java | 3 --- ...InheritanceWithStringType1TestExample.java | 3 --- ...InheritanceWithStringType2TestExample.java | 3 --- .../InheritanceWithStringTypeTestExample.java | 3 --- .../InheritanceWithoutType1TestExample.java | 3 --- .../InheritanceWithoutType2TestExample.java | 3 --- .../InheritanceWithoutTypeTestExample.java | 3 --- .../nomicronaut/ModelTestExample.java | 3 --- .../OneOfImplementor1TestExample.java | 3 --- .../OneOfImplementor2TestExample.java | 3 --- .../OneOfInterfaceTestExample.java | 3 --- .../nomicronaut/OneOfModelTestExample.java | 3 --- .../PropertyTypeOneTestExample.java | 5 +---- .../PropertyTypeTwoTestExample.java | 5 +---- .../SecondLevelModelTestExample.java | 3 --- .../SecondLevelOneModelTestExample.java | 3 --- .../SecondLevelTwoModelTestExample.java | 3 --- .../Micronaut/testExampleObject.mustache | 14 +++----------- .../languages/MicronautCodegenTest.java | 1 + 37 files changed, 60 insertions(+), 103 deletions(-) create mode 100644 gen/test/java/testapi/packages/model/MultipartTestExample.java create mode 100644 gen/test/java/testapi/packages/model/NumberModelTestExample.java create mode 100644 gen/test/java/testapi/packages/model/ParameterModelTestExample.java create mode 100644 gen/test/java/testapi/packages/model/StringModelTestExample.java diff --git a/gen/test/java/testapi/packages/model/MultipartTestExample.java b/gen/test/java/testapi/packages/model/MultipartTestExample.java new file mode 100644 index 00000000..aa4bf355 --- /dev/null +++ b/gen/test/java/testapi/packages/model/MultipartTestExample.java @@ -0,0 +1,13 @@ +package testapi.packages.model; + +public class MultipartTestExample { + + public static Multipart build() { + Multipart exampleInstance = new Multipart(); + exampleInstance.setOrderId(12); + exampleInstance.setUserId(12); + exampleInstance.setFileName("string"); + exampleInstance.setFile("byteArray".getBytes()); + return exampleInstance; + } +} diff --git a/gen/test/java/testapi/packages/model/NumberModelTestExample.java b/gen/test/java/testapi/packages/model/NumberModelTestExample.java new file mode 100644 index 00000000..ee7f6e86 --- /dev/null +++ b/gen/test/java/testapi/packages/model/NumberModelTestExample.java @@ -0,0 +1,10 @@ +package testapi.packages.model; + +public class NumberModelTestExample { + + public static NumberModel build() { + NumberModel exampleInstance = new NumberModel(); + exampleInstance.setBar(12.34); + return exampleInstance; + } +} diff --git a/gen/test/java/testapi/packages/model/ParameterModelTestExample.java b/gen/test/java/testapi/packages/model/ParameterModelTestExample.java new file mode 100644 index 00000000..0988a8b2 --- /dev/null +++ b/gen/test/java/testapi/packages/model/ParameterModelTestExample.java @@ -0,0 +1,19 @@ +package testapi.packages.model; + +public class ParameterModelTestExample { + + public static ParameterModel build() { + ParameterModel exampleInstance = new ParameterModel(); + exampleInstance.setBool("string"); + exampleInstance.setString("string"); + exampleInstance.setNumber(12.34); + exampleInstance.setInteger(12); + exampleInstance.setUuid(java.util.UUID.randomUUID()); + exampleInstance.setDate(null); + exampleInstance.setDateTime(null); + exampleInstance.setA(java.util.List.of()); + exampleInstance.setB(java.util.List.of()); + exampleInstance.setC(java.util.List.of()); + return exampleInstance; + } +} diff --git a/gen/test/java/testapi/packages/model/StringModelTestExample.java b/gen/test/java/testapi/packages/model/StringModelTestExample.java new file mode 100644 index 00000000..e0355f18 --- /dev/null +++ b/gen/test/java/testapi/packages/model/StringModelTestExample.java @@ -0,0 +1,10 @@ +package testapi.packages.model; + +public class StringModelTestExample { + + public static StringModel build() { + StringModel exampleInstance = new StringModel(); + exampleInstance.setFoo("string"); + return exampleInstance; + } +} diff --git a/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelTestExample.java b/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelTestExample.java index 1986bed7..b211068d 100644 --- a/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.AdditionalPropertiesModel.*; - public class AdditionalPropertiesModelTestExample { public static AdditionalPropertiesModel build() { AdditionalPropertiesModel exampleInstance = new AdditionalPropertiesModel(); - //initialize fields exampleInstance.setId("string"); return exampleInstance; } diff --git a/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelValueTestExample.java b/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelValueTestExample.java index 6f609736..1f39383f 100644 --- a/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelValueTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/AdditionalPropertiesModelValueTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.AdditionalPropertiesModelValue.*; - public class AdditionalPropertiesModelValueTestExample { public static AdditionalPropertiesModelValue build() { - // use the first found implementation as example return PropertyTypeOneTestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/EnumerationIntegerTestExample.java b/gen/test/java/testmodel/nomicronaut/EnumerationIntegerTestExample.java index 48057be3..0fb2acea 100644 --- a/gen/test/java/testmodel/nomicronaut/EnumerationIntegerTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/EnumerationIntegerTestExample.java @@ -1,7 +1,5 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.EnumerationInteger.*; - public class EnumerationIntegerTestExample { public static EnumerationInteger build() { diff --git a/gen/test/java/testmodel/nomicronaut/EnumerationModelTestExample.java b/gen/test/java/testmodel/nomicronaut/EnumerationModelTestExample.java index 693ebb2d..243a2b42 100644 --- a/gen/test/java/testmodel/nomicronaut/EnumerationModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/EnumerationModelTestExample.java @@ -1,16 +1,13 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.EnumerationModel.*; - public class EnumerationModelTestExample { public static EnumerationModel build() { EnumerationModel exampleInstance = new EnumerationModel(); - //initialize fields exampleInstance.setString(null); exampleInstance.setStringDefault(null); - exampleInstance.setEmbedded(Embedded.toEnum("first")); - exampleInstance.setEmbeddedDefault(EmbeddedDefault.toEnum("four")); + exampleInstance.setEmbedded(EnumerationModel.Embedded.toEnum("first")); + exampleInstance.setEmbeddedDefault(EnumerationModel.EmbeddedDefault.toEnum("four")); return exampleInstance; } } diff --git a/gen/test/java/testmodel/nomicronaut/EnumerationNumberTestExample.java b/gen/test/java/testmodel/nomicronaut/EnumerationNumberTestExample.java index d1220bb7..fe473aa2 100644 --- a/gen/test/java/testmodel/nomicronaut/EnumerationNumberTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/EnumerationNumberTestExample.java @@ -1,7 +1,5 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.EnumerationNumber.*; - public class EnumerationNumberTestExample { public static EnumerationNumber build() { diff --git a/gen/test/java/testmodel/nomicronaut/EnumerationStringDefaultTestExample.java b/gen/test/java/testmodel/nomicronaut/EnumerationStringDefaultTestExample.java index 0f5ccb04..545de082 100644 --- a/gen/test/java/testmodel/nomicronaut/EnumerationStringDefaultTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/EnumerationStringDefaultTestExample.java @@ -1,7 +1,5 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.EnumerationStringDefault.*; - public class EnumerationStringDefaultTestExample { public static EnumerationStringDefault build() { diff --git a/gen/test/java/testmodel/nomicronaut/EnumerationStringTestExample.java b/gen/test/java/testmodel/nomicronaut/EnumerationStringTestExample.java index eda69d8e..46ae1bff 100644 --- a/gen/test/java/testmodel/nomicronaut/EnumerationStringTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/EnumerationStringTestExample.java @@ -1,7 +1,5 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.EnumerationString.*; - public class EnumerationStringTestExample { public static EnumerationString build() { diff --git a/gen/test/java/testmodel/nomicronaut/FirstModelTestExample.java b/gen/test/java/testmodel/nomicronaut/FirstModelTestExample.java index f9bcf7aa..b87b8700 100644 --- a/gen/test/java/testmodel/nomicronaut/FirstModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/FirstModelTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.FirstModel.*; - public class FirstModelTestExample { public static FirstModel build() { FirstModel exampleInstance = new FirstModel(); - //initialize fields exampleInstance.setType("string"); exampleInstance.setFirst("string"); exampleInstance.setSecondLevel(null); diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceExtendedTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceExtendedTestExample.java index a8057578..5045aa19 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceExtendedTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceExtendedTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceExtended.*; - public class InheritanceExtendedTestExample { public static InheritanceExtended build() { InheritanceExtended exampleInstance = new InheritanceExtended(); - //initialize fields exampleInstance.setFoo("string"); exampleInstance.setBar("string"); return exampleInstance; diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java index 739f7cb1..17f3ccdd 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceSimpleTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceSimple.*; - public class InheritanceSimpleTestExample { public static InheritanceSimple build() { InheritanceSimple exampleInstance = new InheritanceSimple(); - //initialize fields exampleInstance.setFoo("string"); return exampleInstance; } diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType1TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType1TestExample.java index e5cf4e56..8772110e 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType1TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType1TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithEnumType1.*; - public class InheritanceWithEnumType1TestExample { public static InheritanceWithEnumType1 build() { InheritanceWithEnumType1 exampleInstance = new InheritanceWithEnumType1(); - //initialize fields exampleInstance.setD("string"); return exampleInstance; } diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType2TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType2TestExample.java index c7c6e1b7..e0b28430 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType2TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType2TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithEnumType2.*; - public class InheritanceWithEnumType2TestExample { public static InheritanceWithEnumType2 build() { InheritanceWithEnumType2 exampleInstance = new InheritanceWithEnumType2(); - //initialize fields exampleInstance.setE("string"); return exampleInstance; } diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType3TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType3TestExample.java index 9c3f1e72..23be01e3 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType3TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumType3TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithEnumType3.*; - public class InheritanceWithEnumType3TestExample { public static InheritanceWithEnumType3 build() { InheritanceWithEnumType3 exampleInstance = new InheritanceWithEnumType3(); - //initialize fields return exampleInstance; } } diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeEnumTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeEnumTestExample.java index 13081fb0..b4d7edbb 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeEnumTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeEnumTestExample.java @@ -1,7 +1,5 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithEnumTypeEnum.*; - public class InheritanceWithEnumTypeEnumTestExample { public static InheritanceWithEnumTypeEnum build() { diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeTestExample.java index fdb0d41f..a3f11b89 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithEnumTypeTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithEnumType.*; - public class InheritanceWithEnumTypeTestExample { public static InheritanceWithEnumType build() { - // use the first found implementation as example return InheritanceWithEnumType1TestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType1TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType1TestExample.java index 698d81c3..9be9b1cc 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType1TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType1TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithStringType1.*; - public class InheritanceWithStringType1TestExample { public static InheritanceWithStringType1 build() { InheritanceWithStringType1 exampleInstance = new InheritanceWithStringType1(); - //initialize fields exampleInstance.setA("string"); exampleInstance.setB("string"); return exampleInstance; diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType2TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType2TestExample.java index d302ff56..44192ca4 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType2TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithStringType2TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithStringType2.*; - public class InheritanceWithStringType2TestExample { public static InheritanceWithStringType2 build() { InheritanceWithStringType2 exampleInstance = new InheritanceWithStringType2(); - //initialize fields exampleInstance.setA("string"); exampleInstance.setC("string"); return exampleInstance; diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithStringTypeTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithStringTypeTestExample.java index f5ba1863..f186e2ce 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithStringTypeTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithStringTypeTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithStringType.*; - public class InheritanceWithStringTypeTestExample { public static InheritanceWithStringType build() { - // use the first found implementation as example return InheritanceWithStringType1TestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType1TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType1TestExample.java index ae8a4ecb..1617bf48 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType1TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType1TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithoutType1.*; - public class InheritanceWithoutType1TestExample { public static InheritanceWithoutType1 build() { InheritanceWithoutType1 exampleInstance = new InheritanceWithoutType1(); - //initialize fields exampleInstance.setE("string"); exampleInstance.setF("string"); return exampleInstance; diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType2TestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType2TestExample.java index 8a97c64c..e593f64b 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType2TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithoutType2TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithoutType2.*; - public class InheritanceWithoutType2TestExample { public static InheritanceWithoutType2 build() { InheritanceWithoutType2 exampleInstance = new InheritanceWithoutType2(); - //initialize fields exampleInstance.setE("string"); exampleInstance.setG("string"); return exampleInstance; diff --git a/gen/test/java/testmodel/nomicronaut/InheritanceWithoutTypeTestExample.java b/gen/test/java/testmodel/nomicronaut/InheritanceWithoutTypeTestExample.java index 7b597f8a..05012589 100644 --- a/gen/test/java/testmodel/nomicronaut/InheritanceWithoutTypeTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/InheritanceWithoutTypeTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.InheritanceWithoutType.*; - public class InheritanceWithoutTypeTestExample { public static InheritanceWithoutType build() { - // use the first found implementation as example return InheritanceWithoutType1TestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/ModelTestExample.java b/gen/test/java/testmodel/nomicronaut/ModelTestExample.java index ce568113..668416cc 100644 --- a/gen/test/java/testmodel/nomicronaut/ModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/ModelTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.Model.*; - public class ModelTestExample { public static Model build() { Model exampleInstance = new Model(); - //initialize fields exampleInstance.setId(12); exampleInstance.setIdWithExample(32); exampleInstance.setIdWithDefault(32); diff --git a/gen/test/java/testmodel/nomicronaut/OneOfImplementor1TestExample.java b/gen/test/java/testmodel/nomicronaut/OneOfImplementor1TestExample.java index 451d6e9d..20d28bbe 100644 --- a/gen/test/java/testmodel/nomicronaut/OneOfImplementor1TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/OneOfImplementor1TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.OneOfImplementor1.*; - public class OneOfImplementor1TestExample { public static OneOfImplementor1 build() { OneOfImplementor1 exampleInstance = new OneOfImplementor1(); - //initialize fields exampleInstance.setProperty("string"); return exampleInstance; } diff --git a/gen/test/java/testmodel/nomicronaut/OneOfImplementor2TestExample.java b/gen/test/java/testmodel/nomicronaut/OneOfImplementor2TestExample.java index 47af31b6..5eee08d9 100644 --- a/gen/test/java/testmodel/nomicronaut/OneOfImplementor2TestExample.java +++ b/gen/test/java/testmodel/nomicronaut/OneOfImplementor2TestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.OneOfImplementor2.*; - public class OneOfImplementor2TestExample { public static OneOfImplementor2 build() { OneOfImplementor2 exampleInstance = new OneOfImplementor2(); - //initialize fields exampleInstance.setProperty(12.34); return exampleInstance; } diff --git a/gen/test/java/testmodel/nomicronaut/OneOfInterfaceTestExample.java b/gen/test/java/testmodel/nomicronaut/OneOfInterfaceTestExample.java index 9ce77da4..35ceb4f2 100644 --- a/gen/test/java/testmodel/nomicronaut/OneOfInterfaceTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/OneOfInterfaceTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.OneOfInterface.*; - public class OneOfInterfaceTestExample { public static OneOfInterface build() { - // use the first found implementation as example return OneOfImplementor1TestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/OneOfModelTestExample.java b/gen/test/java/testmodel/nomicronaut/OneOfModelTestExample.java index ff90b653..4d01a268 100644 --- a/gen/test/java/testmodel/nomicronaut/OneOfModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/OneOfModelTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.OneOfModel.*; - public class OneOfModelTestExample { public static OneOfModel build() { - // use the first found implementation as example return FirstModelTestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/PropertyTypeOneTestExample.java b/gen/test/java/testmodel/nomicronaut/PropertyTypeOneTestExample.java index bdf9d975..544d34c3 100644 --- a/gen/test/java/testmodel/nomicronaut/PropertyTypeOneTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/PropertyTypeOneTestExample.java @@ -1,13 +1,10 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.PropertyTypeOne.*; - public class PropertyTypeOneTestExample { public static PropertyTypeOne build() { PropertyTypeOne exampleInstance = new PropertyTypeOne(); - //initialize fields - exampleInstance.setType(Type.toEnum("one")); + exampleInstance.setType(PropertyTypeOne.Type.toEnum("one")); return exampleInstance; } } diff --git a/gen/test/java/testmodel/nomicronaut/PropertyTypeTwoTestExample.java b/gen/test/java/testmodel/nomicronaut/PropertyTypeTwoTestExample.java index fb27c272..dfa9d084 100644 --- a/gen/test/java/testmodel/nomicronaut/PropertyTypeTwoTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/PropertyTypeTwoTestExample.java @@ -1,13 +1,10 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.PropertyTypeTwo.*; - public class PropertyTypeTwoTestExample { public static PropertyTypeTwo build() { PropertyTypeTwo exampleInstance = new PropertyTypeTwo(); - //initialize fields - exampleInstance.setType(Type.toEnum("two")); + exampleInstance.setType(PropertyTypeTwo.Type.toEnum("two")); return exampleInstance; } } diff --git a/gen/test/java/testmodel/nomicronaut/SecondLevelModelTestExample.java b/gen/test/java/testmodel/nomicronaut/SecondLevelModelTestExample.java index 47196711..30ad3cda 100644 --- a/gen/test/java/testmodel/nomicronaut/SecondLevelModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/SecondLevelModelTestExample.java @@ -1,11 +1,8 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.SecondLevelModel.*; - public class SecondLevelModelTestExample { public static SecondLevelModel build() { - // use the first found implementation as example return SecondLevelOneModelTestExample.build(); } } diff --git a/gen/test/java/testmodel/nomicronaut/SecondLevelOneModelTestExample.java b/gen/test/java/testmodel/nomicronaut/SecondLevelOneModelTestExample.java index 3ef928ce..f3ea0026 100644 --- a/gen/test/java/testmodel/nomicronaut/SecondLevelOneModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/SecondLevelOneModelTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.SecondLevelOneModel.*; - public class SecondLevelOneModelTestExample { public static SecondLevelOneModel build() { SecondLevelOneModel exampleInstance = new SecondLevelOneModel(); - //initialize fields exampleInstance.setType("string"); exampleInstance.setOne("string"); return exampleInstance; diff --git a/gen/test/java/testmodel/nomicronaut/SecondLevelTwoModelTestExample.java b/gen/test/java/testmodel/nomicronaut/SecondLevelTwoModelTestExample.java index e247a295..e26e1dd8 100644 --- a/gen/test/java/testmodel/nomicronaut/SecondLevelTwoModelTestExample.java +++ b/gen/test/java/testmodel/nomicronaut/SecondLevelTwoModelTestExample.java @@ -1,12 +1,9 @@ package testmodel.nomicronaut; -import testmodel.nomicronaut.SecondLevelTwoModel.*; - public class SecondLevelTwoModelTestExample { public static SecondLevelTwoModel build() { SecondLevelTwoModel exampleInstance = new SecondLevelTwoModel(); - //initialize fields exampleInstance.setType("string"); exampleInstance.setTwo("string"); return exampleInstance; diff --git a/src/main/resources/Micronaut/testExampleObject.mustache b/src/main/resources/Micronaut/testExampleObject.mustache index 2ceaa75b..df58a0b7 100644 --- a/src/main/resources/Micronaut/testExampleObject.mustache +++ b/src/main/resources/Micronaut/testExampleObject.mustache @@ -1,11 +1,9 @@ package {{package}}; - {{#models}} -import {{importPath}}.*; public class {{classname}}TestExample { +{{#model}} - {{#model}} public static {{classname}} build() { {{#isEnum}} return {{classname}}.values()[0]; @@ -14,10 +12,9 @@ public class {{classname}}TestExample { {{^vendorExtensions.x-is-one-of-interface}} {{^discriminator}} {{classname}} exampleInstance = new {{classname}}(); - //initialize fields {{#allVars}} {{#isEnum}} - exampleInstance.set{{nameInCamelCase}}({{datatypeWithEnum}}.toEnum({{{example}}})); + exampleInstance.set{{nameInCamelCase}}({{classname}}.{{datatypeWithEnum}}.toEnum({{{example}}})); {{/isEnum}} {{#isModel}} {{^isPrimitiveType}} @@ -36,7 +33,6 @@ public class {{classname}}TestExample { {{#discriminator}} {{#discriminator.mappedModels}} {{#-first}} - // use the first found implementation as example return {{{modelName}}}TestExample.build(); {{/-first}} {{/discriminator.mappedModels}} @@ -47,25 +43,21 @@ public class {{classname}}TestExample { {{^discriminator}} {{#interfaceModels}} {{#-first}} - // use the first found implementation as example return {{{classname}}}TestExample.build(); {{/-first}} {{/interfaceModels}} {{^interfaceModels}} - // there are no known downstream models. return null; {{/interfaceModels}} {{/discriminator}} {{#discriminator}} {{#discriminator.mappedModels}} {{#-first}} - // use the first found implementation as example return {{{modelName}}}TestExample.build(); {{/-first}} {{/discriminator.mappedModels}} {{/discriminator}} {{/vendorExtensions.x-is-one-of-interface}} - } - {{/model}} + }{{/model}} } {{/models}} diff --git a/src/test/java/org/openapitools/codegen/languages/MicronautCodegenTest.java b/src/test/java/org/openapitools/codegen/languages/MicronautCodegenTest.java index 13b93290..ec09ac49 100644 --- a/src/test/java/org/openapitools/codegen/languages/MicronautCodegenTest.java +++ b/src/test/java/org/openapitools/codegen/languages/MicronautCodegenTest.java @@ -50,6 +50,7 @@ void apiWithModelSuffix() { void apiWithPackages() { var packageName = "testapi.packages"; generate(configurator(SPEC_API, packageName) + .addAdditionalProperty(MicronautCodegen.GENERATE_EXAMPLES, true) .setPackageName(packageName + ".root") .setApiPackage(packageName + ".api") .setModelPackage(packageName + ".model")