Skip to content

Commit

Permalink
test: migrate TargetedExpressionTest to JUnit 5 (#4442)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Jan 11, 2022
1 parent f4892e3 commit 34261f1
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/test/java/spoon/test/targeted/TargetedExpressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@
*/
package spoon.test.targeted;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static spoon.testing.utils.ModelUtils.build;
import static spoon.testing.utils.ModelUtils.buildClass;

import java.util.List;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import spoon.Launcher;
import spoon.reflect.CtModel;
Expand Down Expand Up @@ -62,6 +55,14 @@
import spoon.test.targeted.testclasses.SuperClass;
import spoon.test.targeted.testclasses.Tapas;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static spoon.testing.utils.ModelUtils.build;
import static spoon.testing.utils.ModelUtils.buildClass;


public class TargetedExpressionTest {
@Test
Expand Down Expand Up @@ -107,8 +108,8 @@ public void testTargetOfFieldAccess() throws Exception {
final List<CtFieldAccess<?>> elements = constructor.getElements(new TypeFilter<>(CtFieldAccess.class));
assertEquals(2, elements.size());

assertSame("Target is CtThisAccessImpl if there is a 'this' explicit.", CtThisAccessImpl.class, elements.get(0).getTarget().getClass());
assertNotNull("Target isn't null if there is a 'this' explicit.", elements.get(1).getTarget());
assertSame(CtThisAccessImpl.class, elements.get(0).getTarget().getClass(), "Target is CtThisAccessImpl if there is a 'this' explicit.");
assertNotNull(elements.get(1).getTarget(), "Target isn't null if there is a 'this' explicit.");
assertTrue(elements.get(1).getTarget().isImplicit());
}

Expand Down Expand Up @@ -493,7 +494,7 @@ public void testUnqualifiedStaticMethodCallNoclasspath() {
CtModel model = launcher.buildModel();
List<CtTypeAccess<?>> typeAccesses = model.getElements(e -> e.getAccessedType().getSimpleName().equals("SomeClass"));

assertEquals("There should only be one reference to SomeClass, check the resource!", 1, typeAccesses.size());
assertEquals(1, typeAccesses.size(), "There should only be one reference to SomeClass, check the resource!");

CtPackageReference pkg = typeAccesses.get(0).getAccessedType().getPackage();

Expand Down

0 comments on commit 34261f1

Please sign in to comment.