Skip to content

Commit 51f9ea6

Browse files
committed
polish formatting and remove unnecessery TestRuleToTestInfo import visitor.
1 parent 973d834 commit 51f9ea6

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

src/main/java/org/openrewrite/java/testing/junit5/AssertToAssertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
8080

8181
List<Expression> newArgs = new ArrayList<>(args.size());
8282
for (int i = 1; i < args.size(); i++) {
83-
if(i == 1) {
83+
if (i == 1) {
8484
newArgs.add(args.get(i).withPrefix(firstArg.getPrefix()));
8585
} else {
8686
newArgs.add(args.get(i));

src/main/java/org/openrewrite/java/testing/junit5/ParameterizedRunnerToParameterized.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ private static class ParameterizedRunnerVisitor extends JavaIsoVisitor<Execution
7272
public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext executionContext) {
7373
J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, executionContext);
7474
Map<String, Object> params = getCursor().pollMessage(classDecl.getId().toString());
75-
String parametersMethodName = params != null ? (String)params.get(PARAMETERS_METHOD_NAME) : null;
76-
List<Expression> parametersAnnotationArguments = params != null ? (List<Expression>)params.get(PARAMETERS_ANNOTATION_ARGUMENTS) : null;
77-
List<Statement> constructorParams = params != null ? (List<Statement>)params.get(CONSTRUCTOR_ARGUMENTS) : null;
78-
Map<Integer, Statement> fieldInjectionParams = params != null ? (Map<Integer, Statement>)params.get(FIELD_INJECTION_ARGUMENTS) : null;
75+
String parametersMethodName = params != null ? (String) params.get(PARAMETERS_METHOD_NAME) : null;
76+
List<Expression> parametersAnnotationArguments = params != null ? (List<Expression>) params.get(PARAMETERS_ANNOTATION_ARGUMENTS) : null;
77+
List<Statement> constructorParams = params != null ? (List<Statement>) params.get(CONSTRUCTOR_ARGUMENTS) : null;
78+
Map<Integer, Statement> fieldInjectionParams = params != null ? (Map<Integer, Statement>) params.get(FIELD_INJECTION_ARGUMENTS) : null;
7979
String initMethodName = "init" + cd.getSimpleName();
8080

8181
// Constructor Injected Test
@@ -95,7 +95,7 @@ else if (parametersMethodName != null && fieldInjectionParams != null) {
9595
public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext executionContext) {
9696
J.MethodDeclaration m = super.visitMethodDeclaration(method, executionContext);
9797
Cursor classDeclCursor = getCursor().dropParentUntil(J.ClassDeclaration.class::isInstance);
98-
Map<String, Object> params = classDeclCursor.computeMessageIfAbsent(((J.ClassDeclaration)classDeclCursor.getValue()).getId().toString(), v->new HashMap<>());
98+
Map<String, Object> params = classDeclCursor.computeMessageIfAbsent(((J.ClassDeclaration) classDeclCursor.getValue()).getId().toString(), v -> new HashMap<>());
9999
for (J.Annotation annotation : m.getLeadingAnnotations()) {
100100
if (PARAMETERS.matches(annotation)) {
101101
params.put(PARAMETERS_ANNOTATION_ARGUMENTS, annotation.getArguments());
@@ -113,7 +113,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
113113
public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations multiVariable, ExecutionContext executionContext) {
114114
J.VariableDeclarations variableDeclarations = super.visitVariableDeclarations(multiVariable, executionContext);
115115
Cursor classDeclCursor = getCursor().dropParentUntil(J.ClassDeclaration.class::isInstance);
116-
Map<String, Object> params = classDeclCursor.computeMessageIfAbsent(((J.ClassDeclaration)classDeclCursor.getValue()).getId().toString(), v -> new HashMap<>());
116+
Map<String, Object> params = classDeclCursor.computeMessageIfAbsent(((J.ClassDeclaration) classDeclCursor.getValue()).getId().toString(), v -> new HashMap<>());
117117
J.Annotation parameterAnnotation = variableDeclarations.getLeadingAnnotations().stream().filter(PARAMETER::matches).findFirst().orElse(null);
118118
if (parameterAnnotation != null) {
119119
Integer position = 0;

src/main/java/org/openrewrite/java/testing/junit5/TestRuleToTestInfo.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext execu
9494
return compilationUnit;
9595
}
9696

97-
@Override
98-
public J.Import visitImport(J.Import _import, ExecutionContext executionContext) {
99-
J.Import imp = super.visitImport(_import, executionContext);
100-
if (imp.getTypeName().equals(testNameType)) {
101-
//noinspection ConstantConditions
102-
return null;
103-
}
104-
return imp;
105-
}
106-
10797
@Override
10898
public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations multiVariable, ExecutionContext executionContext) {
10999
J.VariableDeclarations varDecls = super.visitVariableDeclarations(multiVariable, executionContext);
@@ -126,11 +116,11 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext executionC
126116
}
127117

128118
//FIXME. add TestMethod statements.
129-
// @Override
130-
// public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext executionContext) {
131-
// J.MethodDeclaration md = super.visitMethodDeclaration(method, executionContext);
132-
// return md;
133-
// }
119+
// @Override
120+
// public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext executionContext) {
121+
// J.MethodDeclaration md = super.visitMethodDeclaration(method, executionContext);
122+
// return md;
123+
// }
134124

135125
private boolean isBeforeAnnotation(J.Annotation annotation) {
136126
return TypeUtils.isOfClassType(annotation.getType(), "org.junit.Before") || TypeUtils.isOfClassType(annotation.getType(), "org.junit.jupiter.api.BeforeEach");

0 commit comments

Comments
 (0)