Merge "Fix checkstyle warnings in netty-threadgroup-config."
[controller.git] / opendaylight / netconf / netconf-util / src / test / java / org / opendaylight / controller / netconf / util / mapping / AbstractLastNetconfOperationTest.java
1 /*
2  * Copyright (c) 2014 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.netconf.util.mapping;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
19 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
20 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
21 import org.opendaylight.controller.netconf.util.xml.XmlElement;
22 import org.w3c.dom.Document;
23 import org.w3c.dom.Element;
24
25 public class AbstractLastNetconfOperationTest {
26     class LastNetconfOperationImplTest extends  AbstractLastNetconfOperation  {
27
28         boolean handleWithNoSubsequentOperationsRun;
29
30         protected LastNetconfOperationImplTest(String netconfSessionIdForReporting) {
31             super(netconfSessionIdForReporting);
32             handleWithNoSubsequentOperationsRun = false;
33         }
34
35         @Override
36         protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
37             handleWithNoSubsequentOperationsRun = true;
38             return null;
39         }
40
41         @Override
42         protected String getOperationName() {
43             return "";
44         }
45     }
46
47     LastNetconfOperationImplTest netconfOperation;
48
49     @Before
50     public void setUp() throws Exception {
51         netconfOperation = new LastNetconfOperationImplTest("");
52     }
53
54     @Test
55     public void testNetconfOperation() throws Exception {
56         netconfOperation.handleWithNoSubsequentOperations(null, null);
57         assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
58         assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
59     }
60
61     @Test(expected = NetconfDocumentedException.class)
62     public void testHandle() throws Exception {
63         NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
64         doReturn("").when(operation).toString();
65
66         doReturn(false).when(operation).isExecutionTermination();
67         netconfOperation.handle(null, null, operation);
68     }
69 }