|
12 | 12 | import com.tngtech.archunit.core.importer.testexamples.methodresolution.OnlyDefinedInCommonAncestor; |
13 | 13 | import com.tngtech.archunit.core.importer.testexamples.methodresolution.OnlyLeftAncestorOverridesRootMethod; |
14 | 14 | import com.tngtech.archunit.core.importer.testexamples.methodresolution.OnlyRightAncestorOverridesRootMethod; |
15 | | -import com.tngtech.java.junit.dataprovider.DataProvider; |
16 | | -import com.tngtech.java.junit.dataprovider.DataProviderRunner; |
17 | | -import com.tngtech.java.junit.dataprovider.UseDataProvider; |
18 | | -import org.junit.Test; |
19 | | -import org.junit.runner.RunWith; |
| 15 | +import org.junit.jupiter.params.ParameterizedTest; |
| 16 | +import org.junit.jupiter.params.provider.ValueSource; |
20 | 17 |
|
21 | 18 | import static com.google.common.collect.Iterables.getOnlyElement; |
22 | 19 | import static com.tngtech.archunit.testutil.Assertions.assertThat; |
23 | | -import static com.tngtech.java.junit.dataprovider.DataProviders.testForEach; |
24 | 20 |
|
25 | | -@RunWith(DataProviderRunner.class) |
26 | 21 | public class ClassFileImporterAccessesNewerJavaVersionTest { |
27 | 22 |
|
28 | | - @DataProvider |
29 | | - public static Object[][] method_resolution_scenarios() { |
30 | | - return testForEach( |
31 | | - OnlyDefinedInCommonAncestor.class, |
32 | | - OnlyLeftAncestorOverridesRootMethod.class, |
33 | | - OnlyRightAncestorOverridesRootMethod.class, |
34 | | - LeftAncestorPrecedesRightAncestor.class, |
35 | | - ChildOverridesAllMethods.class, |
36 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftLeftHasPrecedence.class, |
37 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftRightHasPrecedenceOverRight.class, |
38 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.RightLeftHasPrecedenceOverRightRight.class, |
39 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.RightRightIsPickedIfThereIsNoAlternative.class, |
40 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftOverriddenHasPrecedenceOverParents.class, |
41 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.RightOverriddenHasPrecedenceOverParents.class, |
42 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftLeftHasPrecedenceOverOverriddenRight.class, |
43 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftRightHasPrecedenceOverOverriddenRight.class, |
44 | | - DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftOverriddenHasPrecedenceOverRightOverridden.class, |
45 | | - DeterminesMethodAnalogouslyToReflectionApi.ClassHasPrecedenceOverInterface.ParentClassHasPrecedenceOverChildInterfaces.class, |
46 | | - DeterminesMethodAnalogouslyToReflectionApi.ClassHasPrecedenceOverInterface.GrandParentClassHasPrecedenceOverChildInterfaces.class, |
47 | | - DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.LeftLeftOnGrandparentHasPrecedenceOverAllOthers.class, |
48 | | - DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.LeftRightOnGrandparentHasPrecedenceOverLeftOnParent.class, |
49 | | - DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.RightLeftOnGrandparentHasPrecedenceOverLeftAndRightOnParent.class, |
50 | | - DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.RightRightOnGrandparentHasPrecedenceOverLeftAndRightOnParent.class, |
51 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.RightWithMoreSpecificReturnOnParentTypeHasPrecedenceOverAllOthers.class, |
52 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.LeftWithMoreSpecificReturnTypeHasPrecedenceRightWithMoreSpecificReturnType.class, |
53 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.ParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverAllOthers.class, |
54 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.InterfaceWithMoreSpecificReturnTypeHasPrecedenceOverGrandParentClass.class, |
55 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.ParentInterfaceOnParentClassWithMoreSpecificReturnTypeHasPrecedenceOverGrandParentClass.class, |
56 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.GrandParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverAllOthers.class, |
57 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.GrandParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverFirstParentInterfaceWithMoreSpecificReturnType.class, |
58 | | - DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.GrandParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverAllParentInterfacesWithMoreSpecificReturnType.class, |
59 | | - DeterminesMethodAnalogouslyToReflectionApi.StaticMethodsInInterfacesAreIgnored.class |
60 | | - ); |
61 | | - } |
62 | | - |
63 | | - @Test |
64 | | - @UseDataProvider("method_resolution_scenarios") |
65 | | - public void resolves_method_call_targets(Class<?> scenario) throws NoSuchMethodException { |
| 23 | + @ParameterizedTest |
| 24 | + @ValueSource(classes = { |
| 25 | + OnlyDefinedInCommonAncestor.class, |
| 26 | + OnlyLeftAncestorOverridesRootMethod.class, |
| 27 | + OnlyRightAncestorOverridesRootMethod.class, |
| 28 | + LeftAncestorPrecedesRightAncestor.class, |
| 29 | + ChildOverridesAllMethods.class, |
| 30 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftLeftHasPrecedence.class, |
| 31 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftRightHasPrecedenceOverRight.class, |
| 32 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.RightLeftHasPrecedenceOverRightRight.class, |
| 33 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.RightRightIsPickedIfThereIsNoAlternative.class, |
| 34 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftOverriddenHasPrecedenceOverParents.class, |
| 35 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.RightOverriddenHasPrecedenceOverParents.class, |
| 36 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftLeftHasPrecedenceOverOverriddenRight.class, |
| 37 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftRightHasPrecedenceOverOverriddenRight.class, |
| 38 | + DeterminesMethodAnalogouslyToReflectionApi.EquivalentMethodsAreChosenDepthFirst.LeftOverriddenHasPrecedenceOverRightOverridden.class, |
| 39 | + DeterminesMethodAnalogouslyToReflectionApi.ClassHasPrecedenceOverInterface.ParentClassHasPrecedenceOverChildInterfaces.class, |
| 40 | + DeterminesMethodAnalogouslyToReflectionApi.ClassHasPrecedenceOverInterface.GrandParentClassHasPrecedenceOverChildInterfaces.class, |
| 41 | + DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.LeftLeftOnGrandparentHasPrecedenceOverAllOthers.class, |
| 42 | + DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.LeftRightOnGrandparentHasPrecedenceOverLeftOnParent.class, |
| 43 | + DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.RightLeftOnGrandparentHasPrecedenceOverLeftAndRightOnParent.class, |
| 44 | + DeterminesMethodAnalogouslyToReflectionApi.InterfaceOnParentHasPrecedenceOverInterfaceOnChild.RightRightOnGrandparentHasPrecedenceOverLeftAndRightOnParent.class, |
| 45 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.RightWithMoreSpecificReturnOnParentTypeHasPrecedenceOverAllOthers.class, |
| 46 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.LeftWithMoreSpecificReturnTypeHasPrecedenceRightWithMoreSpecificReturnType.class, |
| 47 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.ParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverAllOthers.class, |
| 48 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.InterfaceWithMoreSpecificReturnTypeHasPrecedenceOverGrandParentClass.class, |
| 49 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.ParentInterfaceOnParentClassWithMoreSpecificReturnTypeHasPrecedenceOverGrandParentClass.class, |
| 50 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.GrandParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverAllOthers.class, |
| 51 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.GrandParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverFirstParentInterfaceWithMoreSpecificReturnType.class, |
| 52 | + DeterminesMethodAnalogouslyToReflectionApi.MoreSpecificReturnTypeHasPrecedence.GrandParentInterfaceWithMoreSpecificReturnTypeHasPrecedenceOverAllParentInterfacesWithMoreSpecificReturnType.class, |
| 53 | + DeterminesMethodAnalogouslyToReflectionApi.StaticMethodsInInterfacesAreIgnored.class |
| 54 | + }) |
| 55 | + void resolves_method_call_targets(Class<?> scenario) throws NoSuchMethodException { |
66 | 56 | JavaMethod origin = new ClassFileImporter().importPackagesOf(scenario).get(scenario).getMethod("scenario"); |
67 | 57 |
|
68 | 58 | MethodCallTarget target = getOnlyElement(origin.getMethodCallsFromSelf()).getTarget(); |
|
0 commit comments