Remove raw references to Map in XSQL
[controller.git] / opendaylight / config / config-api / src / test / java / org / opendaylight / controller / config / api / IdentityAttributeRefTest.java
1 package org.opendaylight.controller.config.api;
2
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;
7 import org.junit.Assert;
8 import org.junit.Test;
9 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
10
11 public class IdentityAttributeRefTest {
12
13     IdentityAttributeRef attr = new IdentityAttributeRef("attr");
14
15     @Test
16     public void testConstructor() throws Exception {
17         String param = new String("attr");
18         Assert.assertEquals(attr.getqNameOfIdentity(), param);
19     }
20
21     @Test(expected = NullPointerException.class)
22     public void testConstructor2() throws Exception {
23         IdentityAttributeRef attr = new IdentityAttributeRef(null);
24     }
25
26     @Test
27     public void testHashCode() throws Exception {
28         Assert.assertEquals(attr.hashCode(), new String("attr").hashCode());
29     }
30
31     @Test
32     public void testEqual() throws Exception {
33         Assert.assertEquals(attr, attr);
34     }
35
36     @Test
37     public void testEqual2() throws Exception {
38         Assert.assertEquals(attr, new IdentityAttributeRef("attr"));
39     }
40
41     @Test
42     public void testNotEqual() throws Exception {
43         Assert.assertNotEquals(attr, new IdentityAttributeRef("different"));
44     }
45
46     @Test
47     public void testResolveIdentity() throws Exception {
48         DependencyResolver res = mock(DependencyResolver.class);
49         IdentityAttributeRef a = new IdentityAttributeRef("abcd");
50         doReturn(SubIdentity.class).when(res).resolveIdentity(a, Identity.class);
51         a.resolveIdentity(res, Identity.class);
52         verify(res).resolveIdentity(a, Identity.class);
53     }
54
55     @Test
56     public void testValidateIdentity() throws Exception {
57         DependencyResolver res = mock(DependencyResolver.class);
58         JmxAttribute jmxAttr = new JmxAttribute("abc");
59         doNothing().when(res).validateIdentity(attr, Identity.class, jmxAttr);
60         attr.validateIdentity(res, Identity.class, jmxAttr);
61         verify(res).validateIdentity(attr, Identity.class, jmxAttr);
62     }
63
64     static class Identity extends BaseIdentity {}
65
66     static class SubIdentity extends Identity {}
67 }