Java Code Examples for org.powermock.api.support.membermodification.MemberModifier#suppress()

The following examples show how to use org.powermock.api.support.membermodification.MemberModifier#suppress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OvsdbControllerUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testExecute() throws Exception {
    Map<UUID, Controller> updatedControllerRows = new HashMap<>();
    updatedControllerRows.put(mock(UUID.class), mock(Controller.class));
    MemberModifier.field(OvsdbControllerUpdateCommand.class, "updatedControllerRows")
            .set(ovsdbControllerUpdateCommand, updatedControllerRows);
    MemberModifier.suppress(MemberMatcher.method(OvsdbControllerUpdateCommand.class, "updateController",
            ReadWriteTransaction.class, Map.class, Map.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbControllerUpdateCommand.class, "updateController",
            ReadWriteTransaction.class, Map.class));

    // updatedBridgeRows null case
    ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
    ovsdbControllerUpdateCommand.execute(transaction);
    verify(ovsdbControllerUpdateCommand).updateController(any(ReadWriteTransaction.class), any(Map.class));

    // updatedBridgeRows not null case
    Map<UUID, Bridge> updatedBridgeRows = new HashMap<>();
    updatedBridgeRows.put(mock(UUID.class), mock(Bridge.class));
    MemberModifier.field(OvsdbControllerUpdateCommand.class, "updatedBridgeRows").set(ovsdbControllerUpdateCommand,
            updatedBridgeRows);
}
 
Example 2
Source File: OvsdbBridgeRemovedCommandTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testExecute() throws Exception {
    //suppress calls to parent get methods
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeRemovedCommand.class, "getUpdates"));
    when(ovsdbBridgeRemovedCommand.getUpdates()).thenReturn(mock(TableUpdates.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeRemovedCommand.class, "getDbSchema"));
    when(ovsdbBridgeRemovedCommand.getDbSchema()).thenReturn(mock(DatabaseSchema.class));

    PowerMockito.mockStatic(TyperUtils.class);
    Map<UUID, Bridge> map = new HashMap<>();
    when(TyperUtils.extractRowsRemoved(eq(Bridge.class), any(TableUpdates.class), any(DatabaseSchema.class)))
            .thenReturn(map);

    ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
    ovsdbBridgeRemovedCommand.execute(transaction);
    verify(ovsdbBridgeRemovedCommand).getUpdates();
    verify(ovsdbBridgeRemovedCommand).getDbSchema();
}
 
Example 3
Source File: OvsdbBridgeUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testExecute() throws Exception {
    updatedBridgeRows.put(mock(UUID.class), mock(Bridge.class));

    OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class);
    when(ovsdbBridgeUpdateCommand.getOvsdbConnectionInstance()).thenReturn(ovsdbConnectionInstance);
    InstanceIdentifier<Node> connectionIId = mock(InstanceIdentifier.class);
    when(ovsdbConnectionInstance.getInstanceIdentifier()).thenReturn(connectionIId);
    Optional<Node> connection = Optional.of(mock(Node.class));
    PowerMockito.mockStatic(SouthboundUtil.class);
    when(SouthboundUtil.readNode(any(ReadWriteTransaction.class), any(InstanceIdentifier.class)))
            .thenReturn(connection);
    ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "updateBridge",
            ReadWriteTransaction.class, Bridge.class, InstanceIdentifier.class));
    ovsdbBridgeUpdateCommand.execute(transaction);
    verify(ovsdbBridgeUpdateCommand).updateBridge(any(ReadWriteTransaction.class),
            any(Bridge.class), any(InstanceIdentifier.class));
}
 
Example 4
Source File: TerminationPointUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testExecute() {
    Map<InstanceIdentifier<OvsdbTerminationPointAugmentation>, OvsdbTerminationPointAugmentation> created
        = new HashMap<>();
    created.put(mock(InstanceIdentifier.class), mock(OvsdbTerminationPointAugmentation.class));
    PowerMockito.mockStatic(TransactUtils.class);
    PowerMockito.when(TransactUtils.extractCreated(any(DataChangeEvent.class),
            eq(OvsdbTerminationPointAugmentation.class))).thenReturn(created);
    MemberModifier.suppress(MemberMatcher.method(TerminationPointUpdateCommand.class, "updateTerminationPoint",
            TransactionBuilder.class, BridgeOperationalState.class,
            InstanceIdentifier.class, OvsdbTerminationPointAugmentation.class, InstanceIdentifierCodec.class));
    doNothing().when(terminationPointUpdateCommand).updateTerminationPoint(any(TransactionBuilder.class),
            any(BridgeOperationalState.class), any(InstanceIdentifier.class),
            any(OvsdbTerminationPointAugmentation.class), any(InstanceIdentifierCodec.class));

    Map<InstanceIdentifier<OvsdbTerminationPointAugmentation>, OvsdbTerminationPointAugmentation> updated
        = new HashMap<>();
    updated.put(mock(InstanceIdentifier.class), mock(OvsdbTerminationPointAugmentation.class));
    PowerMockito.when(TransactUtils.extractUpdated(any(DataChangeEvent.class),
            eq(OvsdbTerminationPointAugmentation.class))).thenReturn(updated);

    TransactionBuilder transactionBuilder = mock(TransactionBuilder.class);
    terminationPointUpdateCommand.execute(transactionBuilder, mock(BridgeOperationalState.class),
            mock(DataChangeEvent.class), mock(InstanceIdentifierCodec.class));
    // TODO Verify something useful
}
 
Example 5
Source File: OvsdbConnectionManagerTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testDisconnected() throws Exception {
    ConnectionInfo key = mock(ConnectionInfo.class);
    PowerMockito.mockStatic(SouthboundMapper.class);
    when(SouthboundMapper.createConnectionInfo(any(OvsdbClient.class))).thenReturn(key);

    OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class);
    clients = new ConcurrentHashMap<>();
    clients.put(key, ovsdbConnectionInstance);
    MemberModifier.field(OvsdbConnectionManager.class, "clients").set(ovsdbConnManager, clients);

    suppress(MemberMatcher.method(OvsdbConnectionManager.class, "getConnectionInstance", ConnectionInfo.class));
    when(ovsdbConnManager.getConnectionInstance(any(ConnectionInfo.class))).thenReturn(ovsdbConnectionInstance);
    doNothing().when(txInvoker).invoke(any(TransactionCommand.class));

    when(SouthboundMapper.suppressLocalIpPort(any(ConnectionInfo.class))).thenReturn(key);

    // TODO: Write unit tests for EntityOwnershipService
    suppress(MemberMatcher.method(OvsdbConnectionManager.class, "unregisterEntityForOwnership",
            OvsdbConnectionInstance.class));
    instanceIdentifiers = new ConcurrentHashMap<>();
    field(OvsdbConnectionManager.class, "instanceIdentifiers").set(ovsdbConnManager, instanceIdentifiers);
    field(OvsdbConnectionManager.class, "nodeIdVsConnectionInstance").set(ovsdbConnManager, new HashMap<>());

    MemberModifier.suppress(MemberMatcher.method(OvsdbConnectionManager.class, "reconcileConnection",
            InstanceIdentifier.class, OvsdbNodeAugmentation.class));
    ReadTransaction tx = mock(ReadTransaction.class);
    when(db.newReadOnlyTransaction()).thenReturn(tx);
    when(tx.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
            .thenReturn(mock(FluentFuture.class));
    when(tx.exists(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
        .thenReturn(mock(FluentFuture.class));
    when(ovsdbConnectionInstance.getInstanceIdentifier()).thenReturn(mock(InstanceIdentifier.class));
    ovsdbConnManager.disconnected(externalClient);
    Map<ConnectionInfo, OvsdbConnectionInstance> testClients = Whitebox.getInternalState(ovsdbConnManager,
            "clients");
    assertEquals("Error, size of the hashmap is incorrect", 0, testClients.size());
}
 
Example 6
Source File: OvsdbBridgeUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testUpdateBridge() throws Exception {
    MemberModifier
            .suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "buildConnectionNode", Bridge.class));
    ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
    doNothing().when(transaction).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class),
            any(Node.class));

    // suppress calls to private methods
    MemberModifier
            .suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "getInstanceIdentifier", Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "buildBridgeNode", Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "deleteEntries",
            ReadWriteTransaction.class, List.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "protocolEntriesToRemove",
            InstanceIdentifier.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "externalIdsToRemove",
            InstanceIdentifier.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "bridgeOtherConfigsToRemove",
            InstanceIdentifier.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "getNodeId",
            Bridge.class));

    Bridge bridge = mock(Bridge.class);
    InstanceIdentifier<Node> connectionIId = mock(InstanceIdentifier.class);
    Whitebox.invokeMethod(ovsdbBridgeUpdateCommand, "updateBridge", transaction, bridge, connectionIId);
    verify(ovsdbBridgeUpdateCommand, times(3)).deleteEntries(any(ReadWriteTransaction.class), eq(null));
}
 
Example 7
Source File: TerminationPointCreateCommandTest.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes"})
@Test
@Ignore("This needs to be rewritten")
public void testExecute() throws Exception {
    MemberModifier.suppress(MemberMatcher.method(TerminationPointCreateCommand.class, "getChanges"));
    DataChangeEvent asynEvent = mock(DataChangeEvent.class);
    Map<InstanceIdentifier<?>, DataObject> map = new HashMap<>();
    OvsdbTerminationPointAugmentation terminationPoint = mock(OvsdbTerminationPointAugmentation.class);
    InstanceIdentifier terminationPointIid = mock(InstanceIdentifier.class);
    map.put(terminationPointIid, terminationPoint);
    when(asynEvent.getCreatedData()).thenReturn(map);
    when(terminationPoint.getName()).thenReturn(TERMINATION_POINT_NAME);

    Interface ovsInterface = mock(Interface.class);
    PowerMockito.mockStatic(TyperUtils.class);
    TransactionBuilder transaction = mock(TransactionBuilder.class);
    when(transaction.getTypedRowWrapper(eq(Interface.class))).thenReturn(ovsInterface);
    //createInterface()
    Operations op = (Operations) setField("op");
    Insert<GenericTableSchema> insert = mock(Insert.class);
    when(op.insert(any(Interface.class))).thenReturn(insert);
    when(insert.withId(anyString())).thenReturn(insert);
    MemberModifier.suppress(MemberMatcher.method(TerminationPointCreateCommand.class,
            "stampInstanceIdentifier", TransactionBuilder.class, InstanceIdentifier.class, String.class));
    when(ovsInterface.getName()).thenReturn(INTERFACE_NAME);

    Port port = mock(Port.class);
    when(transaction.getTypedRowWrapper(eq(Port.class))).thenReturn(port);
    when(op.insert(any(Port.class))).thenReturn(insert);

    Bridge bridge = mock(Bridge.class);
    when(transaction.getTypedRowWrapper(eq(Bridge.class))).thenReturn(bridge);
    doNothing().when(bridge).setName(anyString());
    PowerMockito.whenNew(UUID.class).withAnyArguments().thenReturn(mock(UUID.class));
    doNothing().when(bridge).setPorts(any(HashSet.class));

    BridgeOperationalState bridgeOpState = mock(BridgeOperationalState.class);

    terminationPointCreateCommand.execute(transaction, bridgeOpState, asynEvent,
            mock(InstanceIdentifierCodec.class));

    // TODO Actually verify something
}
 
Example 8
Source File: OpenVSwitchUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
    @Test
    // TODO This test needs to be re-done
    @Ignore("Broken mock-based test")
    public void testExecute() throws Exception {
        PowerMockito.mockStatic(TyperUtils.class);
        UUID uuid = mock(UUID.class);
        OpenVSwitch ovs = mock(OpenVSwitch.class);
        when(TyperUtils.extractRowsUpdated(eq(OpenVSwitch.class), any(TableUpdates.class), any(DatabaseSchema.class)))
                .thenReturn(ImmutableMap.of(uuid, ovs));
        OpenVSwitch ovs1 = mock(OpenVSwitch.class);
        when(TyperUtils.extractRowsOld(eq(OpenVSwitch.class), any(TableUpdates.class), any(DatabaseSchema.class)))
                .thenReturn(ImmutableMap.of(uuid, ovs1));

        //mock getUpdates() and getDbSchema()
        when(openVSwitchUpdateCommand.getUpdates()).thenReturn(updates);
        when(openVSwitchUpdateCommand.getDbSchema()).thenReturn(dbSchema);

        //Test getInstanceIdentifier(): case 1:
        // ovs.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) == true
        Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
        when(ovs.getExternalIdsColumn()).thenReturn(column);
        when(column.getData()).thenReturn(ImmutableMap.of(SouthboundConstants.IID_EXTERNAL_ID_KEY, "iidString"));
        PowerMockito.mockStatic(SouthboundUtil.class);
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "getOvsdbConnectionInstance"));
        InstanceIdentifier<Node> iid = mock(InstanceIdentifier.class);
//        when((InstanceIdentifier<Node>) SouthboundUtil.deserializeInstanceIdentifier(
//                any(InstanceIdentifierCodec.class), anyString())).thenReturn(iid);
        OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class);
        when(ovsdbConnectionInstance.getInstanceIdentifier()).thenReturn(iid);
        when(openVSwitchUpdateCommand.getOvsdbConnectionInstance()).thenReturn(ovsdbConnectionInstance);
        doNothing().when(ovsdbConnectionInstance).setInstanceIdentifier(any(InstanceIdentifier.class));

        OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = mock(OvsdbNodeAugmentationBuilder.class);
        PowerMockito.whenNew(OvsdbNodeAugmentationBuilder.class).withNoArguments().thenReturn(ovsdbNodeBuilder);

        //suppress the setter methods of the class
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setOvsVersion",
                OvsdbNodeAugmentationBuilder.class, OpenVSwitch.class));
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setDbVersion",
                OvsdbNodeAugmentationBuilder.class, OpenVSwitch.class));
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setDataPathTypes",
                OvsdbNodeAugmentationBuilder.class, OpenVSwitch.class));
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setInterfaceTypes",
                OvsdbNodeAugmentationBuilder.class, OpenVSwitch.class));
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setExternalIds",
                ReadWriteTransaction.class, OvsdbNodeAugmentationBuilder.class, OpenVSwitch.class, OpenVSwitch.class));
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setOtherConfig",
                InstanceIdentifierCodec.class, ReadWriteTransaction.class, OvsdbNodeAugmentationBuilder.class,
                OpenVSwitch.class, OpenVSwitch.class));
        MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "getConnectionInfo"));
        when(openVSwitchUpdateCommand.getConnectionInfo()).thenReturn(mock(ConnectionInfo.class));
        when(ovsdbNodeBuilder.setConnectionInfo(any(ConnectionInfo.class))).thenReturn(ovsdbNodeBuilder);

        NodeBuilder nodeBuilder = mock(NodeBuilder.class);
        PowerMockito.whenNew(NodeBuilder.class).withNoArguments().thenReturn(nodeBuilder);

        //suppress getNodeId()
        MemberModifier.suppress(
                MemberMatcher.method(OpenVSwitchUpdateCommand.class, "getNodeId", InstanceIdentifierCodec.class,
                        OpenVSwitch.class));
        when(nodeBuilder.setNodeId(any(NodeId.class))).thenReturn(nodeBuilder);
        when(ovsdbNodeBuilder.build()).thenReturn(mock(OvsdbNodeAugmentation.class));
        when(nodeBuilder.addAugmentation(eq(OvsdbNodeAugmentation.class), any(OvsdbNodeAugmentation.class)))
                .thenReturn(nodeBuilder);
        when(nodeBuilder.build()).thenReturn(mock(Node.class));
        ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
        doNothing().when(transaction).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class),
                any(Node.class));

        openVSwitchUpdateCommand.execute(transaction);
        verify(openVSwitchUpdateCommand, times(2)).getUpdates();
        verify(openVSwitchUpdateCommand, times(2)).getDbSchema();

        //Test getInstanceIdentifier(): case 2: ovs.getExternalIdsColumn() is null
        when(ovs.getExternalIdsColumn()).thenReturn(null);
        when(ovs.getUuid()).thenReturn(uuid);
        openVSwitchUpdateCommand.execute(transaction);
        verify(openVSwitchUpdateCommand, times(4)).getUpdates();
        verify(openVSwitchUpdateCommand, times(4)).getDbSchema();
    }
 
Example 9
Source File: OvsdbBridgeUpdateCommandTest.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
@Test
public void testBuildBridgeNode() throws Exception {
    NodeBuilder bridgeNodeBuilder = mock(NodeBuilder.class);
    PowerMockito.whenNew(NodeBuilder.class).withNoArguments().thenReturn(bridgeNodeBuilder);
    //suppress call to getNodeId()
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "getNodeId", Bridge.class));
    when(bridgeNodeBuilder.setNodeId(any(NodeId.class))).thenReturn(bridgeNodeBuilder);
    OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = mock(OvsdbBridgeAugmentationBuilder.class);
    PowerMockito.whenNew(OvsdbBridgeAugmentationBuilder.class).withNoArguments()
            .thenReturn(ovsdbBridgeAugmentationBuilder);
    Bridge bridge = mock(Bridge.class);
    when(bridge.getName()).thenReturn("bridge name");
    PowerMockito.whenNew(OvsdbBridgeName.class).withAnyArguments().thenReturn(mock(OvsdbBridgeName.class));
    when(ovsdbBridgeAugmentationBuilder.setBridgeName(any(OvsdbBridgeName.class)))
            .thenReturn(ovsdbBridgeAugmentationBuilder);
    when(bridge.getUuid()).thenReturn(mock(UUID.class));
    PowerMockito.whenNew(Uuid.class).withAnyArguments().thenReturn(mock(Uuid.class));
    when(ovsdbBridgeAugmentationBuilder.setBridgeUuid(any(Uuid.class))).thenReturn(ovsdbBridgeAugmentationBuilder);

    //suppress calls to the set methods
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setDataPath",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setDataPathType",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setProtocol",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setExternalIds",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setOtherConfig",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setFailMode",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setOpenFlowNodeRef",
            OvsdbBridgeAugmentationBuilder.class, Bridge.class));
    MemberModifier.suppress(MemberMatcher.method(OvsdbBridgeUpdateCommand.class, "setManagedBy",
            OvsdbBridgeAugmentationBuilder.class));

    when(ovsdbBridgeAugmentationBuilder.build()).thenReturn(mock(OvsdbBridgeAugmentation.class));
    when(bridgeNodeBuilder.addAugmentation(eq(OvsdbBridgeAugmentation.class), any(OvsdbBridgeAugmentation.class)))
            .thenReturn(bridgeNodeBuilder);
    Node node = mock(Node.class);
    when(bridgeNodeBuilder.build()).thenReturn(node);
    assertEquals(node, Whitebox.invokeMethod(ovsdbBridgeUpdateCommand, "buildBridgeNode", bridge));
}
 
Example 10
Source File: OvsdbPortRemoveCommandTest.java    From ovsdb with Eclipse Public License 1.0 4 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testExecute() throws Exception {
    when(ovsdbPortRemoveCommand.getUpdates()).thenReturn(mock(TableUpdates.class));
    when(ovsdbPortRemoveCommand.getDbSchema()).thenReturn(mock(DatabaseSchema.class));
    UUID uuid = mock(UUID.class);
    Map<UUID, Port> portRemovedRows = new HashMap<>();
    Port port = mock(Port.class);
    portRemovedRows.put(uuid, port);

    PowerMockito.mockStatic(TyperUtils.class);
    PowerMockito.doReturn(portRemovedRows).when(TyperUtils.class);
    TyperUtils.extractRowsRemoved(eq(Port.class), any(TableUpdates.class), any(DatabaseSchema.class));

    Map<UUID, Bridge> bridgeUpdatedRows = new HashMap<>();
    Bridge updatedBridgeData = mock(Bridge.class);
    bridgeUpdatedRows.put(uuid, updatedBridgeData);
    PowerMockito.doReturn(bridgeUpdatedRows).when(TyperUtils.class);
    TyperUtils.extractRowsUpdated(eq(Bridge.class), any(TableUpdates.class), any(DatabaseSchema.class));

    Map<UUID, Bridge> bridgeUpdatedOldRows = new HashMap<>();
    Bridge oldBridgeData = mock(Bridge.class);
    bridgeUpdatedOldRows.put(uuid, oldBridgeData);
    PowerMockito.doReturn(bridgeUpdatedOldRows).when(TyperUtils.class);
    TyperUtils.extractRowsOld(eq(Bridge.class), any(TableUpdates.class), any(DatabaseSchema.class));

    Column<GenericTableSchema, Set<UUID>> column = mock(Column.class);
    when(oldBridgeData.getPortsColumn()).thenReturn(column);
    Set<UUID> uuids = new HashSet<>();
    uuids.add(uuid);
    when(column.getData()).thenReturn(uuids);

    Column<GenericTableSchema, UUID> uuidColumn = mock(Column.class);
    when(port.getUuidColumn()).thenReturn(uuidColumn);
    when(uuidColumn.getData()).thenReturn(uuid);

    when(port.getName()).thenReturn(PORT_NAME);
    InstanceIdentifier<Node> nodeIID = mock(InstanceIdentifier.class);
    doReturn(mock(OvsdbConnectionInstance.class)).when(ovsdbPortRemoveCommand).getOvsdbConnectionInstance();

    PowerMockito.mockStatic(SouthboundMapper.class);
    PowerMockito.doReturn(nodeIID).when(SouthboundMapper.class);
    SouthboundMapper.createInstanceIdentifier(eq(null),
        any(OvsdbConnectionInstance.class), any(Bridge.class));

    MemberModifier.suppress(MemberModifier.methodsDeclaredIn(InstanceIdentifier.class));
    ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
    doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));

    ovsdbPortRemoveCommand.execute(transaction);
    verify(transaction).delete(any(LogicalDatastoreType.class), eq(null));
}