Skip to content

Commit

Permalink
Module sbm-support-boot compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
fabapp2 committed Sep 20, 2023
1 parent 211a65d commit 049155c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public String getDisplayName() {
}

@Override
protected TreeVisitor<?, ExecutionContext> getVisitor() {
public String getDescription() {
return getDisplayName();
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
return new JavaIsoVisitor<>() {
@Override
public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext executionContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private boolean hasBuildFileDependencyImport(BuildFile buildFile) {
}

private String resolveCoordinates(BuildFile buildFile, Dependency md) {
String coordinates = md.getCoordinates();
String coordinates = md.getGav();
if (md.getVersion().startsWith("${")) {
String version = buildFile.getProperty(md.getVersion().substring(2, md.getVersion().length() - 1));
if (version != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public boolean evaluate(ProjectContext context) {

@NotNull
private Predicate<Dependency> matchesSpringBootPattern() {
return k -> k.getCoordinates().matches("org\\.springframework\\.boot:.*:" + versionPattern);
return k -> k.getGav().matches("org\\.springframework\\.boot:.*:" + versionPattern);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


import org.junit.jupiter.api.Test;
import org.openrewrite.SourceFile;
import org.openrewrite.properties.PropertiesParser;
import org.openrewrite.properties.tree.Properties;
import org.springframework.sbm.parsers.RewriteExecutionContext;
Expand All @@ -39,10 +40,17 @@ void createNewProperties_Add_Print() {

@Test
void parseExistingPropertiesTest() {
List<Properties.File> parse = new PropertiesParser().parse(
"foo=bar\n" +
"bob=bill");
SpringBootApplicationProperties sut = new SpringBootApplicationProperties(Path.of("./projectDir").toAbsolutePath(), parse.get(0), new RewriteExecutionContext());
List<SourceFile> parse = new PropertiesParser()
.parse(
"""
foo=bar
bob=bill
"""
)
.toList();
Path absolutePath = Path.of("./projectDir").toAbsolutePath();
Properties.File propertiesFile = (Properties.File) parse.get(0);
SpringBootApplicationProperties sut = new SpringBootApplicationProperties(absolutePath, propertiesFile, new RewriteExecutionContext());
assertThat(sut.getProperty("foo").get()).isEqualTo("bar");
assertThat(sut.getProperty("bob").get()).isEqualTo("bill");
assertThat(sut.getProperty("jane")).isEmpty();
Expand Down

0 comments on commit 049155c

Please sign in to comment.