Skip to content

Commit

Permalink
Reduce failing tests following upstream change
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Oct 14, 2024
1 parent 4092054 commit e009626
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
// Update or apply bean-discovery-mode=all
if (hasBeanDiscoveryMode) {
TreeVisitor<?, ExecutionContext> changeTagVisitor = new ChangeTagAttribute("beans", "bean-discovery-mode", "all", null, null).getVisitor();
t = (Xml.Tag) changeTagVisitor.visit(t, ctx, getCursor());
t = (Xml.Tag) changeTagVisitor.visit(t, ctx, getCursor().getParentOrThrow());
} else {
t = addAttribute(t, "bean-discovery-mode", "all", ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations m
// The javax.persistence.Column attributes length, precision, and scale are not kept.
maybeRemoveImport(COLUMN);
maybeAddImport(JOIN_COLUMN);
J.VariableDeclarations joinColumn = (J.VariableDeclarations) new ChangeType(COLUMN, JOIN_COLUMN, false).getVisitor().visit(multiVariable, ctx, getCursor());
joinColumn = (J.VariableDeclarations) new RemoveAnnotationAttribute(JOIN_COLUMN, "length").getVisitor().visit(joinColumn, ctx);
joinColumn = (J.VariableDeclarations) new RemoveAnnotationAttribute(JOIN_COLUMN, "precision").getVisitor().visit(joinColumn, ctx);
joinColumn = (J.VariableDeclarations) new RemoveAnnotationAttribute(JOIN_COLUMN, "scale").getVisitor().visit(joinColumn, ctx);
J.VariableDeclarations joinColumn = (J.VariableDeclarations) new ChangeType(COLUMN, JOIN_COLUMN, false).getVisitor().visit(multiVariable, ctx, getCursor().getParentOrThrow());
joinColumn = (J.VariableDeclarations) new RemoveAnnotationAttribute(JOIN_COLUMN, "length").getVisitor().visit(joinColumn, ctx, getCursor().getParentOrThrow());
joinColumn = (J.VariableDeclarations) new RemoveAnnotationAttribute(JOIN_COLUMN, "precision").getVisitor().visit(joinColumn, ctx, getCursor().getParentOrThrow());
joinColumn = (J.VariableDeclarations) new RemoveAnnotationAttribute(JOIN_COLUMN, "scale").getVisitor().visit(joinColumn, ctx, getCursor().getParentOrThrow());

return joinColumn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
private void insertRow(MethodAccess ma, ExecutionContext ctx, JavaType.Method methodType) {
methodCalls.insertRow(ctx, new MethodCalls.Row(
ma.getCursor().firstEnclosingOrThrow(SourceFile.class).getSourcePath().toString(),
ma.getTree().printTrimmed(ma.getCursor()),
ma.getTree().printTrimmed(ma.getCursor().getParentOrThrow()),
methodType.getDeclaringType().toString(),
methodType.getName(),
methodType.getParameterTypes().stream().map(String::valueOf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,32 @@ public void defaults(RecipeSpec spec) {
@DocumentExample
@Test
void scopeRequired() {
//language=java
rewriteRun(
java(
"""
package com.sample.service;
public class Bar {}
""",
"""
package com.sample.service;
import javax.enterprise.context.Dependent;
@Dependent
public class Bar {}
"""
),
java(
"""
package com.sample;
import javax.inject.Inject;
import com.sample.service.Bar;
public class Foo {
@Inject
Bar service;
}
Expand All @@ -86,25 +87,25 @@ public class Foo {
);
}


@Test
void noMemberVariableAnnotation() {
//language=java
rewriteRun(
java(
"""
package com.sample.service;
public class Bar {}
"""
),
java(
"""
package com.sample;
import com.sample.service.Bar;
public class Foo{
Bar service;
}
"""
Expand All @@ -114,21 +115,22 @@ public class Foo{

@Test
void nonInjectAnnotation() {
//language=java
rewriteRun(
java(
"""
package com.sample.service;
public class Bar {}
"""
),
java(
"""
package com.sample;
import com.sample.service.Bar;
import javax.inject.NotInject;
public class Foo{
@NotInject
Bar service;
Expand All @@ -138,9 +140,9 @@ public class Foo{
java(
"""
package javax.inject;
import java.lang.annotation.*;
@Target({ElementType.Type})
@Retention(RetentionPolicy.RUNTIME)
public @interface NotInject {
Expand All @@ -153,32 +155,32 @@ public class Foo{

@Test
void scopeAnnotationAlreadyExists() {
//language=java
rewriteRun(
java(
"""
package com.sample.service;
import javax.enterprise.context.Dependent;
@Dependent
public class Bar {}
"""
),
java(
"""
package com.sample;
import com.sample.service.Bar;
import javax.inject.Inject;
public class Foo {
@javax.inject.Inject
Bar service;
}
"""
)
);
}

}

0 comments on commit e009626

Please sign in to comment.