2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netconf.server.api.operations;
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;
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;
22 public class AbstractLastNetconfOperationTest {
23 private static final class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
24 boolean handleWithNoSubsequentOperationsRun;
26 protected LastNetconfOperationImplTest(final String netconfSessionIdForReporting) {
27 super(netconfSessionIdForReporting);
28 handleWithNoSubsequentOperationsRun = false;
32 protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
33 throws DocumentedException {
34 handleWithNoSubsequentOperationsRun = true;
39 protected String getOperationName() {
44 LastNetconfOperationImplTest netconfOperation;
47 public void setUp() throws Exception {
48 netconfOperation = new LastNetconfOperationImplTest("");
52 public void testNetconfOperation() throws Exception {
53 netconfOperation.handleWithNoSubsequentOperations(null, null);
54 assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
55 assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
58 @Test(expected = DocumentedException.class)
59 public void testHandle() throws Exception {
60 NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
61 doReturn("").when(operation).toString();
63 doReturn(false).when(operation).isExecutionTermination();
64 netconfOperation.handle(null, null, operation);