import static org.opendaylight.mdsal.binding.spec.reflect.BindingReflections.findHierarchicalParent;
import com.google.common.util.concurrent.ListenableFuture;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.spec.util.FooChild;
+import org.opendaylight.mdsal.binding.spec.util.GroupingFoo;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.ChildOf;
BindingReflections.getModelRootPackageName("org.opendaylight.yang.gen.v1.test.rev990939"));
assertEquals("ModuleInfoClassName should be equal to string", "test.$YangModuleInfoImpl",
BindingReflections.getModuleInfoClassName("test"));
- assertEquals("Module info should be empty Set", Collections.EMPTY_SET,
+ assertEquals("Module info should be empty Set", Collections.emptySet(),
BindingReflections.loadModuleInfos());
assertFalse("Should not be RpcType", BindingReflections.isRpcType(DataObject.class));
- assertFalse("Should not be AugmentationChild", BindingReflections.isAugmentationChild(DataObject.class));
assertTrue("Should be BindingClass", BindingReflections.isBindingClass(DataObject.class));
assertFalse("Should not be Notification", BindingReflections.isNotification(DataObject.class));
assertNull(findHierarchicalParent(mock(DataObject.class)));
assertEquals(GroupingFoo.class, BindingReflections.findHierarchicalParent(FooChild.class));
final ChildOf<?> childOf = mock(FooChild.class);
- doReturn(FooChild.class).when(childOf).getImplementedInterface();
+ doReturn(FooChild.class).when(childOf).implementedInterface();
assertEquals(GroupingFoo.class, BindingReflections.findHierarchicalParent(childOf));
assertTrue(BindingReflections.isRpcMethod(TestImplementation.class.getDeclaredMethod("rpcMethodTest")));
assertEquals(TestImplementation.class, BindingReflections.findAugmentationTarget(TestImplementation.class));
assertFalse(BindingReflections.resolveRpcOutputClass(
TestImplementation.class.getDeclaredMethod("rpcMethodTest2")).isPresent());
- assertEquals(QName.create("test", "test"), BindingReflections.getQName(TestIdentity.class));
+ assertEquals(QName.create("test", "test"), BindingReflections.getQName(TestIdentity.VALUE));
}
- @Test(expected = UnsupportedOperationException.class)
- @SuppressWarnings({ "checkstyle:illegalThrows", "checkstyle:avoidHidingCauseException" })
- public void testPrivateConstructor() throws Throwable {
- assertFalse(BindingReflections.class.getDeclaredConstructor().isAccessible());
- final Constructor<?> constructor = BindingReflections.class.getDeclaredConstructor();
- constructor.setAccessible(true);
- try {
- constructor.newInstance();
- } catch (InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- private interface TestIdentity extends BaseIdentity {
- @SuppressWarnings("unused")
+ interface TestIdentity extends BaseIdentity {
QName QNAME = QName.create("test", "test");
+ TestIdentity VALUE = () -> TestIdentity.class;
+ @Override
+ Class<? extends TestIdentity> implementedInterface();
}
- private static final class TestImplementation implements Augmentation<TestImplementation>, RpcService {
- @SuppressWarnings("unused")
+ static final class TestImplementation implements Augmentation<TestImplementation>, RpcService {
public static final QName QNAME = QName.create("test", "test");
- @SuppressWarnings({ "unused", "static-method" })
+ @SuppressWarnings("static-method")
ListenableFuture<List<Object>> rpcMethodTest() {
return null;
}
- @SuppressWarnings({ "unused", "static-method" })
+ @SuppressWarnings("static-method")
ListenableFuture<?> rpcMethodTest2() {
return null;
}
+
+ @Override
+ public Class<TestImplementation> implementedInterface() {
+ return TestImplementation.class;
+ }
}
}
\ No newline at end of file