2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.spec.reflect;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import java.util.List;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.binding.Augmentation;
18 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.binding.RpcService;
21 import org.opendaylight.yangtools.yang.common.QName;
23 public class BindingReflectionsTest {
26 public void testBindingWithDummyObject() throws Exception {
27 assertEquals("ModuleInfoClassName should be equal to string", "test.$YangModuleInfoImpl",
28 BindingReflections.getModuleInfoClassName("test"));
29 assertFalse("Should not be RpcType", BindingReflections.isRpcType(DataObject.class));
30 assertTrue("Should be BindingClass", BindingReflections.isBindingClass(DataObject.class));
31 assertFalse("Should not be Notification", BindingReflections.isNotification(DataObject.class));
33 assertTrue(BindingReflections.isRpcMethod(TestImplementation.class.getDeclaredMethod("rpcMethodTest")));
34 assertEquals(TestImplementation.class, BindingReflections.findAugmentationTarget(TestImplementation.class));
36 assertEquals(QName.create("test", "test"), BindingReflections.getQName(TestIdentity.VALUE));
39 interface TestIdentity extends BaseIdentity {
40 QName QNAME = QName.create("test", "test");
41 TestIdentity VALUE = () -> TestIdentity.class;
44 Class<? extends TestIdentity> implementedInterface();
47 static final class TestImplementation implements Augmentation<TestImplementation>, RpcService {
48 public static final QName QNAME = QName.create("test", "test");
50 @SuppressWarnings("static-method")
51 ListenableFuture<List<Object>> rpcMethodTest() {
56 public Class<TestImplementation> implementedInterface() {
57 return TestImplementation.class;