|
178 | 178 | import com.tngtech.java.junit.dataprovider.UseDataProvider;
|
179 | 179 | import org.apache.logging.log4j.Level;
|
180 | 180 | import org.assertj.core.api.Condition;
|
| 181 | +import org.assertj.core.util.Objects; |
181 | 182 | import org.junit.After;
|
182 | 183 | import org.junit.Rule;
|
183 | 184 | import org.junit.Test;
|
@@ -663,9 +664,14 @@ public void imports_complex_method_with_correct_parameters() throws Exception {
|
663 | 664 | JavaClass clazz = classesIn("testexamples/complexmethodimport").get(ClassWithComplexMethod.class);
|
664 | 665 |
|
665 | 666 | assertThat(clazz.getMethods()).as("Methods of %s", ClassWithComplexMethod.class.getSimpleName()).hasSize(1);
|
666 |
| - assertThat(clazz.getMethod("complex", String.class, long.class, long.class, Serializable.class, Serializable.class)) |
667 |
| - .isEquivalentTo(ClassWithComplexMethod.class.getDeclaredMethod( |
668 |
| - "complex", String.class, long.class, long.class, Serializable.class, Serializable.class)); |
| 667 | + |
| 668 | + Class<?>[] parameterTypes = {String.class, long.class, long.class, Serializable.class, Serializable.class}; |
| 669 | + Method expectedMethod = ClassWithComplexMethod.class.getDeclaredMethod("complex", parameterTypes); |
| 670 | + |
| 671 | + assertThat(clazz.getMethod("complex", parameterTypes)).isEquivalentTo(expectedMethod); |
| 672 | + assertThat(clazz.tryGetMethod("complex", parameterTypes).get()).isEquivalentTo(expectedMethod); |
| 673 | + assertThat(clazz.getMethod("complex", Objects.namesOf(parameterTypes))).isEquivalentTo(expectedMethod); |
| 674 | + assertThat(clazz.tryGetMethod("complex", Objects.namesOf(parameterTypes)).get()).isEquivalentTo(expectedMethod); |
669 | 675 | }
|
670 | 676 |
|
671 | 677 | @Test
|
@@ -889,10 +895,16 @@ public void imports_simple_constructors_with_correct_parameters() throws Excepti
|
889 | 895 |
|
890 | 896 | assertThat(clazz.getConstructors()).as("Constructors").hasSize(3);
|
891 | 897 | assertThat(clazz.getConstructor()).isEquivalentTo(ClassWithSimpleConstructors.class.getDeclaredConstructor());
|
892 |
| - assertThat(clazz.getConstructor(Object.class)) |
893 |
| - .isEquivalentTo(ClassWithSimpleConstructors.class.getDeclaredConstructor(Object.class)); |
894 |
| - assertThat(clazz.getConstructor(int.class, int.class)) |
895 |
| - .isEquivalentTo(ClassWithSimpleConstructors.class.getDeclaredConstructor(int.class, int.class)); |
| 898 | + |
| 899 | + Class<?>[] parameterTypes = {Object.class}; |
| 900 | + Constructor<ClassWithSimpleConstructors> expectedConstructor = ClassWithSimpleConstructors.class.getDeclaredConstructor(parameterTypes); |
| 901 | + assertThat(clazz.getConstructor(parameterTypes)).isEquivalentTo(expectedConstructor); |
| 902 | + assertThat(clazz.getConstructor(Objects.namesOf(parameterTypes))).isEquivalentTo(expectedConstructor); |
| 903 | + |
| 904 | + parameterTypes = new Class[]{int.class, int.class}; |
| 905 | + expectedConstructor = ClassWithSimpleConstructors.class.getDeclaredConstructor(parameterTypes); |
| 906 | + assertThat(clazz.getConstructor(parameterTypes)).isEquivalentTo(expectedConstructor); |
| 907 | + assertThat(clazz.getConstructor(Objects.namesOf(parameterTypes))).isEquivalentTo(expectedConstructor); |
896 | 908 | }
|
897 | 909 |
|
898 | 910 | @Test
|
|
0 commit comments