Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-api / src / test / java / org / opendaylight / controller / config / api / IdentityAttributeRefTest.java
1 /*
2  * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.config.api;
10
11 import static org.mockito.Mockito.doNothing;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
15
16 import org.junit.Assert;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
19
20 public class IdentityAttributeRefTest {
21
22     IdentityAttributeRef attr = new IdentityAttributeRef("attr");
23
24     @Test
25     public void testConstructor() throws Exception {
26         String param = new String("attr");
27         Assert.assertEquals(attr.getqNameOfIdentity(), param);
28     }
29
30     @Test(expected = NullPointerException.class)
31     public void testConstructor2() throws Exception {
32         IdentityAttributeRef attr = new IdentityAttributeRef(null);
33     }
34
35     @Test
36     public void testHashCode() throws Exception {
37         Assert.assertEquals(attr.hashCode(), new String("attr").hashCode());
38     }
39
40     @Test
41     public void testEqual() throws Exception {
42         Assert.assertEquals(attr, attr);
43     }
44
45     @Test
46     public void testEqual2() throws Exception {
47         Assert.assertEquals(attr, new IdentityAttributeRef("attr"));
48     }
49
50     @Test
51     public void testNotEqual() throws Exception {
52         Assert.assertNotEquals(attr, new IdentityAttributeRef("different"));
53     }
54
55     @Test
56     public void testResolveIdentity() throws Exception {
57         DependencyResolver res = mock(DependencyResolver.class);
58         IdentityAttributeRef identityAttributeRef = new IdentityAttributeRef("abcd");
59         doReturn(SubIdentity.class).when(res).resolveIdentity(identityAttributeRef, Identity.class);
60         identityAttributeRef.resolveIdentity(res, Identity.class);
61         verify(res).resolveIdentity(identityAttributeRef, Identity.class);
62     }
63
64     @Test
65     public void testValidateIdentity() throws Exception {
66         DependencyResolver res = mock(DependencyResolver.class);
67         JmxAttribute jmxAttr = new JmxAttribute("abc");
68         doNothing().when(res).validateIdentity(attr, Identity.class, jmxAttr);
69         attr.validateIdentity(res, Identity.class, jmxAttr);
70         verify(res).validateIdentity(attr, Identity.class, jmxAttr);
71     }
72
73     static class Identity extends BaseIdentity {}
74
75     static class SubIdentity extends Identity {}
76 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.