1 package org.opendaylight.controller.config.api;
3 import org.junit.Assert;
5 import org.mockito.Mock;
6 import org.mockito.MockitoAnnotations;
7 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
8 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
10 import javax.management.*;
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Mockito.*;
15 public class IdentityAttributeRefTest {
17 IdentityAttributeRef attr = new IdentityAttributeRef("attr");
20 public void testConstructor() throws Exception {
21 String param = new String("attr");
22 Assert.assertEquals(attr.getqNameOfIdentity(), param);
25 @Test(expected = NullPointerException.class)
26 public void testConstructor2() throws Exception {
27 IdentityAttributeRef attr = new IdentityAttributeRef(null);
31 public void testHashCode() throws Exception {
32 Assert.assertEquals(attr.hashCode(), new String("attr").hashCode());
36 public void testEqual() throws Exception {
37 Assert.assertEquals(attr, attr);
41 public void testEqual2() throws Exception {
42 Assert.assertEquals(attr, new IdentityAttributeRef("attr"));
46 public void testNotEqual() throws Exception {
47 Assert.assertNotEquals(attr, new IdentityAttributeRef("different"));
51 public void testResolveIdentity() throws Exception {
52 DependencyResolver res = mock(DependencyResolver.class);
53 IdentityAttributeRef a = new IdentityAttributeRef("abcd");
54 doReturn(SubIdentity.class).when(res).resolveIdentity(a, Identity.class);
55 a.resolveIdentity(res, Identity.class);
56 verify(res).resolveIdentity(a, Identity.class);
60 public void testValidateIdentity() throws Exception {
61 DependencyResolver res = mock(DependencyResolver.class);
62 JmxAttribute jmxAttr = new JmxAttribute("abc");
63 doNothing().when(res).validateIdentity(attr, Identity.class, jmxAttr);
64 attr.validateIdentity(res, Identity.class, jmxAttr);
65 verify(res).validateIdentity(attr, Identity.class, jmxAttr);
68 static class Identity extends BaseIdentity {}
70 static class SubIdentity extends Identity {}