case correction

This commit is contained in:
HARDEMAN Sébastien 2023-01-18 10:39:54 +01:00
parent 61b5922c60
commit 33474c6096

View File

@ -1,131 +1,127 @@
package com.baeldung.checkinterface; package com.baeldung.checkinterface;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ClassUtils;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.reflections.ReflectionUtils; import org.reflections.ReflectionUtils;
import org.reflections.Reflections; import org.reflections.Reflections;
import com.baeldung.checkinterface.ChildClass2; public class CheckInterfaceUnitTest {
import com.baeldung.checkinterface.ChildInterface2;
import com.baeldung.checkinterface.MasterInterface; protected static Reflections reflections;
public class CheckInterfaceUnitTest { @BeforeAll
public static void initializeReflectionsLibrary() {
protected static Reflections reflections;
reflections = new Reflections("com.baeldung.checkinterface");
@BeforeAll }
public static void initializeReflectionsLibrary() {
@Test
reflections = new Reflections("com.baeldung.checkInterface"); public void whenUsingReflectionGetInterfaces_thenDirectlyImplementedInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test List<Class<?>> interfaces = Arrays.asList(childClass2.getClass().getInterfaces());
public void whenUsingReflectionGetInterfaces_thenDirectlyImplementedInterfaceIsFound() {
assertTrue(interfaces.contains(ChildInterface2.class));
ChildClass2 childClass2 = new ChildClass2(); }
List<Class<?>> interfaces = Arrays.asList(childClass2.getClass().getInterfaces());
@Test
assertTrue(interfaces.contains(ChildInterface2.class)); public void whenUsingReflectionGetInterfaces_thenParentInterfaceIsNotFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test List<Class<?>> interfaces = Arrays.asList(childClass2.getClass().getInterfaces());
public void whenUsingReflectionGetInterfaces_thenParentInterfaceIsNotFound() {
assertFalse(interfaces.contains(MasterInterface.class));
ChildClass2 childClass2 = new ChildClass2(); }
List<Class<?>> interfaces = Arrays.asList(childClass2.getClass().getInterfaces());
@Test
assertFalse(interfaces.contains(MasterInterface.class)); public void whenUsingReflectionIsAssignableFrom_thenDirectlyImplementedInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test
public void whenUsingReflectionIsAssignableFrom_thenDirectlyImplementedInterfaceIsFound() { assertTrue(ChildInterface2.class.isAssignableFrom(childClass2.getClass()));
}
ChildClass2 childClass2 = new ChildClass2();
@Test
assertTrue(ChildInterface2.class.isAssignableFrom(childClass2.getClass())); public void whenUsingReflectionIsAssignableFrom_thenParentInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test
public void whenUsingReflectionIsAssignableFrom_thenParentInterfaceIsFound() { assertTrue(MasterInterface.class.isAssignableFrom(childClass2.getClass()));
}
ChildClass2 childClass2 = new ChildClass2();
@Test
assertTrue(MasterInterface.class.isAssignableFrom(childClass2.getClass())); public void whenUsingReflectionIsInstance_thenDirectlyImplementedInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test
public void whenUsingReflectionIsInstance_thenDirectlyImplementedInterfaceIsFound() { assertTrue(ChildInterface2.class.isInstance(childClass2));
}
ChildClass2 childClass2 = new ChildClass2();
@Test
assertTrue(ChildInterface2.class.isInstance(childClass2)); public void whenUsingReflectionIsInstance_thenParentInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test
public void whenUsingReflectionIsInstance_thenParentInterfaceIsFound() { assertTrue(MasterInterface.class.isInstance(childClass2));
}
ChildClass2 childClass2 = new ChildClass2();
@Test
assertTrue(MasterInterface.class.isInstance(childClass2)); public void whenUsingReflectionInstanceOf_thenDirectlyImplementedInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test
public void whenUsingReflectionInstanceOf_thenDirectlyImplementedInterfaceIsFound() { assertTrue(childClass2 instanceof ChildInterface2);
}
ChildClass2 childClass2 = new ChildClass2();
@Test
assertTrue(childClass2 instanceof ChildInterface2); public void whenUsingReflectionInstanceOf_thenParentInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test
public void whenUsingReflectionInstanceOf_thenParentInterfaceIsFound() { assertTrue(childClass2 instanceof MasterInterface);
}
ChildClass2 childClass2 = new ChildClass2();
@Test
assertTrue(childClass2 instanceof MasterInterface); public void whenUsingCommons_thenDirectlyImplementedInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test List<Class<?>> interfaces = ClassUtils.getAllInterfaces(childClass2.getClass());
public void whenUsingCommons_thenDirectlyImplementedInterfaceIsFound() {
assertTrue(interfaces.contains(ChildInterface2.class));
ChildClass2 childClass2 = new ChildClass2(); }
List<Class<?>> interfaces = ClassUtils.getAllInterfaces(childClass2.getClass());
@Test
assertTrue(interfaces.contains(ChildInterface2.class)); public void whenUsingCommons_thenParentInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test List<Class<?>> interfaces = ClassUtils.getAllInterfaces(childClass2.getClass());
public void whenUsingCommons_thenParentInterfaceIsFound() {
assertTrue(interfaces.contains(MasterInterface.class));
ChildClass2 childClass2 = new ChildClass2(); }
List<Class<?>> interfaces = ClassUtils.getAllInterfaces(childClass2.getClass());
@Test
assertTrue(interfaces.contains(MasterInterface.class)); public void whenUsingReflections_thenDirectlyImplementedInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test Set<Class<?>> interfaces = reflections.get(ReflectionUtils.Interfaces.of(childClass2.getClass()));
public void whenUsingReflections_thenDirectlyImplementedInterfaceIsFound() {
assertTrue(interfaces.contains(ChildInterface2.class));
ChildClass2 childClass2 = new ChildClass2(); }
Set<Class<?>> interfaces = reflections.get(ReflectionUtils.Interfaces.of(childClass2.getClass()));
@Test
assertTrue(interfaces.contains(ChildInterface2.class)); public void whenUsingReflections_thenParentInterfaceIsFound() {
}
ChildClass2 childClass2 = new ChildClass2();
@Test Set<Class<?>> interfaces = reflections.get(ReflectionUtils.Interfaces.of(childClass2.getClass()));
public void whenUsingReflections_thenParentInterfaceIsFound() {
assertTrue(interfaces.contains(MasterInterface.class));
ChildClass2 childClass2 = new ChildClass2(); }
Set<Class<?>> interfaces = reflections.get(ReflectionUtils.Interfaces.of(childClass2.getClass())); }
assertTrue(interfaces.contains(MasterInterface.class));
}
}