package org.opendaylight.netconf.topology.spi;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import org.opendaylight.netconf.client.mdsal.NetconfDeviceCapabilities;
import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
public void before() {
doReturn(mockTx).when(mockChain).newWriteOnlyTransaction();
// FIXME: exact match
- doNothing().when(mockTx).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class));
+ doNothing().when(mockTx).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class),
+ any(Node.class));
doReturn("test transaction").when(mockTx).getIdentifier();
doReturn(CommitInfo.emptyFluentFuture()).when(mockTx).commit();
@Test
public void replaceChainIfFailed() {
+ doNothing().when(mockChain).close();
+ doReturn("mockChain").when(mockChain).toString();
adapter.onTransactionChainFailed(mockChain, mockTx, new Exception("chain failed"));
verify(mockBroker, times(2)).createMergingTransactionChain(any());
}
@Test
public void testFailedDevice() {
+ // FIXME: exact match
+ doNothing().when(mockTx).mergeParentStructurePut(eq(LogicalDatastoreType.OPERATIONAL),
+ any(InstanceIdentifier.class), any(NetconfNode.class));
+
adapter.setDeviceAsFailed(null);
verify(mockChain, times(2)).newWriteOnlyTransaction();
@Test
public void testDeviceUpdate() throws Exception {
+ doNothing().when(mockTx).mergeParentStructurePut(eq(LogicalDatastoreType.OPERATIONAL),
+ any(InstanceIdentifier.class), any(NetconfNode.class));
adapter.updateDeviceData(true, NetconfDeviceCapabilities.empty(), new SessionIdType(Uint32.ONE));
verify(mockChain, times(2)).newWriteOnlyTransaction();
@Test
public void testRemoveDeviceConfiguration() throws Exception {
+ // FIXME: exact match
+ doNothing().when(mockTx).delete(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
+ doNothing().when(mockChain).close();
listeners.getValue().onTransactionChainSuccessful(mockChain);
adapter.close();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.doReturn;
import org.junit.Before;
import org.junit.Test;
@Before
public void setUp() {
- when(encryptionService.encrypt(TEST_PWD)).thenReturn(ENC_PWD);
+ doReturn(ENC_PWD).when(encryptionService).encrypt(TEST_PWD);
rpcProvider = new NetconfTopologyRPCProvider(dataBroker, encryptionService, TOPOLOGY_ID);
}
.setHost(new Host(new IpAddress(new Ipv4Address("10.18.16.188"))))
.setPort(new PortNumber(Uint16.valueOf(830)))
.setTcpOnly(Boolean.FALSE)
- // FIXME: do we really want 'toString()' here?
- .setNodeId(NODE_ID.toString())
+ .setNodeId(NODE_ID.getValue())
.build();
}
}