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.test.tool.operations;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Optional;
14 import org.opendaylight.netconf.api.capability.Capability;
15 import org.opendaylight.netconf.server.api.operations.NetconfOperation;
16 import org.opendaylight.netconf.server.api.operations.NetconfOperationService;
17 import org.opendaylight.netconf.test.tool.rpc.DataList;
18 import org.opendaylight.netconf.test.tool.rpc.SimulatedCommit;
19 import org.opendaylight.netconf.test.tool.rpc.SimulatedCreateSubscription;
20 import org.opendaylight.netconf.test.tool.rpc.SimulatedDiscardChanges;
21 import org.opendaylight.netconf.test.tool.rpc.SimulatedEditConfig;
22 import org.opendaylight.netconf.test.tool.rpc.SimulatedGet;
23 import org.opendaylight.netconf.test.tool.rpc.SimulatedGetConfig;
24 import org.opendaylight.netconf.test.tool.rpc.SimulatedLock;
25 import org.opendaylight.netconf.test.tool.rpc.SimulatedUnLock;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
28 public final class DefaultOperationsCreator implements OperationsCreator {
31 public NetconfOperationService getNetconfOperationService(final Set<Capability> caps,
32 final SessionIdType sessionId) {
33 return new SimulatedOperationService(sessionId);
36 static class SimulatedOperationService implements NetconfOperationService {
37 private final SessionIdType currentSessionId;
39 SimulatedOperationService(final SessionIdType currentSessionId) {
40 this.currentSessionId = requireNonNull(currentSessionId);
44 public Set<NetconfOperation> getNetconfOperations() {
45 final DataList storage = new DataList();
46 final SimulatedGet sGet = new SimulatedGet(currentSessionId, storage);
47 final SimulatedEditConfig sEditConfig = new SimulatedEditConfig(currentSessionId, storage);
48 final SimulatedGetConfig sGetConfig = new SimulatedGetConfig(currentSessionId, storage, Optional.empty());
49 final SimulatedCommit sCommit = new SimulatedCommit(currentSessionId);
50 final SimulatedLock sLock = new SimulatedLock(currentSessionId);
51 final SimulatedUnLock sUnlock = new SimulatedUnLock(currentSessionId);
52 final SimulatedCreateSubscription sCreateSubs = new SimulatedCreateSubscription(currentSessionId,
54 final SimulatedDiscardChanges sDiscardChanges = new SimulatedDiscardChanges(currentSessionId);
55 return Set.of(sGet, sGetConfig, sEditConfig, sCommit, sLock, sUnlock, sCreateSubs, sDiscardChanges);