Skip to content

Fixing PagingAndSortingHelperTest conforming to new finder #556

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

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,14 @@ public ProjectContext build() {
" <artifactId>dummy-root</artifactId>\n" +
" <version>0.1.0-SNAPSHOT</version>\n" +
" <packaging>jar</packaging>\n" +
"{{}}\n" +
"{{springParentPom}}\n" +
"{{dependencies}}\n" +
"</project>\n";

xml = xml.replace("{{dependencies}}", getDependenciesSection());
xml = xml
.replace("{{dependencies}}", getDependenciesSection())
.replace("{{springParentPom}}", getSpringParentPomSection())
;

resourcesWithRelativePaths.put(Path.of("pom.xml"), xml);

Expand Down Expand Up @@ -520,6 +523,7 @@ public ProjectContext build() {
return projectContext;
}


private void orderByOrderAnnotationValue(List<ProjectResourceWrapper> resourceWrapperList) {
resourceWrapperList.sort(Comparator.comparing(this::getOrder));
}
Expand Down Expand Up @@ -618,6 +622,23 @@ private String getDependenciesSection() {
return dependenciesSection.toString();
}

@NotNull
private String getSpringParentPomSection() {

if (this.springVersion.isPresent()) {
return """
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>%s</version>
<relativePath/>
</parent>
""".formatted(this.springVersion.get());
}

return "";
}

public Builder withSpringBootParentOf(String springVersion) {

this.springVersion = Optional.of(springVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class A {}
""";

ProjectContext context = TestProjectContext.buildProjectContext()
.withSpringBootParentOf("2.7.1")
.addJavaSource("src/main/java", javaClassWithPagingAndSortingRepository)
.addJavaSource("src/main/java",javaClassWithoutPagingAndSortingRepo)
.withBuildFileHavingDependencies("org.springframework.data:spring-data-commons:2.7.1")
Expand Down Expand Up @@ -105,6 +106,7 @@ public class A {}
""";

ProjectContext context = TestProjectContext.buildProjectContext()
.withSpringBootParentOf("2.7.1")
.addJavaSource("src/main/java", javaClassWithReactiveSortingRepo)
.addJavaSource("src/main/java",javaClassWithoutReactiveSortingRepo)
.withBuildFileHavingDependencies("org.springframework.data:spring-data-commons:2.7.1")
Expand Down Expand Up @@ -165,7 +167,7 @@ public class A {}
""";

ProjectContext context = TestProjectContext.buildProjectContext()
.withSpringBootParentOf("2.7,1")
.withSpringBootParentOf("2.7.1")
.addJavaSource("src/main/java", javaClassWithReactiveSortingRepo)
.addJavaSource("src/main/java",javaClassWithoutReactiveSortingRepo)
.withBuildFileHavingDependencies("org.springframework.data:spring-data-commons:2.7.1")
Expand Down Expand Up @@ -250,6 +252,7 @@ public class A {}
""";

ProjectContext context = TestProjectContext.buildProjectContext()
.withSpringBootParentOf("2.7.1")
.addJavaSource("src/main/java", javaClassWithPagingAndSortingRepository)
.addJavaSource("src/main/java",javaClassWithoutPagingAndSortingRepo)
.addJavaSource("src/main/java",javaClassWithReactiveSortingRepo)
Expand Down Expand Up @@ -309,6 +312,7 @@ public class A {}
""";

ProjectContext context = TestProjectContext.buildProjectContext()
.withSpringBootParentOf("2.7.1")
.addJavaSource("src/main/java",javaClassWithoutPagingAndSortingRepo)
.withBuildFileHavingDependencies("org.springframework.data:spring-data-commons:2.7.1")
.build();
Expand Down