use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method replaceTagsThrowsIfDeviceIDIsEmpty.
@Test(expected = IllegalArgumentException.class)
public void replaceTagsThrowsIfDeviceIDIsEmpty() throws Exception {
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = "";
}
};
//act
testTwin.replaceTags(mockedDevice);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method updateTwinThrowsIfDeviceIDIsEmpty.
@Test(expected = IllegalArgumentException.class)
public void updateTwinThrowsIfDeviceIDIsEmpty() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = "";
}
};
//act
testTwin.updateTwin(mockedDevice);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method replaceDesiredPropertiesThrowsIfDeviceIDIsEmpty.
@Test(expected = IllegalArgumentException.class)
public void replaceDesiredPropertiesThrowsIfDeviceIDIsEmpty() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = "";
}
};
//act
testTwin.replaceDesiredProperties(mockedDevice);
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method updateTwinThrowsIfJsonIsNull.
/*
**Tests_SRS_DEVICETWIN_25_046: [** The function shall throw IOException if updateTwin Api call returned an empty or null json**]**
*/
@Test(expected = IOException.class)
public void updateTwinThrowsIfJsonIsNull() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
Map<String, Object> testMap = new HashMap<>();
testMap.put("TestKey", "TestValue");
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = "SomeDevID";
Deencapsulation.invoke(mockedDevice, "getDesiredMap");
result = testMap;
Deencapsulation.invoke(mockedDevice, "getTagsMap");
result = testMap;
Deencapsulation.invoke(mockedDevice, "getTwinParser");
result = mockedTwinParser;
mockedTwinParser.updateTwin((Map<String, Object>) any, null, (Map<String, Object>) any);
result = null;
}
};
//act
testTwin.updateTwin(mockedDevice);
//assert
new Verifications() {
{
mockedConnectionString.getUrlTwin(anyString);
times = 1;
mockedTwinParser.updateTwin((Map<String, Object>) any, null, (Map<String, Object>) any);
times = 1;
}
};
}
use of com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method replaceDesiredPropertiesThrowsIfJsonIsNull.
/*
**Tests_SRS_DEVICETWIN_25_045: [** If resetDesiredProperty call returns null or empty string then this method shall throw IOException**]**
*/
@Test(expected = IOException.class)
public void replaceDesiredPropertiesThrowsIfJsonIsNull() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = "SomeDevID";
Deencapsulation.invoke(mockedDevice, "getTwinParser");
result = mockedTwinParser;
mockedTwinParser.resetDesiredProperty((Map<String, Object>) any);
result = null;
}
};
//act
testTwin.replaceDesiredProperties(mockedDevice);
//assert
new Verifications() {
{
mockedConnectionString.getUrlTwinDesired(anyString);
times = 1;
mockedTwinParser.resetDesiredProperty((Map<String, Object>) any);
times = 1;
}
};
}
Aggregations