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
9 package org.opendaylight.controller.netconf.util.mapping;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
14 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
15 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
16 import org.opendaylight.controller.netconf.util.xml.XmlElement;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertTrue;
22 import static org.mockito.Mockito.doReturn;
23 import static org.mockito.Mockito.mock;
25 public class AbstractLastNetconfOperationTest {
26 class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
28 boolean handleWithNoSubsequentOperationsRun;
30 protected LastNetconfOperationImplTest(String netconfSessionIdForReporting) {
31 super(netconfSessionIdForReporting);
32 handleWithNoSubsequentOperationsRun = false;
36 protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
37 handleWithNoSubsequentOperationsRun = true;
42 protected String getOperationName() {
47 LastNetconfOperationImplTest netconfOperation;
50 public void setUp() throws Exception {
51 netconfOperation = new LastNetconfOperationImplTest("");
55 public void testNetconfOperation() throws Exception {
56 netconfOperation.handleWithNoSubsequentOperations(null, null);
57 assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
58 assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
61 @Test(expected = NetconfDocumentedException.class)
62 public void testHandle() throws Exception {
63 NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
64 doReturn("").when(operation).toString();
66 doReturn(false).when(operation).isExecutionTermination();
67 netconfOperation.handle(null, null, operation);