Skip to content

Commit

Permalink
adding recipe for RemovedJakartaFacesExpressionLanguageClasses jakart…
Browse files Browse the repository at this point in the history
…a ee 10 (#309)

* adding recipe for RemovedJakartaFacesExpressionLanguageClasses jakarta_ee10

* adding formatting and Copyright update

* update description in .yml

* adding javax tests and updates

* formatted defaults(RecipeSpec spec)

---------

Co-authored-by: anuram <[email protected]>
  • Loading branch information
ranuradh and AnuRam123 authored Oct 6, 2023
1 parent cc6668d commit eaf1adc
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/main/resources/META-INF/rewrite/jakarta-ee-10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ recipeList:
- org.openrewrite.java.migrate.jakarta.RemovedIsParmetersProvidedMethod
- org.openrewrite.java.migrate.jakarta.RemovedSOAPElementFactory
- org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation
- org.openrewrite.java.migrate.jakarta.RemovedJakartaFacesExpressionLanguageClasses
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation
Expand Down Expand Up @@ -71,3 +72,76 @@ recipeList:
oldFullyQualifiedTypeName: jakarta.xml.soap.SOAPElementFactory
newFullyQualifiedTypeName: jakarta.xml.soap.SOAPFactory
ignoreDefinition: true
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.jakarta.RemovedJakartaFacesExpressionLanguageClasses
displayName: Use `jakarta.el instead of jakarta.faces.el and javax.faces.el`
description: >
Several classes were removed and replaced in Jakarta Faces 4.0.
The only Object definition not removed in the jakarta.faces.el package is the CompositeComponentExpressionHolder interface.
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.MethodBinding
newFullyQualifiedTypeName: jakarta.el.MethodExpression
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.PropertyResolver
newFullyQualifiedTypeName: jakarta.el.ELResolver
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.ValueBinding
newFullyQualifiedTypeName: jakarta.el.ValueExpression
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.VariableResolver
newFullyQualifiedTypeName: jakarta.el.ELResolver
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.EvaluationException
newFullyQualifiedTypeName: jakarta.el.ELException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.MethodNotFoundException
newFullyQualifiedTypeName: jakarta.el.MethodNotFoundException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.PropertyNotFoundException
newFullyQualifiedTypeName: jakarta.el.PropertyNotFoundException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.faces.el.ReferenceSyntaxException
newFullyQualifiedTypeName: jakarta.el.ELException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.MethodBinding
newFullyQualifiedTypeName: jakarta.el.MethodExpression
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.PropertyResolver
newFullyQualifiedTypeName: jakarta.el.ELResolver
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.ValueBinding
newFullyQualifiedTypeName: jakarta.el.ValueExpression
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.VariableResolver
newFullyQualifiedTypeName: jakarta.el.ELResolver
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.EvaluationException
newFullyQualifiedTypeName: jakarta.el.ELException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.MethodNotFoundException
newFullyQualifiedTypeName: jakarta.el.MethodNotFoundException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.PropertyNotFoundException
newFullyQualifiedTypeName: jakarta.el.PropertyNotFoundException
ignoreDefinition: true
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: javax.faces.el.ReferenceSyntaxException
newFullyQualifiedTypeName: jakarta.el.ELException
ignoreDefinition: true

Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
* Copyright 2023 the original author or authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.java.migrate.jakarta;

import org.junit.jupiter.api.Test;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.config.Environment;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;

public class RemovedJakartaFacesExpressionLanguageClassesTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.parser(JavaParser.fromJavaVersion()
.classpathFromResources(new InMemoryExecutionContext(), "jakarta.el-api-4.0.0","jakarta.faces-2.3.19", "jakarta.faces-3.0.3"))
.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.jakarta").build().activateRecipes("org.openrewrite.java.migrate.jakarta.RemovedJakartaFacesExpressionLanguageClasses"));
}

@Test
void removedExpressionLanguageTestJakarta_1() {
rewriteRun(
//language=java
java("""
package com.test;
import jakarta.faces.el.MethodBinding;
import jakarta.faces.el.PropertyResolver;
import jakarta.faces.el.ValueBinding;
public class Test {
public void testJakarta() {
MethodBinding methodBinding = null;
PropertyResolver propertyResolver = null;
ValueBinding valueBinding = null;
}
}
""", """
package com.test;
import jakarta.el.ELResolver;
import jakarta.el.MethodExpression;
import jakarta.el.ValueExpression;
public class Test {
public void testJakarta() {
MethodExpression methodBinding = null;
ELResolver propertyResolver = null;
ValueExpression valueBinding = null;
}
}
"""));
}

@Test
void removedExpressionLanguageTestJakarta_2() {
rewriteRun(
//language=java
java("""
package com.test;
import jakarta.faces.el.VariableResolver;
import jakarta.faces.el.EvaluationException;
import jakarta.faces.el.MethodNotFoundException;
import jakarta.faces.el.PropertyNotFoundException;
import jakarta.faces.el.ReferenceSyntaxException;
public class Test {
public void testJakarta_1() {
VariableResolver variableResolver = null;
EvaluationException evaluationException = null;
MethodNotFoundException methodNotFoundException = null;
PropertyNotFoundException propertyNotFoundException = null;
ReferenceSyntaxException referenceSyntaxException = null;
}
}
""", """
package com.test;
import jakarta.el.ELException;
import jakarta.el.ELResolver;
import jakarta.el.MethodNotFoundException;
import jakarta.el.PropertyNotFoundException;
public class Test {
public void testJakarta_1() {
ELResolver variableResolver = null;
ELException evaluationException = null;
MethodNotFoundException methodNotFoundException = null;
PropertyNotFoundException propertyNotFoundException = null;
ELException referenceSyntaxException = null;
}
}
"""));
}
@Test
void removedExpressionLanguageTestJavax_1() {
rewriteRun(
//language=java
java("""
package com.test;
import javax.faces.el.MethodBinding;
import javax.faces.el.PropertyResolver;
import javax.faces.el.ValueBinding;
public class Test {
public void testJavax() {
MethodBinding methodBinding = null;
PropertyResolver propertyResolver = null;
ValueBinding valueBinding = null;
}
}
""", """
package com.test;
import jakarta.el.ELResolver;
import jakarta.el.MethodExpression;
import jakarta.el.ValueExpression;
public class Test {
public void testJavax() {
MethodExpression methodBinding = null;
ELResolver propertyResolver = null;
ValueExpression valueBinding = null;
}
}
"""));
}

@Test
void removedExpressionLanguageTestJavax_2() {
rewriteRun(
//language=java
java("""
package com.test;
import javax.faces.el.VariableResolver;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodNotFoundException;
import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.ReferenceSyntaxException;
public class Test {
public void testJavax_1() {
VariableResolver variableResolver = null;
EvaluationException evaluationException = null;
MethodNotFoundException methodNotFoundException = null;
PropertyNotFoundException propertyNotFoundException = null;
ReferenceSyntaxException referenceSyntaxException = null;
}
}
""", """
package com.test;
import jakarta.el.ELException;
import jakarta.el.ELResolver;
import jakarta.el.MethodNotFoundException;
import jakarta.el.PropertyNotFoundException;
public class Test {
public void testJavax_1() {
ELResolver variableResolver = null;
ELException evaluationException = null;
MethodNotFoundException methodNotFoundException = null;
PropertyNotFoundException propertyNotFoundException = null;
ELException referenceSyntaxException = null;
}
}
"""));
}

}
Binary file not shown.
Binary file not shown.

0 comments on commit eaf1adc

Please sign in to comment.