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;
7 import org.junit.Assert;
9 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
11 public class IdentityAttributeRefTest {
13 IdentityAttributeRef attr = new IdentityAttributeRef("attr");
16 public void testConstructor() throws Exception {
17 String param = new String("attr");
18 Assert.assertEquals(attr.getqNameOfIdentity(), param);
21 @Test(expected = NullPointerException.class)
22 public void testConstructor2() throws Exception {
23 IdentityAttributeRef attr = new IdentityAttributeRef(null);
27 public void testHashCode() throws Exception {
28 Assert.assertEquals(attr.hashCode(), new String("attr").hashCode());
32 public void testEqual() throws Exception {
33 Assert.assertEquals(attr, attr);
37 public void testEqual2() throws Exception {
38 Assert.assertEquals(attr, new IdentityAttributeRef("attr"));
42 public void testNotEqual() throws Exception {
43 Assert.assertNotEquals(attr, new IdentityAttributeRef("different"));
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);
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);
64 static class Identity extends BaseIdentity {}
66 static class SubIdentity extends Identity {}