@@ -5104,6 +5104,7 @@ public void testEnumUnknownDefaultCaseDeserializationNotSet_issue13241() throws
51045104 public void shouldAnnotateNonRequiredFieldsAsNullable () throws IOException {
51055105 SpringCodegen codegen = new SpringCodegen ();
51065106 codegen .setLibrary (SPRING_BOOT );
5107+ codegen .setGenerateConstructorWithAllArgs (true );
51075108
51085109 Map <String , File > files = generateFiles (codegen , "src/test/resources/3_0/nullable-annotation.yaml" );
51095110 var file = files .get ("Item.java" );
@@ -5120,12 +5121,18 @@ public void shouldAnnotateNonRequiredFieldsAsNullable() throws IOException {
51205121 JavaFileAssert .assertThat (file )
51215122 .assertProperty ("nullableStr" )
51225123 .doesNotHaveAnnotation ("Nullable" );
5124+ JavaFileAssert .assertThat (file )
5125+ .fileContains (
5126+ "public Item(String mandatoryName, @Nullable String optionalDescription," +
5127+ " String optionalOneWithDefault, String nullableStr)"
5128+ );
51235129 }
51245130
51255131 @ Test
51265132 public void shouldNotAnnotateNonRequiredFieldsAsNullableWhileUseOptional () throws IOException {
51275133 SpringCodegen codegen = new SpringCodegen ();
51285134 codegen .setLibrary (SPRING_BOOT );
5135+ codegen .setGenerateConstructorWithAllArgs (true );
51295136 codegen .setUseOptional (true );
51305137
51315138 Map <String , File > files = generateFiles (codegen , "src/test/resources/3_0/nullable-annotation.yaml" );
@@ -5143,12 +5150,18 @@ public void shouldNotAnnotateNonRequiredFieldsAsNullableWhileUseOptional() throw
51435150 JavaFileAssert .assertThat (file )
51445151 .assertProperty ("nullableStr" )
51455152 .doesNotHaveAnnotation ("Nullable" );
5153+ JavaFileAssert .assertThat (file )
5154+ .fileContains (
5155+ "public Item(String mandatoryName, String optionalDescription," +
5156+ " String optionalOneWithDefault, String nullableStr)"
5157+ );
51465158 }
51475159
51485160 @ Test
51495161 public void shouldAnnotateNonRequiredFieldsAsNullableWhileNotUsingOpenApiNullable () throws IOException {
51505162 SpringCodegen codegen = new SpringCodegen ();
51515163 codegen .setLibrary (SPRING_BOOT );
5164+ codegen .setGenerateConstructorWithAllArgs (true );
51525165 codegen .setOpenApiNullable (false );
51535166
51545167 Map <String , File > files = generateFiles (codegen , "src/test/resources/3_0/nullable-annotation.yaml" );
@@ -5166,5 +5179,10 @@ public void shouldAnnotateNonRequiredFieldsAsNullableWhileNotUsingOpenApiNullabl
51665179 JavaFileAssert .assertThat (file )
51675180 .assertProperty ("nullableStr" )
51685181 .hasAnnotation ("Nullable" );
5182+ JavaFileAssert .assertThat (file )
5183+ .fileContains (
5184+ "public Item(String mandatoryName, @Nullable String optionalDescription," +
5185+ " String optionalOneWithDefault, @Nullable String nullableStr)"
5186+ );
51695187 }
51705188}
0 commit comments