Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching conflict between generateImmutableModels and generateNoArgsConstructorOnly #1395

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Patching conflict between generateImmutableModels and generateNoArgsC…
…onstructorOnly
  • Loading branch information
vvandertas committed Nov 14, 2023
commit f09925c1dad965ecdf1d510239b1f8a9bc77f489
4 changes: 2 additions & 2 deletions src/main/resources/templates/java-lang/type.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ${className} implements java.io.Serializable<#if implements?has_con
public ${className}() {
}

<#if fields?has_content && !generateNoArgsConstructorOnly>
<#if fields?has_content && (!generateNoArgsConstructorOnly || immutableModels)>
public ${className}(<#list fields as field>${field.type} ${field.name}<#if field_has_next>, </#if></#list>) {
<#list fields as field>
this.${field.name} = ${field.name};
Expand Down Expand Up @@ -202,7 +202,7 @@ public class ${className} implements java.io.Serializable<#if implements?has_con
</#if>

public ${className} build() {
<#if generateNoArgsConstructorOnly>
<#if !immutableModels && generateNoArgsConstructorOnly>
${className} result = new ${className}();
<#list fields as field>
<#if field.visibility == 'public'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@
new File("src/test/resources/expected-classes/immutable/Event.java.txt"),
getFileByName(files, "Event.java"));
}

@Test
void generate_noArgs_CheckFiles() throws Exception {
mappingConfig.setPackageName("com.kobylynskyi.graphql.immutable");

Check warning on line 45 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 6, expected level should be 8. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:45:7: warning: 'method def' child has incorrect indentation level 6, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
mappingConfig.setGenerateImmutableModels(true);

Check warning on line 46 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 6, expected level should be 8. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:46:7: warning: 'method def' child has incorrect indentation level 6, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
mappingConfig.setGenerateNoArgsConstructorOnly(true);

Check warning on line 47 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 6, expected level should be 8. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:47:7: warning: 'method def' child has incorrect indentation level 6, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

new JavaGraphQLCodegen(singletonList("src/test/resources/schemas/test.graphqls"),

Check warning on line 49 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 6, expected level should be 8. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:49:7: warning: 'method def' child has incorrect indentation level 6, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
outputBuildDir, mappingConfig, TestUtils.getStaticGeneratedInfo(mappingConfig)).generate();

File[] files = Objects.requireNonNull(outputJavaClassesDir.listFiles());

Check warning on line 52 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 6, expected level should be 8. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:52:7: warning: 'method def' child has incorrect indentation level 6, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

assertSameTrimmedContent(

Check warning on line 54 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 6, expected level should be 8. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:54:7: warning: 'method def' child has incorrect indentation level 6, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
new File("src/test/resources/expected-classes/immutable/Event.java.txt"),

Check warning on line 55 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'method call' child has incorrect indentation level 8, expected level should be 12. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:55:9: warning: 'method call' child has incorrect indentation level 8, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
getFileByName(files, "Event.java"));

Check warning on line 56 in src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java

View workflow job for this annotation

GitHub Actions / check-code-style

[checkstyle] reported by reviewdog 🐶 'getFileByName' has incorrect indentation level 8, expected level should be 10. Raw Output: /home/runner/work/graphql-java-codegen/graphql-java-codegen/./src/test/java/com/kobylynskyi/graphql/codegen/GraphQLCodegenImmutableTest.java:56:9: warning: 'getFileByName' has incorrect indentation level 8, expected level should be 10. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void generate_PublicFields() throws Exception {
void generate_PublicFields_NoArgsConstructor_immutableModels() throws Exception {
mappingConfig.setGenerateModelsWithPublicFields(true);
mappingConfig.setGenerateNoArgsConstructorOnly(true);
mappingConfig.setGenerateImmutableModels(true);
mappingConfig.setGenerateImmutableModels(false);
mappingConfig.setGenerateClient(true);

generate("src/test/resources/schemas/test.graphqls");
Expand All @@ -483,7 +483,7 @@ void generate_PublicFields_NoArgsConstructor_immutableModels() throws Exception
void generate_PublicFields_NoBuilder_NoArgsConstructor() throws Exception {
mappingConfig.setGenerateModelsWithPublicFields(true);
mappingConfig.setGenerateNoArgsConstructorOnly(true);
mappingConfig.setGenerateImmutableModels(true);
mappingConfig.setGenerateImmutableModels(false);
mappingConfig.setGenerateBuilder(false);

generate("src/test/resources/schemas/test.graphqls");
Expand Down
Loading