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