### Question:
OvsdbNodeRemoveCommand extends AbstractTransactionCommand { @Override public void execute(ReadWriteTransaction transaction) { FluentFuture<Optional<Node>> ovsdbNodeFuture = transaction.read( LogicalDatastoreType.OPERATIONAL, getOvsdbConnectionInstance().getInstanceIdentifier()); Optional<Node> ovsdbNodeOptional; try { ovsdbNodeOptional = ovsdbNodeFuture.get(); if (ovsdbNodeOptional.isPresent()) { Node ovsdbNode = ovsdbNodeOptional.get(); OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.augmentation(OvsdbNodeAugmentation.class); if (checkIfOnlyConnectedManager(ovsdbNodeAugmentation)) { if (ovsdbNodeAugmentation != null) { Map<ManagedNodeEntryKey, ManagedNodeEntry> entries = ovsdbNodeAugmentation.getManagedNodeEntry(); if (entries != null) { for (ManagedNodeEntry managedNode : entries.values()) { transaction.delete( LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue()); } } else { LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue()); } } else { LOG.warn("{} had no OvsdbNodeAugmentation", ovsdbNode.getNodeId().getValue()); } LOG.debug("Deleting node {} from oper", getOvsdbConnectionInstance().getInstanceIdentifier()); transaction.delete(LogicalDatastoreType.OPERATIONAL, getOvsdbConnectionInstance().getInstanceIdentifier()); } else { LOG.debug("Other southbound plugin instances in cluster are connected to the device," + " not deleting OvsdbNode from operational data store."); } } } catch (InterruptedException | ExecutionException e) { LOG.warn("Failure to delete ovsdbNode", e); } } OvsdbNodeRemoveCommand(OvsdbConnectionInstance key,TableUpdates updates,DatabaseSchema dbSchema); @Override void execute(ReadWriteTransaction transaction);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testExecute() throws Exception { ReadWriteTransaction transaction = mock(ReadWriteTransaction.class); FluentFuture<Optional<Node>> ovsdbNodeFuture = mock(FluentFuture.class); OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class); when(ovsdbNodeRemoveCommand.getOvsdbConnectionInstance()).thenReturn(ovsdbConnectionInstance); when(ovsdbConnectionInstance.getInstanceIdentifier()).thenReturn(mock(InstanceIdentifier.class)); when(transaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))) .thenReturn(ovsdbNodeFuture); Node ovsdbNode = mock(Node.class); Optional<Node> ovsdbNodeOptional = Optional.of(ovsdbNode); when(ovsdbNodeFuture.get()).thenReturn(ovsdbNodeOptional); OvsdbNodeAugmentation ovsdbNodeAugmentation = mock(OvsdbNodeAugmentation.class); when(ovsdbNode.augmentation(OvsdbNodeAugmentation.class)).thenReturn(ovsdbNodeAugmentation); doReturn(true).when(ovsdbNodeRemoveCommand).checkIfOnlyConnectedManager(any(OvsdbNodeAugmentation.class)); ManagedNodeEntry managedNode = new ManagedNodeEntryBuilder() .setBridgeRef(new OvsdbBridgeRef(mock(InstanceIdentifier.class))) .build(); when(ovsdbNodeAugmentation.getManagedNodeEntry()).thenReturn(Map.of(managedNode.key(), managedNode)); doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); ovsdbNodeRemoveCommand.execute(transaction); verify(ovsdbNodeAugmentation).getManagedNodeEntry(); verify(transaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)); }