Fixed Checkstyle violation errors in mdsal-dom-api module
[mdsal.git] / dom / mdsal-dom-api / src / test / java / org / opendaylight / mdsal / dom / api / DOMExceptionsTest.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.mdsal.dom.api;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.net.URI;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20
21 public class DOMExceptionsTest {
22     private static final String TEST_MESSAGE = "TestMessage";
23     private static final String TEST_LISTS = "test-lists";
24     private static final QNameModule TEST_MODULE = QNameModule.create(URI.create(
25             "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
26     private static final YangInstanceIdentifier TEST_YI_ID = YangInstanceIdentifier.create(
27             new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, TEST_LISTS)));
28     private static final DOMDataTreeIdentifier TEST_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
29             TEST_YI_ID);
30
31     @Test(expected = DOMDataTreeInaccessibleException.class)
32     public void testDomDataTreeInaccessibleException() throws Exception {
33         final DOMDataTreeInaccessibleException testExc = new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE);
34         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
35         assertNotNull(testExc.getTreeIdentifier());
36         assertEquals(TEST_TREE, testExc.getTreeIdentifier());
37
38         throw new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE, new Throwable());
39     }
40
41     @Test(expected = DOMDataTreeListeningException.class)
42     public void testDomDataTreeListeningException() throws Exception {
43         final DOMDataTreeListeningException testExc = new DOMDataTreeListeningException(TEST_MESSAGE);
44         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
45
46         throw new DOMDataTreeListeningException(TEST_MESSAGE, new Throwable());
47     }
48
49     @Test(expected = DOMDataTreeLoopException.class)
50     public void testDomDataTreeLoopException() throws Exception {
51         final DOMDataTreeLoopException testExc = new DOMDataTreeLoopException(TEST_MESSAGE);
52         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
53
54         throw new DOMDataTreeLoopException(TEST_MESSAGE, new Throwable());
55     }
56
57     @Test(expected = DOMDataTreeProducerBusyException.class)
58     public void testDomDataTreeProducerBusyException() throws Exception {
59         final DOMDataTreeProducerBusyException testExc = new DOMDataTreeProducerBusyException(TEST_MESSAGE);
60         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
61
62         throw new DOMDataTreeProducerBusyException(TEST_MESSAGE, new Throwable());
63     }
64
65     @Test(expected = DOMDataTreeProducerException.class)
66     public void testDOMDataTreeProducerException() throws Exception {
67         final DOMDataTreeProducerException testExc = new DOMDataTreeProducerException(TEST_MESSAGE);
68         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
69
70         throw new DOMDataTreeProducerException(TEST_MESSAGE, new Throwable());
71     }
72
73     @Test(expected = DOMDataTreeShardingConflictException.class)
74     public void testDOMDataTreeShardingConflictException() throws Exception {
75         final DOMDataTreeShardingConflictException testExc = new DOMDataTreeShardingConflictException(TEST_MESSAGE);
76         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
77
78         throw new DOMDataTreeShardingConflictException(TEST_MESSAGE, new Throwable());
79     }
80
81     @Test(expected = DOMNotificationRejectedException.class)
82     public void testDomNotificationRejectedException() throws Exception {
83         final DOMNotificationRejectedException testExc = new DOMNotificationRejectedException(TEST_MESSAGE);
84         assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
85
86         throw new DOMNotificationRejectedException(TEST_MESSAGE, new Throwable());
87     }
88
89     @Test(expected = DOMRpcImplementationNotAvailableException.class)
90     public void testDomRpcImplementationNotAvailableException() throws Exception {
91         final DOMRpcImplementationNotAvailableException dompcImplementationNotAvailableException
92             = new DOMRpcImplementationNotAvailableException(TEST_MESSAGE);
93         assertTrue(dompcImplementationNotAvailableException.getMessage().contains(TEST_MESSAGE));
94
95         throw new DOMRpcImplementationNotAvailableException(new Throwable(), TEST_MESSAGE, new Object());
96     }
97 }