1 package org.opendaylight.controller.config.api;
3 import static org.mockito.Mockito.doNothing;
4 import static org.mockito.Mockito.doReturn;
5 import static org.mockito.Mockito.mock;
6 import static org.mockito.Mockito.verify;
8 import org.junit.Assert;
10 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
12 public class IdentityAttributeRefTest {
14 IdentityAttributeRef attr = new IdentityAttributeRef("attr");
17 public void testConstructor() throws Exception {
18 String param = new String("attr");
19 Assert.assertEquals(attr.getqNameOfIdentity(), param);
22 @Test(expected = NullPointerException.class)
23 public void testConstructor2() throws Exception {
24 IdentityAttributeRef attr = new IdentityAttributeRef(null);
28 public void testHashCode() throws Exception {
29 Assert.assertEquals(attr.hashCode(), new String("attr").hashCode());
33 public void testEqual() throws Exception {
34 Assert.assertEquals(attr, attr);
38 public void testEqual2() throws Exception {
39 Assert.assertEquals(attr, new IdentityAttributeRef("attr"));
43 public void testNotEqual() throws Exception {
44 Assert.assertNotEquals(attr, new IdentityAttributeRef("different"));
48 public void testResolveIdentity() throws Exception {
49 DependencyResolver res = mock(DependencyResolver.class);
50 IdentityAttributeRef a = new IdentityAttributeRef("abcd");
51 doReturn(SubIdentity.class).when(res).resolveIdentity(a, Identity.class);
52 a.resolveIdentity(res, Identity.class);
53 verify(res).resolveIdentity(a, Identity.class);
57 public void testValidateIdentity() throws Exception {
58 DependencyResolver res = mock(DependencyResolver.class);
59 JmxAttribute jmxAttr = new JmxAttribute("abc");
60 doNothing().when(res).validateIdentity(attr, Identity.class, jmxAttr);
61 attr.validateIdentity(res, Identity.class, jmxAttr);
62 verify(res).validateIdentity(attr, Identity.class, jmxAttr);
65 static class Identity extends BaseIdentity {}
67 static class SubIdentity extends Identity {}