Skip to content

Commit

Permalink
Fix SourceSpec#path docs and two test usages
Browse files Browse the repository at this point in the history
This sets the original source path, not the one after recipes are run. Adjust two tests to reflect this behavior, where they previously set the target path, resulting in the wrong path being passed to class visitors
  • Loading branch information
kennytv committed May 11, 2024
1 parent e66aae7 commit 20616ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,18 @@ public class Original {
public class Target {
}
""",
spec -> spec.path("a/b/Original.java").afterRecipe(cu -> {
assertThat(TypeUtils.isOfClassType(cu.getClasses().get(0).getType(), "x.y.Target")).isTrue();
})
),
java(
"""
package a.b;
public class NoMatch {
}
""",
spec -> spec.path("a/b/NoMatch.java").afterRecipe(cu -> {
assertThat(PathUtils.separatorsToUnix(cu.getSourcePath().toString())).isEqualTo("a/b/NoMatch.java");
assertThat(TypeUtils.isOfClassType(cu.getClasses().get(0).getType(), "x.y.Target")).isTrue();
})
)
);
Expand Down Expand Up @@ -1443,7 +1452,7 @@ class Z {
class D {
}
""",
spec -> spec.path("x/y/Z.java")
spec -> spec.path("a/b/C.java")
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Path getSourcePath() {
protected boolean noTrim = false;

/**
* @param sourcePath The source path after the recipe is run.
* @param sourcePath The source path before the recipe is run.
* @return This source spec.
*/
public SourceSpec<T> path(Path sourcePath) {
Expand All @@ -115,7 +115,7 @@ public SourceSpec<T> path(Path sourcePath) {
}

/**
* @param sourcePath The source path after the recipe is run.
* @param sourcePath The source path before the recipe is run.
* @return This source spec.
*/
public SourceSpec<T> path(String sourcePath) {
Expand Down

0 comments on commit 20616ac

Please sign in to comment.