Merge "Fix checkstyle warnings in config-api"
[controller.git] / opendaylight / config / config-api / src / test / java / org / opendaylight / controller / config / api / ModuleIdentifierTest.java
1 package org.opendaylight.controller.config.api;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotEquals;
5
6 import org.junit.Test;
7
8 public class ModuleIdentifierTest {
9     String fact = new String("factory");
10     String inst = new String("instance");
11
12     @Test(expected = IllegalArgumentException.class)
13     public void testConstructor() throws Exception {
14         ModuleIdentifier m = new ModuleIdentifier(null, "instance");
15     }
16
17     @Test(expected = IllegalArgumentException.class)
18     public void testConstructor2() throws Exception {
19         ModuleIdentifier m = new ModuleIdentifier("name", null);
20     }
21
22     @Test
23     public void testEquals() throws Exception {
24
25         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
26         assertEquals(m1, new ModuleIdentifier(fact, inst));
27     }
28
29     @Test
30     public void testEquals2() throws Exception {
31         assertNotEquals(new ModuleIdentifier(fact, inst), null);
32     }
33
34     @Test
35     public void testEquals3() throws Exception {
36         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier(fact, "i"));
37     }
38
39     @Test
40     public void testEquals4() throws Exception {
41         assertNotEquals(new ModuleIdentifier(fact, inst), new ModuleIdentifier("f", inst));
42     }
43
44     @Test
45     public void testEquals5() throws Exception {
46         ModuleIdentifier m1 = new ModuleIdentifier(fact, inst);
47         assertEquals(m1, m1);
48     }
49
50     @Test
51     public void testHashCode() throws Exception {
52         int hash = new ModuleIdentifier(fact, inst).hashCode();
53         assertEquals(hash, new ModuleIdentifier("factory", "instance").hashCode());
54     }
55
56     @Test
57     public void testToString() throws Exception {
58         assertEquals( new ModuleIdentifier("factory", "instance").toString(),
59                 new ModuleIdentifier("factory", "instance").toString());
60     }
61 }