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.netconf.util.mapping;
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;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.netconf.api.DocumentedException;
19 import org.opendaylight.netconf.api.xml.XmlElement;
20 import org.opendaylight.netconf.mapping.api.HandlingPriority;
21 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
22 import org.w3c.dom.Document;
23 import org.w3c.dom.Element;
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,
37 XmlElement operationElement) throws DocumentedException {
38 handleWithNoSubsequentOperationsRun = true;
43 protected String getOperationName() {
48 LastNetconfOperationImplTest netconfOperation;
51 public void setUp() throws Exception {
52 netconfOperation = new LastNetconfOperationImplTest("");
56 public void testNetconfOperation() throws Exception {
57 netconfOperation.handleWithNoSubsequentOperations(null, null);
58 assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
59 assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
62 @Test(expected = DocumentedException.class)
63 public void testHandle() throws Exception {
64 NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
65 doReturn("").when(operation).toString();
67 doReturn(false).when(operation).isExecutionTermination();
68 netconfOperation.handle(null, null, operation);