use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method open_async.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_011: [The function shall create an async wrapper around the open() function call]
@Test
public void open_async() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
// Assert
new Expectations() {
{
amqpReceive.open();
feedbackReceiver.open();
}
};
// Act
CompletableFuture<Void> completableFuture = feedbackReceiver.openAsync();
completableFuture.get();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method receive_with_timout_async.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_014: [The function shall create an async wrapper around the receive(long timeoutMs) function call]
@Test
public void receive_with_timout_async() throws Exception {
// Arrange
long timeoutMs = 1000;
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
// Assert
new Expectations() {
{
amqpReceive.receive(timeoutMs);
feedbackReceiver.receive(anyLong);
}
};
// Act
CompletableFuture<FeedbackBatch> completableFuture = feedbackReceiver.receiveAsync(timeoutMs);
completableFuture.get();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method constructor_save_properties.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_002: [The constructor shall store deviceId]
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_003: [The constructor shall create a new instance of AmqpReceive object]
@Test
public void constructor_save_properties() throws Exception {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
new Expectations() {
{
amqpReceive = new AmqpReceive(anyString, anyString, anyString, iotHubServiceClientProtocol);
}
};
// Act
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
// Assert
assertEquals(deviceId, Deencapsulation.getField(feedbackReceiver, "deviceId"));
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method open_async_without_deviceId.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_011: [The function shall create an async wrapper around the open() function call]
@Test
public void open_async_without_deviceId() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
// Assert
new Expectations() {
{
amqpReceive.open();
feedbackReceiver.open();
}
};
// Act
CompletableFuture<Void> completableFuture = feedbackReceiver.openAsync();
completableFuture.get();
}
use of mockit.Expectations in project azure-iot-sdk-java by Azure.
the class FeedbackReceiverTest method close_async.
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_012: [The function shall create an async wrapper around the close() function call]
@Test
public void close_async() throws Exception {
// Arrange
String hostName = "xxx";
String userName = "xxx";
String sasToken = "xxx";
String deviceId = "xxx";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
// Assert
new Expectations() {
{
amqpReceive.close();
feedbackReceiver.close();
}
};
// Act
CompletableFuture<Void> completableFuture = feedbackReceiver.closeAsync();
completableFuture.get();
}
Aggregations