Skip to content

Commit

Permalink
Make sbm-recipes-jee-to-boot compile
Browse files Browse the repository at this point in the history
  • Loading branch information
fabapp2 committed Sep 24, 2023
1 parent 5570686 commit 0e1baa4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.tngtech.archunit.lang.ArchRule;
import org.openrewrite.ExecutionContext;
import org.springframework.sbm.boot.autoconfigure.ScopeConfiguration;
import org.springframework.sbm.openrewrite.RewriteExecutionContext;
import org.springframework.sbm.parsers.RewriteExecutionContext;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.springframework.sbm.jee.jaxrs.recipes;

import org.openrewrite.SourceFile;
import org.openrewrite.java.tree.J;
import org.springframework.sbm.engine.recipe.AbstractAction;
import org.springframework.sbm.engine.context.ProjectContext;
Expand All @@ -26,6 +27,7 @@
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -375,7 +377,7 @@ void type() {
String actual = projectContext.getProjectJavaSources().list().get(0).print();

// verify it compiles
List<J.CompilationUnit> parse = new RewriteJavaParser(new SbmApplicationProperties(),
Stream<SourceFile> parse = new RewriteJavaParser(new SbmApplicationProperties(),
new RewriteExecutionContext()).parse(actual);

assertThat(actual)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void shouldAddDependencyToSpringBootStarterDataJpaIfNoneExists() {

sut.apply(projectContext);

assertThat(projectContext.getBuildFile().print()).isEqualTo(
assertThat(projectContext.getApplicationModules().getRootModule().getBuildFile().print()).isEqualTo(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
Expand Down Expand Up @@ -152,7 +152,7 @@ void shouldAddExcludesToSpringBootStarterDataJpaIfExists() {

sut.apply(projectContext);

assertThat(projectContext.getBuildFile().print()).isEqualTo(
assertThat(projectContext.getApplicationModules().getRootModule().getBuildFile().print()).isEqualTo(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\n" +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
Expand Down Expand Up @@ -338,7 +338,6 @@ void shouldAddEclipseLinkConfigurationClass() {
ProjectContext projectContext = TestProjectContext.buildProjectContext()
.withMavenRootBuildFileSource(pomXml)
.withProjectResource("src/main/resources/META-INF/persistence.xml", persistenceXml)
.addRegistrar(new PersistenceXmlProjectResourceRegistrar())
.build();

sut.apply(projectContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ void whenNoProjectContextExistThenExceptionThrown() {
.withMavenRootBuildFileSource(parentPom)
.withProjectResource("pom1/pom.xml", pom1)
.withProjectResource("pom2/pom.xml", pom2)
.addRegistrar(new PersistenceXmlProjectResourceRegistrar())
.build();

MigratePersistenceXmlToApplicationPropertiesAction sut = new MigratePersistenceXmlToApplicationPropertiesAction();
Expand Down Expand Up @@ -142,7 +141,6 @@ void whenNoApplicationPropertiesExistThenPropertiesShouldBeCreated() {
.withProjectResource("pom1/pom.xml", pom1)
.withProjectResource("pom2/pom.xml", pom2)
.withProjectResource("pom2/src/main/resources/META-INF/persistence.xml", persistenceXml)
.addRegistrar(new PersistenceXmlProjectResourceRegistrar())
.build();

assertThat(projectContext.search(new SpringBootApplicationPropertiesResourceListFilter())).isEmpty();
Expand Down Expand Up @@ -176,7 +174,7 @@ void migrateJpaToSpringBoot() {
</persistence-unit>
</persistence>
""")
.addRegistrar(new PersistenceXmlProjectResourceRegistrar()))
)
.actionUnderTest(new MigratePersistenceXmlToApplicationPropertiesAction())
.verify(context -> {
List<SpringBootApplicationProperties> applicationProperties = context.search(new SpringBootApplicationPropertiesResourceListFilter());
Expand Down

0 comments on commit 0e1baa4

Please sign in to comment.