本文整理汇总了Java中org.powermock.api.support.membermodification.MemberModifier.suppress方法的典型用法代码示例。如果您正苦于以下问题:Java MemberModifier.suppress方法的具体用法?Java MemberModifier.suppress怎么用?Java MemberModifier.suppress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.powermock.api.support.membermodification.MemberModifier
的用法示例。
在下文中一共展示了MemberModifier.suppress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetOtherConfig
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testSetOtherConfig() throws Exception {
OpenVSwitch oldEntry = mock(OpenVSwitch.class);
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(openVSwitch.getOtherConfigColumn()).thenReturn(column);
Map<String, String> map = new HashMap<>();
when(column.getData()).thenReturn(map);
when(oldEntry.getOtherConfigColumn()).thenReturn(column);
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "removeOldConfigs",
ReadWriteTransaction.class, Map.class, OpenVSwitch.class));
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setNewOtherConfigs",
OvsdbNodeAugmentationBuilder.class, Map.class));
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = mock(OvsdbNodeAugmentationBuilder.class);
Whitebox.invokeMethod(openVSwitchUpdateCommand, "setOtherConfig",
transaction, ovsdbNodeBuilder, oldEntry, openVSwitch);
verify(openVSwitch, times(2)).getOtherConfigColumn();
verify(oldEntry, times(2)).getOtherConfigColumn();
PowerMockito.verifyPrivate(openVSwitchUpdateCommand).invoke("removeOldConfigs",
any(ReadWriteTransaction.class),
any(Map.class), any(OpenVSwitch.class));
}
示例2: testRemoveOldConfigs
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
public void testRemoveOldConfigs() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
Map<String, String> oldOtherConfigs = new HashMap<>();
oldOtherConfigs.put("OpenvswitchOtherConfigsKey", "OpenvswitchOtherConfigsValue");
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
//suppress getNodeId()
MemberModifier.suppress(
MemberMatcher.method(OpenVSwitchUpdateCommand.class, "getNodeId", OpenVSwitch.class));
PowerMockito.whenNew(NodeKey.class).withAnyArguments().thenReturn(mock(NodeKey.class));
OpenVSwitch ovs = mock(OpenVSwitch.class);
Whitebox.invokeMethod(openVSwitchUpdateCommand, "removeOldConfigs",
transaction, oldOtherConfigs, ovs);
verify(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
}
示例3: testSetExternalIds
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testSetExternalIds() throws Exception {
OpenVSwitch oldEntry = mock(OpenVSwitch.class);
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
Column<GenericTableSchema, Map<String, String>> column = mock(Column.class);
when(openVSwitch.getExternalIdsColumn()).thenReturn(column);
Map<String, String> map = new HashMap<>();
when(column.getData()).thenReturn(map);
when(oldEntry.getExternalIdsColumn()).thenReturn(column);
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "removeExternalIds",
ReadWriteTransaction.class, Map.class, OpenVSwitch.class));
MemberModifier.suppress(MemberMatcher.method(OpenVSwitchUpdateCommand.class, "setNewExternalIds",
OvsdbNodeAugmentationBuilder.class, Map.class));
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
OvsdbNodeAugmentationBuilder ovsdbNodeBuilder = mock(OvsdbNodeAugmentationBuilder.class);
Whitebox.invokeMethod(openVSwitchUpdateCommand, "setExternalIds",
transaction, ovsdbNodeBuilder, oldEntry, openVSwitch);
verify(openVSwitch, times(2)).getExternalIdsColumn();
verify(oldEntry, times(2)).getExternalIdsColumn();
PowerMockito.verifyPrivate(openVSwitchUpdateCommand).invoke("removeExternalIds",
any(ReadWriteTransaction.class), any(Map.class),
any(OpenVSwitch.class));
}
示例4: testRemoveExternalIds
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
public void testRemoveExternalIds() throws Exception {
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
Map<String, String> oldExternalIds = new HashMap<>();
oldExternalIds.put("OpenvswitchExternalIdKey", "OpenvswitchExternalIdValue");
doNothing().when(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
//suppress getNodeId()
MemberModifier.suppress(
MemberMatcher.method(OpenVSwitchUpdateCommand.class, "getNodeId", OpenVSwitch.class));
PowerMockito.whenNew(NodeKey.class).withAnyArguments().thenReturn(mock(NodeKey.class));
OpenVSwitch ovs = mock(OpenVSwitch.class);
Whitebox.invokeMethod(openVSwitchUpdateCommand, "removeExternalIds",
transaction, oldExternalIds, ovs);
verify(transaction).delete(any(LogicalDatastoreType.class), any(KeyedInstanceIdentifier.class));
}
示例5: testExecute
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecute() throws Exception {
updatedBridgeRows = new HashMap<>();
UUID uuid = mock(UUID.class);
Bridge bridge = mock(Bridge.class);
updatedBridgeRows.put(uuid, bridge);
MemberModifier.field(OvsdbControllerRemovedCommand.class, "updatedBridgeRows")
.set(ovsdbControllerRemovedCommand, updatedBridgeRows);
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.createInstanceIdentifier(any(InstanceIdentifierCodec.class),
any(OvsdbConnectionInstance.class), any(Bridge.class)))
.thenReturn(mock(InstanceIdentifier.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbControllerRemovedCommand.class, "deleteControllers",
ReadWriteTransaction.class, List.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbControllerRemovedCommand.class, "controllerEntriesToRemove",
InstanceIdentifier.class, Bridge.class));
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
ovsdbControllerRemovedCommand.execute(transaction);
PowerMockito.verifyPrivate(ovsdbControllerRemovedCommand).invoke("deleteControllers",
any(ReadWriteTransaction.class), any(List.class));
PowerMockito.verifyPrivate(ovsdbControllerRemovedCommand).invoke("controllerEntriesToRemove",
any(ReadWriteTransaction.class), any(Bridge.class));
}
示例6: testExecute
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecute() throws Exception {
updatedOpenVSwitchRows = new HashMap<>();
UUID uuid = mock(UUID.class);
OpenVSwitch openVSwitch = mock(OpenVSwitch.class);
updatedOpenVSwitchRows.put(uuid, openVSwitch);
MemberModifier.field(OvsdbManagersRemovedCommand.class, "updatedOpenVSwitchRows")
.set(ovsdbManagersRemovedCommand, updatedOpenVSwitchRows);
PowerMockito.mockStatic(SouthboundMapper.class);
OvsdbConnectionInstance ovsdbConnectionInstance = mock(OvsdbConnectionInstance.class);
when(ovsdbManagersRemovedCommand.getOvsdbConnectionInstance()).thenReturn(ovsdbConnectionInstance);
when(ovsdbConnectionInstance.getNodeId()).thenReturn(mock(NodeId.class));
when(SouthboundMapper.createInstanceIdentifier(any(NodeId.class))).thenReturn(mock(InstanceIdentifier.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbManagersRemovedCommand.class, "deleteManagers",
ReadWriteTransaction.class, List.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbManagersRemovedCommand.class, "managerEntriesToRemove",
InstanceIdentifier.class, OpenVSwitch.class));
ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
ovsdbManagersRemovedCommand.execute(transaction);
PowerMockito.verifyPrivate(ovsdbManagersRemovedCommand).invoke("deleteManagers",
any(ReadWriteTransaction.class), any(List.class));
PowerMockito.verifyPrivate(ovsdbManagersRemovedCommand).invoke("managerEntriesToRemove",
any(InstanceIdentifier.class), any(OpenVSwitch.class));
}
示例7: testExecute
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@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);
PowerMockito.verifyPrivate(ovsdbControllerUpdateCommand).invoke("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);
}
示例8: testExecute
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@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();
}
示例9: testBuildTerminationPoint1
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
public void testBuildTerminationPoint1() throws Exception {
Interface interfaceUpdate = mock(Interface.class);
when(interfaceUpdate.getName()).thenReturn(INTERFACE_NAME);
when(interfaceUpdate.getUuid()).thenReturn(mock(UUID.class));
PowerMockito.whenNew(Uuid.class).withAnyArguments().thenReturn(mock(Uuid.class));
OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder = mock(
OvsdbTerminationPointAugmentationBuilder.class);
when(tpAugmentationBuilder.setName(anyString())).thenReturn(tpAugmentationBuilder);
when(tpAugmentationBuilder.setInterfaceUuid(any(Uuid.class))).thenReturn(tpAugmentationBuilder);
MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaces", Interface.class,
OvsdbTerminationPointAugmentationBuilder.class));
Whitebox.invokeMethod(ovsdbPortUpdateCommand, "buildTerminationPoint", tpAugmentationBuilder, interfaceUpdate);
verify(tpAugmentationBuilder).setName(anyString());
verify(tpAugmentationBuilder).setInterfaceUuid(any(Uuid.class));
PowerMockito.verifyPrivate(ovsdbPortUpdateCommand).invoke("updateInterfaces", any(Interface.class),
any(OvsdbTerminationPointAugmentationBuilder.class));
}
示例10: testUpdateInterfaces
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUpdateInterfaces() throws Exception {
Interface interfaceUpdate = mock(Interface.class);
Column<GenericTableSchema, String> typeColumn = mock(Column.class);
when(interfaceUpdate.getTypeColumn()).thenReturn(typeColumn);
when(typeColumn.getData()).thenReturn(OVSDB_INTERFACE_TYPE);
MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterface", Interface.class,
String.class, OvsdbTerminationPointAugmentationBuilder.class));
OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder = mock(
OvsdbTerminationPointAugmentationBuilder.class);
Whitebox.invokeMethod(ovsdbPortUpdateCommand, "updateInterfaces", interfaceUpdate,
ovsdbTerminationPointBuilder);
PowerMockito.verifyPrivate(ovsdbPortUpdateCommand).invoke("updateInterface", any(Interface.class), anyString(),
any(OvsdbTerminationPointAugmentationBuilder.class));
}
示例11: testExecute
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@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);
PowerMockito.verifyPrivate(ovsdbBridgeUpdateCommand).invoke("updateBridge", any(ReadWriteTransaction.class),
any(Bridge.class), any(InstanceIdentifier.class));
}
示例12: testPushFlow
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
public void testPushFlow() {
MemberModifier.suppress(MemberMatcher.method(LldpFlowManager.class, "writeDataTransaction",
NodeId.class, FlowBuilder.class, FlowAction.class));
arpFlowManager.pushFlow(nodeId, flowAction);
Mockito.verify(arpFlowManager).writeDataTransaction(any(NodeId.class),
any(FlowBuilder.class), any(FlowAction.class));
}
示例13: testPushFlow
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@Test
public void testPushFlow() throws Exception {
MemberModifier.suppress(MemberMatcher.method(LldpFlowManager.class, "writeDataTransaction", NodeId.class, FlowBuilder.class, FlowAction.class));
MemberModifier.suppress(MemberMatcher.method(LldpFlowManager.class, "createLldpReplyToControllerFlow"));
when(lldpFlowManager.writeDataTransaction(any(NodeId.class), any(FlowBuilder.class), any(FlowAction.class))).thenReturn(true);
NodeId nodeId = mock(NodeId.class);
lldpFlowManager.pushFlow(nodeId, FlowAction.ADD_FLOW);
Mockito.verify(lldpFlowManager).writeDataTransaction(any(NodeId.class), any(FlowBuilder.class), any(FlowAction.class));
}
示例14: testExecute
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@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(AsyncDataChangeEvent.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(AsyncDataChangeEvent.class),
eq(OvsdbTerminationPointAugmentation.class))).thenReturn(updated);
TransactionBuilder transactionBuilder = mock(TransactionBuilder.class);
terminationPointUpdateCommand.execute(transactionBuilder, mock(BridgeOperationalState.class),
mock(AsyncDataChangeEvent.class), mock(InstanceIdentifierCodec.class));
// TODO Verify something useful
}
示例15: testDisconnected
import org.powermock.api.support.membermodification.MemberModifier; //导入方法依赖的package包/类
@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);
MemberModifier.suppress(MemberMatcher.method(OvsdbConnectionManager.class, "reconcileConnection",
InstanceIdentifier.class, OvsdbNodeAugmentation.class));
ReadOnlyTransaction tx = mock(ReadOnlyTransaction.class);
when(db.newReadOnlyTransaction()).thenReturn(tx);
when(tx.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
.thenReturn(mock(CheckedFuture.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());
}