Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-api / src / test / java / org / opendaylight / controller / config / api / jmx / CommitStatusTest.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.jmx;
10
11 import java.util.ArrayList;
12 import java.util.List;
13 import javax.management.ObjectName;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17
18 public class CommitStatusTest {
19     List<ObjectName> newInst = new ArrayList<>();
20     List<ObjectName> reusedInst = new ArrayList<>();
21     List<ObjectName> recreatedInst = new ArrayList<>();
22
23     @Before
24     public void setUp() throws Exception {
25         newInst.add(new ObjectName("domain: key1 = value1 , key2 = value2"));
26         reusedInst.add(new ObjectName("o2: key = val"));
27         recreatedInst.add(new ObjectName("o3: key = k"));
28     }
29
30     @Test
31     public void testCommitStatus() throws Exception {
32         CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
33         Assert.assertEquals(status.getNewInstances(), newInst);
34         Assert.assertEquals(status.getRecreatedInstances(), recreatedInst);
35         Assert.assertEquals(status.getReusedInstances(), reusedInst);
36     }
37
38     @Test
39     public void testEqual() throws Exception {
40         CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
41         Assert.assertEquals(status, new CommitStatus(newInst, reusedInst, recreatedInst));
42         Assert.assertEquals(status.toString(), new CommitStatus(newInst, reusedInst, recreatedInst).toString());
43         Assert.assertEquals(status, status);
44     }
45
46     @Test
47     public void testHashCode() throws Exception {
48         CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
49         Assert.assertEquals(status.hashCode(), new CommitStatus(newInst, reusedInst, recreatedInst).hashCode());
50     }
51
52     @Test
53     public void testNotEqual() throws Exception {
54         List<ObjectName> newInst2 = new ArrayList<>();
55         List<ObjectName> reusedInst2 = new ArrayList<>();
56         List<ObjectName> recreatedInst2 = new ArrayList<>();
57
58         newInst2.add(new ObjectName("first: key1 = value1"));
59         reusedInst2.add(new ObjectName("second: key = val"));
60         recreatedInst2.add(new ObjectName("third: key = k"));
61
62         CommitStatus status = new CommitStatus(newInst, reusedInst, recreatedInst);
63         Assert.assertNotEquals(status, null);
64         Assert.assertNotEquals(status, new Object());
65         Assert.assertNotEquals(status, new CommitStatus(newInst2, reusedInst, recreatedInst));
66         Assert.assertNotEquals(status, new CommitStatus(newInst, reusedInst2, recreatedInst));
67         Assert.assertNotEquals(status, new CommitStatus(newInst, reusedInst, recreatedInst2));
68
69         CommitStatus status2 = new CommitStatus(newInst, reusedInst, recreatedInst);
70     }
71 }

©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.