Skip to content

Commit

Permalink
Add more scenarios to JavaTypeGoat for simply typed fields and method…
Browse files Browse the repository at this point in the history
…s that return exceptions.
  • Loading branch information
jkschneider committed Dec 24, 2024
1 parent 321c93b commit 4ca0c8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.java;

import java.io.FileNotFoundException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

Expand All @@ -25,6 +26,8 @@ public abstract class JavaTypeGoat<T, S extends PT<S> & C> {

public static final PT<TypeA> parameterizedField = new PT<TypeA>() {
};
public static final Double PI = 3.14;
public static final double PI_PRIMITIVE = 3.14;

public static abstract class InheritedJavaTypeGoat<T, U extends PT<U> & C> extends JavaTypeGoat<T, U> {
public InheritedJavaTypeGoat() {
Expand Down Expand Up @@ -73,6 +76,9 @@ public static class TypeB {}
public abstract <U extends TypeA & PT<U> & C> U genericIntersection(U n);
public abstract T genericT(T n); // remove after signatures are common.
public abstract <U extends Extension<U> & Intersection<U>> void recursiveIntersection(U n);
public abstract <T> T nameShadow(T t);
public abstract void throwsException() throws FileNotFoundException;
public abstract <T extends FileNotFoundException> void throwsGenericException() throws T, InterruptedException;
}

interface C {
Expand Down
6 changes: 6 additions & 0 deletions rewrite-java-test/src/main/resources/JavaTypeGoat.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.java;

import java.io.FileNotFoundException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

Expand All @@ -25,6 +26,8 @@ public abstract class JavaTypeGoat<T, S extends PT<S> & C> {

public static final PT<TypeA> parameterizedField = new PT<TypeA>() {
};
public static final Double PI = 3.14;
public static final double PI_PRIMITIVE = 3.14;

public static abstract class InheritedJavaTypeGoat<T, U extends PT<U> & C> extends JavaTypeGoat<T, U> {
public InheritedJavaTypeGoat() {
Expand Down Expand Up @@ -73,6 +76,9 @@ public static class TypeB {}
public abstract <U extends TypeA & PT<U> & C> U genericIntersection(U n);
public abstract T genericT(T n); // remove after signatures are common.
public abstract <U extends JavaTypeGoat.Extension<U> & Intersection<U>> void recursiveIntersection(U n);
public abstract <T> T nameShadow(T t);
public abstract void throwsException() throws FileNotFoundException;
public abstract <T extends FileNotFoundException> void throwsGenericException() throws T, InterruptedException;
}

interface C {
Expand Down

0 comments on commit 4ca0c8e

Please sign in to comment.