use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod in project azure-iot-sdk-java by Azure.
the class MqttDeviceMethodTest method stopSucceedsDoesNotCallUnSubscribeIfStopped.
@Test
public void stopSucceedsDoesNotCallUnSubscribeIfStopped() throws IOException {
//arrange
MqttDeviceMethod testMethod = new MqttDeviceMethod();
testMethod.start();
testMethod.stop();
//act
testMethod.stop();
//assert
new Verifications() {
{
Deencapsulation.invoke(mockedMqtt, "unsubscribe", anyString);
maxTimes = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod in project azure-iot-sdk-java by Azure.
the class MqttDeviceMethodTest method sendDoesNotSendOnDifferentMessageType.
/*
Tests_SRS_MqttDeviceMethod_25_017: [**send method shall return if the message is not of Type DeviceMethod.**]**
*/
@Test
public void sendDoesNotSendOnDifferentMessageType() throws IOException {
final byte[] actualPayload = "TestMessage".getBytes();
final DeviceMethodMessage testMessage = new DeviceMethodMessage(actualPayload);
testMessage.setMessageType(MessageType.DeviceTwin);
MqttDeviceMethod testMethod = new MqttDeviceMethod();
testMethod.start();
//act
testMethod.send(testMessage);
//assert
new Verifications() {
{
Deencapsulation.invoke(mockedMqtt, "publish", anyString, actualPayload);
maxTimes = 0;
Deencapsulation.invoke(mockedMqtt, "subscribe", anyString);
maxTimes = 0;
}
};
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod in project azure-iot-sdk-java by Azure.
the class MqttDeviceMethodTest method startSucceedsDoesNotCallsSubscribeIfStarted.
@Test
public void startSucceedsDoesNotCallsSubscribeIfStarted() throws IOException {
//arrange
MqttDeviceMethod testMethod = new MqttDeviceMethod();
testMethod.start();
//act
testMethod.start();
//assert
new Verifications() {
{
Deencapsulation.invoke(mockedMqtt, "subscribe", anyString);
maxTimes = 0;
}
};
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod in project azure-iot-sdk-java by Azure.
the class MqttDeviceMethodTest method sendThrowsOnNullRequestID.
/*
Tests_SRS_MqttDeviceMethod_25_021: [**send method shall throw an IoException if message contains a null or empty request id if the operation is of type DEVICE_OPERATION_METHOD_SEND_RESPONSE.**]**
*/
@Test(expected = IOException.class)
public void sendThrowsOnNullRequestID() throws IOException {
final byte[] actualPayload = "TestMessage".getBytes();
final DeviceMethodMessage testMessage = new DeviceMethodMessage(actualPayload);
testMessage.setMessageType(MessageType.DeviceMethods);
testMessage.setDeviceOperationType(DEVICE_OPERATION_METHOD_SEND_RESPONSE);
MqttDeviceMethod testMethod = new MqttDeviceMethod();
testMethod.start();
//act
testMethod.send(testMessage);
}
use of com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod in project azure-iot-sdk-java by Azure.
the class MqttDeviceMethodTest method startSucceedsCalls.
/*
Tests_SRS_MqttDeviceMethod_25_014: [**start method shall just mark that this class is ready to start.**]**
*/
@Test
public void startSucceedsCalls() throws IOException {
//arrange
MqttDeviceMethod testMethod = new MqttDeviceMethod();
//act
testMethod.start();
//assert
new Verifications() {
{
Deencapsulation.invoke(mockedMqtt, "subscribe", anyString);
times = 0;
}
};
}
Aggregations