Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/spoon/testing/AbstractAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/AbstractAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.SpoonException;
import spoon.processing.Processor;
Expand All @@ -20,7 +20,9 @@
* the self type of this assertion class.
* @param <A>
* the type of the actual value.
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public abstract class AbstractAssert<T extends AbstractAssert<T, A>, A> {
protected final LinkedList<Processor<?>> processors = new LinkedList<>();
protected final A actual;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/spoon/testing/AbstractCtElementAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.reflect.declaration.CtElement;

import static spoon.testing.utils.Check.assertCtElementEquals;

Check failure on line 12 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.Check.assertNotNull;

Check failure on line 13 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.Check.assertIsSame;

Check failure on line 14 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.ProcessorUtils.process;

Check failure on line 15 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

/**
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public abstract class AbstractCtElementAssert<T extends AbstractCtElementAssert<T>> extends AbstractAssert<T, CtElement> {

Check failure on line 21 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
protected AbstractCtElementAssert(CtElement actual, Class<?> selfType) {
super(actual, selfType);
}
Expand All @@ -28,14 +32,14 @@
*/
public T isEqualTo(CtElement expected) {
assertNotNull(expected);
assertIsSame(actual, expected);

Check failure on line 35 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

process(actual.getFactory(), processors);

Check failure on line 37 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

Check failure on line 37 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

// using the new method to have a nice error message
assertCtElementEquals(expected, actual);

Check failure on line 40 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

return this.myself;

Check failure on line 42 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}

/**
Expand All @@ -48,11 +52,11 @@
public T isEqualTo(String expected) {
assertNotNull(expected);

process(actual.getFactory(), processors);

Check failure on line 55 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

Check failure on line 55 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

if (!actual.toString().equals(expected)) {

Check failure on line 57 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
throw new AssertionError(String.format("%1$s and %2$s aren't equals.", actual.getShortRepresentation(), expected));

Check failure on line 58 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}
return this.myself;

Check failure on line 60 in src/main/java/spoon/testing/AbstractCtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}
}
4 changes: 4 additions & 0 deletions src/main/java/spoon/testing/AbstractCtPackageAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtType;
Expand All @@ -15,11 +15,15 @@
import java.util.Comparator;
import java.util.List;

import static spoon.testing.Assert.assertThat;

Check failure on line 18 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

Check failure on line 18 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.Assert' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.Check.assertNotNull;

Check failure on line 19 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.ProcessorUtils.process;

Check failure on line 20 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

/**
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public abstract class AbstractCtPackageAssert<T extends AbstractCtPackageAssert<T>> extends AbstractAssert<T, CtPackage> {

Check failure on line 26 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
protected AbstractCtPackageAssert(CtPackage actual, Class<?> selfType) {
super(actual, selfType);
}
Expand All @@ -34,12 +38,12 @@
public T isEqualTo(CtPackage expected) {
assertNotNull(expected);

if (!actual.getSimpleName().equals(expected.getSimpleName())) {

Check failure on line 41 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
throw new AssertionError(String.format("The actual package named %1$s isn't equals to the expected package named %2$s", actual.getSimpleName(), expected.getSimpleName()));

Check failure on line 42 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}

if (processors != null && !processors.isEmpty()) {

Check failure on line 45 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

Check failure on line 45 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
process(actual.getFactory(), processors);

Check failure on line 46 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal

Check failure on line 46 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}

class TypeComparator implements Comparator<CtType<?>> {
Expand All @@ -49,11 +53,11 @@
}
}

final List<CtType<?>> actualTypes = new ArrayList<>(actual.getTypes());

Check failure on line 56 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
Collections.sort(actualTypes, new TypeComparator());
final List<CtType<?>> expectedTypes = new ArrayList<>(expected.getTypes());
Collections.sort(expectedTypes, new TypeComparator());
for (int i = 0; i < actual.getTypes().size(); i++) {

Check failure on line 60 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
final CtType<?> actualType = actualTypes.get(i);
final CtType<?> expectedType = expectedTypes.get(i);
if (!actualType.toString().equals(expectedType.toString())) {
Expand All @@ -68,7 +72,7 @@
}
}

final List<CtPackage> actualPackages = new ArrayList<>(actual.getPackages());

Check failure on line 75 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
Collections.sort(actualPackages, new PackageComparator());
final List<CtPackage> expectedPackages = new ArrayList<>(expected.getPackages());
Collections.sort(expectedPackages, new PackageComparator());
Expand All @@ -76,9 +80,9 @@
for (int i = 0; i < actualPackages.size(); i++) {
final CtPackage actualPackage = actualPackages.get(i);
final CtPackage expectedPackage = expectedPackages.get(i);
assertThat(actualPackage).isEqualTo(expectedPackage);

Check failure on line 83 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.Assert' is deprecated since version 11 and marked for removal
}

return this.myself;

Check failure on line 86 in src/main/java/spoon/testing/AbstractCtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}
}
4 changes: 4 additions & 0 deletions src/main/java/spoon/testing/AbstractFileAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.reflect.declaration.CtType;
import spoon.reflect.factory.Factory;
Expand All @@ -13,12 +13,16 @@
import java.io.File;
import java.util.List;

import static spoon.testing.utils.Check.assertExists;

Check failure on line 16 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.Check.assertNotNull;

Check failure on line 17 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.ModelUtils.build;

Check failure on line 18 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.ProcessorUtils.process;

Check failure on line 19 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

/**
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public abstract class AbstractFileAssert<T extends AbstractFileAssert<T>> extends AbstractAssert<T, File> {

Check failure on line 25 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
public AbstractFileAssert(File actual, Class<?> selfType) {
super(actual, selfType);
}
Expand All @@ -45,10 +49,10 @@
assertNotNull(expected);
assertExists(expected);

final Factory actualFactory = build(actual);

Check failure on line 52 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
final Factory expectedFactory = build(expected);

process(actualFactory, processors);

Check failure on line 55 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
final List<CtType<?>> allActual = actualFactory.Type().getAll();
final List<CtType<?>> allExpected = expectedFactory.Type().getAll();
for (int i = 0; i < allActual.size(); i++) {
Expand All @@ -58,6 +62,6 @@
throw new AssertionError(String.format("%1$s and %2$s aren't equals.", currentActual.getQualifiedName(), currentExpected.getQualifiedName()));
}
}
return this.myself;

Check failure on line 65 in src/main/java/spoon/testing/AbstractFileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractAssert' is deprecated since version 11 and marked for removal
}
}
3 changes: 3 additions & 0 deletions src/main/java/spoon/testing/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,53 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtPackage;

import java.io.File;

import static spoon.testing.utils.Check.assertExists;

Check failure on line 15 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
import static spoon.testing.utils.Check.assertNotNull;

Check failure on line 16 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

/**
* Entry point for assertion methods for different data types.
* Each method in this class is a static factory for the type-specific
* assertion objects. The purpose of this class is to make test code
* more readable.
*
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public class Assert {
private Assert() { }
/**
* Create a new instance of <code>{@link FileAssert}</code>.

Check failure on line 30 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.FileAssert' is deprecated since version 11 and marked for removal
*
* @param actual
* The actual value.
* @return the created assertion object.
*/
public static AbstractFileAssert<?> assertThat(String actual) {

Check failure on line 36 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractFileAssert' is deprecated since version 11 and marked for removal
return assertThat(new File(actual));
}

/**
* Create a new instance of <code>{@link FileAssert}</code>.

Check failure on line 41 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.FileAssert' is deprecated since version 11 and marked for removal
*
* @param actual
* The actual value.
* @return the created assertion object.
*/
public static AbstractFileAssert<?> assertThat(File actual) {

Check failure on line 47 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractFileAssert' is deprecated since version 11 and marked for removal
assertNotNull(actual);
assertExists(actual);
return new FileAssert(actual);

Check failure on line 50 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.FileAssert' is deprecated since version 11 and marked for removal
}

/**
* Create a new instance of <code>{@link CtElementAssert}</code>.

Check failure on line 54 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.CtElementAssert' is deprecated since version 11 and marked for removal
* Note that a package typed by CtElement will call this method and
* not {@link Assert#assertThat(CtPackage)}.
*
Expand All @@ -56,13 +59,13 @@
* The actual value.
* @return the created assertion object.
*/
public static AbstractCtElementAssert<?> assertThat(CtElement actual) {

Check failure on line 62 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractCtElementAssert' is deprecated since version 11 and marked for removal
assertNotNull(actual);
return new CtElementAssert(actual);

Check failure on line 64 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.CtElementAssert' is deprecated since version 11 and marked for removal
}

/**
* Create a new instance of <code>{@link CtPackageAssert}</code>.

Check failure on line 68 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.CtPackageAssert' is deprecated since version 11 and marked for removal
* Note that this assert will be make a deep equals with its content
* (all types).
*
Expand All @@ -70,8 +73,8 @@
* The actual value.
* @return the created assertion object.
*/
public static AbstractCtPackageAssert<?> assertThat(CtPackage actual) {

Check failure on line 76 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractCtPackageAssert' is deprecated since version 11 and marked for removal
assertNotNull(actual);
return new CtPackageAssert(actual);

Check failure on line 78 in src/main/java/spoon/testing/Assert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.CtPackageAssert' is deprecated since version 11 and marked for removal
}
}
4 changes: 4 additions & 0 deletions src/main/java/spoon/testing/CtElementAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/CtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.reflect.declaration.CtElement;

/**
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public class CtElementAssert extends AbstractCtElementAssert<CtElementAssert> {

Check failure on line 16 in src/main/java/spoon/testing/CtElementAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractCtElementAssert' is deprecated since version 11 and marked for removal
protected CtElementAssert(CtElement actual) {
super(actual, CtElementAssert.class);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/spoon/testing/CtPackageAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/CtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import spoon.reflect.declaration.CtPackage;

/**
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public class CtPackageAssert extends AbstractCtPackageAssert<CtPackageAssert> {

Check failure on line 16 in src/main/java/spoon/testing/CtPackageAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractCtPackageAssert' is deprecated since version 11 and marked for removal
public CtPackageAssert(CtPackage actual) {
super(actual, CtPackageAssert.class);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/spoon/testing/FileAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.testing;

Check failure on line 8 in src/main/java/spoon/testing/FileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal

import java.io.File;

/**
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
public class FileAssert extends AbstractFileAssert<FileAssert> {

Check failure on line 16 in src/main/java/spoon/testing/FileAssert.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing.AbstractFileAssert' is deprecated since version 11 and marked for removal
public FileAssert(File actual) {
super(actual, FileAssert.class);
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/spoon/testing/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* SPDX-License-Identifier: (MIT OR CECILL-C)
*
* Copyright (C) 2006-2023 INRIA and contributors
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
/**
* Deprecated assertion classes for Spoon elements.
*
* <p>Use {@code spoon.testing.assertions.SpoonAssertions} instead, which provides
* AssertJ-based fluent assertions for all Spoon types. Example:
* <pre>
* import static spoon.testing.assertions.SpoonAssertions.assertThat;
* assertThat(myCtClass).isEqualTo(otherCtClass);
* </pre>
*
* @deprecated Use {@code spoon.testing.assertions.SpoonAssertions} instead.
*/
@Deprecated(since = "11", forRemoval = true)
package spoon.testing;

Check failure on line 21 in src/main/java/spoon/testing/package-info.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM (./src/main/java)

Usage of API marked for removal

'spoon.testing' is deprecated since version 11 and marked for removal
2 changes: 1 addition & 1 deletion src/test/java/spoon/processing/CtGenerationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static spoon.testing.Assert.assertThat;
import static spoon.testing.assertions.SpoonAssertions.assertThat;
import static spoon.testing.utils.ModelUtils.build;

public class CtGenerationTest {
Expand Down
36 changes: 24 additions & 12 deletions src/test/java/spoon/processing/ProcessingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package spoon.processing;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import spoon.Launcher;
Expand All @@ -29,16 +30,22 @@
import spoon.test.processing.processors.MyProcessor;
import spoon.test.template.testclasses.AssertToIfAssertedStatementTemplate;

import spoon.reflect.declaration.CtType;
import spoon.reflect.factory.Factory;
import spoon.testing.utils.ModelTest;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static spoon.testing.Assert.assertThat;
import static spoon.testing.assertions.SpoonAssertions.assertThat;
import static spoon.testing.utils.ModelUtils.build;

public class ProcessingTest {

Expand Down Expand Up @@ -129,9 +136,9 @@ public void testNullPointerException() throws IOException {
l.setSourceOutputDirectory(path.toFile());
l.run();
}
@Test
public void testTemplateNotInOutput() throws IOException {

@ModelTest("src/test/resources/spoon/test/template/SimpleIfAsserted.java")
public void testTemplateNotInOutput(Factory expectedFactory) throws IOException {
// https://github.com/INRIA/spoon/issues/2987
class AssertProcessor extends AbstractProcessor<CtAssert<?>> {
public void process(CtAssert<?> element) {
Expand All @@ -141,24 +148,29 @@ public void process(CtAssert<?> element) {
);
}
}

String templatePath = "src/test/java/spoon/test/template/testclasses/AssertToIfAssertedStatementTemplate.java";
String resourcePath = "src/test/resources/spoon/test/template/";

final Launcher l = new Launcher();
Path outputPath = Files.createTempDirectory("emptydir");

l.addProcessor(new AssertProcessor());
l.addTemplateResource(new FileSystemFile(templatePath));

l.addInputResource(resourcePath + "SimpleAssert.java");
l.setSourceOutputDirectory(outputPath.toFile());
l.run();

// If template is applied to itself then there will be modified spoon/...Template.java on output
assertArrayEquals(new String[]{"SimpleAssert.java"}, outputPath.toFile().list(), "Template source found in output");
Assertions.assertThat(outputPath.toFile().list())
.containsExactly("SimpleAssert.java");
// Check that the template worked as intended
assertThat(outputPath.toString() + "/SimpleAssert.java")
.isEqualTo(resourcePath + "SimpleIfAsserted.java");
List<CtType<?>> actualTypes = build(new File(outputPath.toString() + "/SimpleAssert.java")).Type().getAll();
List<CtType<?>> expectedTypes = expectedFactory.Type().getAll();
Assertions.assertThat(actualTypes).hasSameSizeAs(expectedTypes);
for (int i = 0; i < actualTypes.size(); i++) {
assertThat(actualTypes.get(i)).isEqualTo(expectedTypes.get(i));
}
}
}
2 changes: 1 addition & 1 deletion src/test/java/spoon/support/TypeAdaptorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static spoon.testing.Assert.assertThat;
import static spoon.testing.assertions.SpoonAssertions.assertThat;

class TypeAdaptorTest {

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/spoon/test/fieldaccesses/FieldAccessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static spoon.testing.Assert.assertThat;
import static spoon.testing.assertions.SpoonAssertions.assertThat;
import static spoon.testing.utils.ModelUtils.build;
import static spoon.testing.utils.ModelUtils.buildClass;

Expand Down Expand Up @@ -332,7 +332,7 @@ public void testTypeDeclaredInAnonymousClass() throws Exception {

assertEquals(1, elements.size());
assertTrue(elements.get(0).getType().getDeclaringType().isAnonymous());
assertThat(elements.get(0)).isEqualTo("private final Test test = new Test();");
assertThat(elements.get(0)).hasToString("private final Test test = new Test();");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/pkg/PackageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static spoon.testing.Assert.assertThat;
import static spoon.testing.assertions.SpoonAssertions.assertThat;
import static spoon.testing.utils.ModelUtils.canBeBuilt;
import static spoon.testing.utils.ModelUtils.createFactory;

Expand Down
43 changes: 22 additions & 21 deletions src/test/java/spoon/testing/AbstractAssertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,43 @@
*/
package spoon.testing;

import org.junit.jupiter.api.Test;
import org.assertj.core.api.Assertions;
import spoon.processing.AbstractProcessor;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtType;
import spoon.reflect.factory.Factory;
import spoon.testing.processors.FooToBarProcessor;
import spoon.testing.utils.ByClass;
import spoon.testing.utils.ModelTest;
import spoon.testing.utils.ProcessorUtils;

import static spoon.testing.Assert.assertThat;
import static spoon.testing.utils.ModelUtils.buildNoClasspath;
import java.io.File;
import java.util.List;

public class AbstractAssertTest {
public static final String PATH = "./src/test/java/spoon/testing/testclasses/";

@Test
public void testTransformationWithProcessorInstantiated() {
assertThat(PATH + "Foo.java").withProcessor(new FooToBarProcessor()).isEqualTo(PATH + "Bar.java");
}
import static spoon.testing.assertions.SpoonAssertions.assertThat;
import static spoon.testing.utils.ModelUtils.build;

@Test
public void testTransformationWithProcessorClass() {
assertThat(PATH + "Foo.java").withProcessor(FooToBarProcessor.class).isEqualTo(PATH + "Bar.java");
}
public class AbstractAssertTest {

@Test
public void testTransformationWithProcessorName() {
assertThat(PATH + "Foo.java").withProcessor(FooToBarProcessor.class.getName()).isEqualTo(PATH + "Bar.java");
@ModelTest("./src/test/java/spoon/testing/testclasses/Foo.java")
public void testTransformationWithProcessor(Factory actual) {
ProcessorUtils.process(actual, List.of(new FooToBarProcessor()));
List<CtType<?>> actualTypes = actual.Type().getAll();
List<CtType<?>> expectedTypes = build(new File("./src/test/java/spoon/testing/testclasses/Bar.java")).Type().getAll();
Assertions.assertThat(actualTypes).containsExactlyElementsOf(expectedTypes);
}

@Test
public void testTransformationFromCtElementWithProcessor() throws Exception {
@ModelTest("./src/test/java/spoon/testing/CtElementAssertTest.java")
public void testTransformationFromCtElementWithProcessor(
@ByClass(CtElementAssertTest.class) CtType<CtElementAssertTest> type, Factory factory) throws Exception {
class MyProcessor extends AbstractProcessor<CtField<?>> {
@Override
public void process(CtField<?> element) {
element.setSimpleName("j");
}
}
final CtType<CtElementAssertTest> type = buildNoClasspath(CtElementAssertTest.class).Type().get(CtElementAssertTest.class);
assertThat(type.getField("i")).withProcessor(new MyProcessor()).isEqualTo("public int j;");
CtField<?> field = type.getField("i");
ProcessorUtils.process(factory, List.of(new MyProcessor()));
Assertions.assertThat(field.toString()).isEqualTo("public int j;");
}
}
41 changes: 22 additions & 19 deletions src/test/java/spoon/testing/CtElementAssertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,25 @@
*/
package spoon.testing;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import spoon.reflect.code.CtFieldAccess;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.factory.Factory;
import spoon.testing.utils.ByClass;
import spoon.testing.utils.ModelTest;

import static org.junit.jupiter.api.Assertions.assertThrows;
import static spoon.testing.Assert.assertThat;
import static spoon.testing.utils.ModelUtils.buildNoClasspath;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static spoon.testing.assertions.SpoonAssertions.assertThat;
import static spoon.testing.utils.ModelUtils.createFactory;

public class CtElementAssertTest {
public int i;

@Test
public void testEqualityBetweenTwoCtElement() throws Exception {
final CtType<CtElementAssertTest> type = buildNoClasspath(CtElementAssertTest.class).Type().get(CtElementAssertTest.class);
@ModelTest("./src/test/java/spoon/testing/CtElementAssertTest.java")
public void testEqualityBetweenTwoCtElement(@ByClass(CtElementAssertTest.class) CtType<CtElementAssertTest> type) throws Exception {
final Factory factory = createFactory();
final CtField<Integer> expected = factory.Core().createField();
expected.setSimpleName("i");
Expand All @@ -43,29 +44,31 @@ public void testEqualityBetweenTwoCtElement() throws Exception {
assertThat(f).isEqualTo(expected);
}

@Test
public void testEqualityBetweenACtElementAndAString() throws Exception {
final CtType<CtElementAssertTest> type = buildNoClasspath(CtElementAssertTest.class).Type().get(CtElementAssertTest.class);
assertThat(type.getField("i")).isEqualTo("public int i;");
@ModelTest("./src/test/java/spoon/testing/CtElementAssertTest.java")
public void testEqualityBetweenACtElementAndAString(@ByClass(CtElementAssertTest.class) CtType<CtElementAssertTest> type) throws Exception {
Assertions.assertThat(type.getField("i").toString()).isEqualTo("public int i;");
}

@Test
public void testEqualityBetweenTwoCtElementWithTypeDifferent() {
assertThrows(AssertionError.class, ()-> assertThat(createFactory().Core().createAnnotation()).isEqualTo(createFactory().Core().createBlock()));
assertThatThrownBy(() -> assertThat(createFactory().Core().createAnnotation()).isEqualTo(createFactory().Core().createBlock()))
.isInstanceOf(AssertionError.class);
}

@Test
public void testEqualityBetweenTwoCtElementWithTheSameSignatureButNotTheSameContent() throws Exception {
assertThrows(AssertionError.class, ()-> assertThat(buildNoClasspath(CtElementAssertTest.class).Type().get(CtElementAssertTest.class)).isEqualTo(createFactory().Class().create(CtElementAssertTest.class.getName())));
@ModelTest("./src/test/java/spoon/testing/CtElementAssertTest.java")
public void testEqualityBetweenTwoCtElementWithTheSameSignatureButNotTheSameContent(
@ByClass(CtElementAssertTest.class) CtType<CtElementAssertTest> actual, Factory factory) {
assertThatThrownBy(() -> assertThat(actual).isEqualTo(factory.Class().create(CtElementAssertTest.class.getName())))
.isInstanceOf(AssertionError.class);
}

@Test
public void testEqualityBetweenTwoDifferentCtElement() throws Exception {
@ModelTest("./src/test/java/spoon/testing/CtElementAssertTest.java")
public void testEqualityBetweenTwoDifferentCtElement(Factory factory) throws Exception {
class String {
}
final Factory build = buildNoClasspath(CtElementAssertTest.class);
final CtFieldAccess<Class<String>> actual = build.Code().createClassAccess(build.Type().<String>get(String.class).getReference());
final CtFieldAccess<Class<String>> actual = factory.Code().createClassAccess(factory.Type().<String>get(String.class).getReference());
final CtFieldAccess<Class<java.lang.String>> expected = createFactory().Code().createClassAccess(createFactory().Type().stringType());
assertThrows(AssertionError.class, ()-> assertThat(actual).isEqualTo(expected));
assertThatThrownBy(() -> assertThat(actual).isEqualTo(expected))
.isInstanceOf(AssertionError.class);
}
}
Loading
Loading