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.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
20 import org.opendaylight.yangtools.yang.common.Uint32;
21 import org.w3c.dom.Document;
22 import org.w3c.dom.Element;
24 public class AbstractLastNetconfOperationTest {
25 private static final class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
26 boolean handleWithNoSubsequentOperationsRun;
28 protected LastNetconfOperationImplTest(final SessionIdType sessionId) {
30 handleWithNoSubsequentOperationsRun = false;
34 protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
35 throws DocumentedException {
36 handleWithNoSubsequentOperationsRun = true;
41 protected String getOperationName() {
46 LastNetconfOperationImplTest netconfOperation;
49 public void setUp() throws Exception {
50 netconfOperation = new LastNetconfOperationImplTest(new SessionIdType(Uint32.ONE));
54 public void testNetconfOperation() throws Exception {
55 netconfOperation.handleWithNoSubsequentOperations(null, null);
56 assertTrue(netconfOperation.handleWithNoSubsequentOperationsRun);
57 assertEquals(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY, netconfOperation.getHandlingPriority());
60 @Test(expected = DocumentedException.class)
61 public void testHandle() throws Exception {
62 NetconfOperationChainedExecution operation = mock(NetconfOperationChainedExecution.class);
63 doReturn("").when(operation).toString();
65 doReturn(false).when(operation).isExecutionTermination();
66 netconfOperation.handle(null, null, operation);