use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class CustomLoggerTest method testLogDebug.
// Tests_SRS_CUSTOMERLOGGER_25_002: [The function shall print message for DEBUG level.]
@Test
public void testLogDebug(@Mocked final Logger mockLogger) {
final String message = "This is DEBUG message";
new NonStrictExpectations() {
{
Logger.getLogger((Class) any);
result = mockLogger;
mockLogger.isEnabledFor(Level.DEBUG);
result = true;
}
};
new CustomLogger(this.getClass()).LogDebug(message);
new Verifications() {
{
mockLogger.debug(anyString);
times = 1;
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class AmqpsMessageTest method acknowledgeSetsRejectedDispositionForReject.
// Tests_SRS_AMQPSMESSAGE_14_003: [If the ACK_TYPE is REJECT, the function shall set a Rejected disposition on the private Delivery object.]
@Test
public void acknowledgeSetsRejectedDispositionForReject(@Mocked final Rejected mockRejected) {
new NonStrictExpectations() {
{
new Rejected();
result = mockRejected;
}
};
AmqpsMessage message = new AmqpsMessage();
message.setDelivery(mockDelivery);
message.acknowledge(AmqpsMessage.ACK_TYPE.REJECT);
final Delivery expectedDelivery = mockDelivery;
new Verifications() {
{
expectedDelivery.disposition(mockRejected);
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class AmqpsMessageTest method acknowledgeSettlesDelivery.
// Tests_SRS_AMQPSMESSAGE_14_005: [The function shall settle the delivery after setting the proper disposition.]
@Test
public void acknowledgeSettlesDelivery() {
AmqpsMessage message = new AmqpsMessage();
message.setDelivery(mockDelivery);
message.acknowledge(AmqpsMessage.ACK_TYPE.COMPLETE);
message.acknowledge(AmqpsMessage.ACK_TYPE.ABANDON);
message.acknowledge(AmqpsMessage.ACK_TYPE.REJECT);
final Delivery expectedDelivery = mockDelivery;
new Verifications() {
{
expectedDelivery.settle();
times = 3;
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class IotHubSendTaskTest method runSendsAllMessages.
// Tests_SRS_IOTHUBSENDTASK_11_001: [The constructor shall save the transport.]
// Tests_SRS_IOTHUBSENDTASK_11_002: [The function shall send all messages on the transport queue.]
@Test
public void runSendsAllMessages() throws IOException, URISyntaxException {
IotHubSendTask sendTask = new IotHubSendTask(mockTransport);
sendTask.run();
new Verifications() {
{
mockTransport.sendMessages();
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class MqttIotHubConnectionTest method receiveMessageSucceeds.
// Tests_SRS_MQTTIOTHUBCONNECTION_15_014: [The function shall attempt to consume a message
// from the received messages queue.]
@Test
public void receiveMessageSucceeds() throws IOException {
baseExpectations();
openExpectations();
final byte[] expectedMessageBody = { 0x61, 0x62, 0x63 };
new NonStrictExpectations() {
{
mockDeviceMethods.receive();
result = null;
mockDeviceTwin.receive();
result = null;
mockDeviceMessaging.receive();
result = new Message(expectedMessageBody);
}
};
MqttIotHubConnection connection = new MqttIotHubConnection(mockConfig);
connection.open();
Message message = connection.receiveMessage();
byte[] actualMessageBody = message.getBytes();
for (int i = 0; i < expectedMessageBody.length; i++) {
assertEquals(expectedMessageBody[i], actualMessageBody[i]);
}
new Verifications() {
{
mockDeviceTwin.receive();
times = 1;
mockDeviceMethods.receive();
times = 1;
mockDeviceMessaging.receive();
times = 1;
}
};
}
Aggregations