本文整理了Java中org.mockito.Mockito.refEq()
方法的一些代码示例,展示了Mockito.refEq()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.refEq()
方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:refEq
暂无
代码示例来源:origin: inovait/neatle
private void verifyCommandFail() {
CommandResult result = CommandResult.createErrorResult(characteristicUUID, BluetoothGatt.GATT_FAILURE);
verify(commandObserver, times(1)).finished(eq(readCommand), refEq(result, "timestamp"));
verify(operationCommandObserver, times(1)).finished(eq(readCommand), refEq(result, "timestamp"));
}
}
代码示例来源:origin: it.tidalwave.metadata/it-tidalwave-metadata
@Test
public void testSetLatestModificationTime()
{
holder.addPropertyChangeListener(listener);
holder.setLatestModificationTime(TIMESTAMP1);
holder.setLatestModificationTime(TIMESTAMP2);
final InOrder inOrder = inOrder(listener);
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "latestModificationTime", null, TIMESTAMP1)));
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "latestModificationTime", TIMESTAMP1, TIMESTAMP2)));
verifyNoMoreInteractions(listener);
}
代码示例来源:origin: inovait/neatle
@Test
public void testOnCharacteristicRead() {
BluetoothGattCharacteristic otherCharacteristic = Mockito.mock(BluetoothGattCharacteristic.class);
when(otherCharacteristic.getUuid()).thenReturn(Neatle.createUUID(123));
when(gatt.getService(eq(serviceUUID))).thenReturn(gattService);
when(gattService.getCharacteristic(characteristicUUID)).thenReturn(gattCharacteristic);
when(gatt.readCharacteristic(eq(gattCharacteristic))).thenReturn(true);
when(gattCharacteristic.getValue()).thenReturn(new byte[]{21, 22});
when(gattCharacteristic.getUuid()).thenReturn(characteristicUUID);
readCommand.execute(device, operationCommandObserver, gatt);
// Unknown characteristic
readCommand.onCharacteristicRead(gatt, otherCharacteristic, BluetoothGatt.GATT_SUCCESS);
verify(commandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
verify(operationCommandObserver, times(0)).finished(any(Command.class), any(CommandResult.class));
Mockito.reset(commandObserver, operationCommandObserver);
// Known characteristic
readCommand.onCharacteristicRead(gatt, gattCharacteristic, BluetoothGatt.GATT_SUCCESS);
CommandResult result = CommandResult.createCharacteristicRead(gattCharacteristic, BluetoothGatt.GATT_SUCCESS);
verify(commandObserver, times(1)).finished(eq(readCommand), refEq(result, "timestamp"));
verify(operationCommandObserver, times(1)).finished(eq(readCommand), refEq(result, "timestamp"));
}
代码示例来源:origin: it.tidalwave.metadata/it-tidalwave-metadata
@Test
public void testBeanIsAvailableChange()
{
stub(bean.isAvailable()).toReturn(false);
holder.addPropertyChangeListener(listener);
final TimestampProviderMock timestampProvider = (TimestampProviderMock)TimestampProvider.Locator.findTimestampProvider();
// Test a bean property change that makes bean.isAvailable() to transition from false to true
timestampProvider.setTimestamp(TIMESTAMP1);
assertFalse(bean.isAvailable());
stub(bean.isAvailable()).toReturn(true);
holder.propertyChangeListener.propertyChange(new MyPropertyChangeEvent(bean, "stringProperty", null, "newValue"));
// Test a bean property change that makes bean.isAvailable() to transition from true to false
timestampProvider.setTimestamp(TIMESTAMP2);
assertTrue(bean.isAvailable());
stub(bean.isAvailable()).toReturn(false);
holder.propertyChangeListener.propertyChange(new MyPropertyChangeEvent(bean, "stringProperty", "newValue", null));
// Test a bean property change that makes bean.isAvailable() to stay false
timestampProvider.setTimestamp(TIMESTAMP3);
assertFalse(bean.isAvailable());
holder.propertyChangeListener.propertyChange(new MyPropertyChangeEvent(bean, "stringProperty", null, null));
final InOrder inOrder = inOrder(listener);
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "latestModificationTime", null, TIMESTAMP1)));
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "available", false, true)));
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "latestModificationTime", TIMESTAMP1, TIMESTAMP2)));
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "available", true, false)));
inOrder.verify(listener).propertyChange(refEq(new MyPropertyChangeEvent(holder, "latestModificationTime", TIMESTAMP2, TIMESTAMP3)));
verifyNoMoreInteractions(listener);
}
}
内容来源于网络,如有侵权,请联系作者删除!