### Question:
OvsdbPortUpdateCommand extends AbstractTransactionCommand { @SuppressWarnings("IllegalCatch") private Optional<Node> readNode(final ReadWriteTransaction transaction, final InstanceIdentifier<Node> nodePath) { Optional<Node> node = Optional.empty(); try { node = SouthboundUtil.readNode(transaction, nodePath); } catch (Exception exp) { LOG.error("Error in getting the Node for {}", nodePath, exp); } return node; } OvsdbPortUpdateCommand(InstanceIdentifierCodec instanceIdentifierCodec, OvsdbConnectionInstance key,
            TableUpdates updates, DatabaseSchema dbSchema); @Override void execute(ReadWriteTransaction transaction);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testReadNode() throws Exception { ReadWriteTransaction transaction = mock(ReadWriteTransaction.class); InstanceIdentifier<Node> nodePath = mock(InstanceIdentifier.class); Optional<Node> node = Optional.of(mock(Node.class)); FluentFuture<Optional<Node>> fluentFuture = mock(FluentFuture.class); when(transaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))) .thenReturn(fluentFuture); when(fluentFuture.get()).thenReturn(node); assertEquals(node, Whitebox.invokeMethod(ovsdbPortUpdateCommand, "readNode", transaction, nodePath)); }
@SuppressWarnings("unchecked") @Test public void testGetTerminationPointBridge1() throws Exception { Node node = mock(Node.class); OvsdbNodeAugmentation ovsdbNode = mock(OvsdbNodeAugmentation.class); when(node.augmentation(OvsdbNodeAugmentation.class)).thenReturn(ovsdbNode); InstanceIdentifier<Node> iidNode = mock(InstanceIdentifier.class); ManagedNodeEntry managedNodeEntry = new ManagedNodeEntryBuilder() .setBridgeRef(new OvsdbBridgeRef(iidNode)) .build(); when(ovsdbNode.nonnullManagedNodeEntry()).thenCallRealMethod(); when(ovsdbNode.getManagedNodeEntry()).thenReturn(Map.of(managedNodeEntry.key(), managedNodeEntry)); Node managedNode = mock(Node.class); Optional<Node> optionalNode = Optional.of(managedNode); PowerMockito.doReturn(optionalNode).when(ovsdbPortUpdateCommand, "readNode", any(ReadWriteTransaction.class), any(InstanceIdentifier.class)); PowerMockito.mockStatic(SouthboundUtil.class); PowerMockito.when(SouthboundUtil.readNode(any(ReadWriteTransaction.class), any(InstanceIdentifier.class))) .thenReturn(optionalNode); TerminationPoint terminationPoint = new TerminationPointBuilder().setTpId(new TpId(TP_NAME)).build(); TerminationPointBuilder tpBuilder = mock(TerminationPointBuilder.class); when(tpBuilder.withKey(any(TerminationPointKey.class))).thenReturn(tpBuilder); when(tpBuilder.build()).thenReturn(terminationPoint); PowerMockito.whenNew(TerminationPointBuilder.class).withNoArguments().thenReturn(tpBuilder); when(managedNode.nonnullTerminationPoint()).thenCallRealMethod(); when(managedNode.getTerminationPoint()).thenReturn(Map.of(terminationPoint.key(), terminationPoint)); when(managedNode.augmentation(OvsdbBridgeAugmentation.class)) .thenReturn(mock(OvsdbBridgeAugmentation.class)); Optional<InstanceIdentifier<Node>> testResult = Optional.of(iidNode); ReadWriteTransaction transaction = mock(ReadWriteTransaction.class); Optional<InstanceIdentifier<Node>> result = Whitebox.invokeMethod(ovsdbPortUpdateCommand, "getTerminationPointBridge", transaction, node, TP_NAME); assertEquals(testResult, result); }