Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-api / src / test / java / org / opendaylight / controller / config / api / ModuleIdentifierTest.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.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotEquals;
13
14 import org.junit.Test;
15
16 public class ModuleIdentifierTest {
17     String fact = new String("factory");
18     String inst = new String("instance");
19
20     @Test(expected = IllegalArgumentException.class)
21     public void testConstructor() throws Exception {
22         ModuleIdentifier moduleIdentifier = new ModuleIdentifier(null, "instance");
23     }
24
25     @Test(expected = IllegalArgumentException.class)
26     public void testConstructor2() throws Exception {
27         ModuleIdentifier moduleIdentifier = new ModuleIdentifier("name", null);
28     }
29
30     @Test
31     public void testEquals() throws Exception {
32
33         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
34         assertEquals(m1, new ModuleIdentifier(fact, inst));
35     }
36
37     @Test
38     public void testEquals2() throws Exception {
39         assertNotEquals(new ModuleIdentifier(fact, inst), null);
40     }
41
42     @Test
43     public void testEquals3() throws Exception {
44         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier(fact, "i"));
45     }
46
47     @Test
48     public void testEquals4() throws Exception {
49         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier("f", inst));
50     }
51
52     @Test
53     public void testEquals5() throws Exception {
54         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
55         assertEquals(m1, m1);
56     }
57
58     @Test
59     public void testHashCode() throws Exception {
60         int hash = new ModuleIdentifier(fact, inst).hashCode();
61         assertEquals(hash, new ModuleIdentifier("factory", "instance").hashCode());
62     }
63
64     @Test
65     public void testToString() throws Exception {
66         assertEquals(new ModuleIdentifier("factory", "instance").toString(),
67                 new ModuleIdentifier("factory", "instance").toString());
68     }
69 }