use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method replaceDesiredPropertiesThrowsIfDeviceIDIsNull.
@Test(expected = IllegalArgumentException.class)
public void replaceDesiredPropertiesThrowsIfDeviceIDIsNull() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = null;
}
};
//act
testTwin.replaceDesiredProperties(mockedDevice);
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method updateTwinDoesNotThrowsIfOnlyDesiredHasValue.
@Test
public void updateTwinDoesNotThrowsIfOnlyDesiredHasValue() 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 = null;
mockedTwinParser.updateTwin((Map<String, Object>) any, null, (Map<String, Object>) any);
result = "SomeJsonString";
}
};
//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;
mockedHttpRequest.setReadTimeoutMillis(anyInt);
times = 1;
mockedHttpRequest.setHeaderField(anyString, anyString);
times = 5;
mockedHttpRequest.send();
times = 1;
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method replaceTagsThrowsJsonIsEmpty.
@Test(expected = IOException.class)
public void replaceTagsThrowsJsonIsEmpty() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = "SomeDevID";
mockedTwinParser.resetTags((Map<String, Object>) any);
result = "";
}
};
//act
testTwin.replaceTags(mockedDevice);
//assert
new Verifications() {
{
mockedConnectionString.getUrlTwinTags(anyString);
times = 1;
mockedTwinParser.resetTags((Map<String, Object>) any);
times = 1;
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method replaceDesiredPropertiesThrowsIfJsonIsEmpty.
@Test(expected = IOException.class)
public void replaceDesiredPropertiesThrowsIfJsonIsEmpty() 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 = "";
}
};
//act
testTwin.replaceDesiredProperties(mockedDevice);
//assert
new Verifications() {
{
mockedConnectionString.getUrlTwinDesired(anyString);
times = 1;
mockedTwinParser.resetDesiredProperty((Map<String, Object>) any);
times = 1;
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class DeviceTwinTest method updateTwinThrowsIfDeviceIDIsNull.
@Test(expected = IllegalArgumentException.class)
public void updateTwinThrowsIfDeviceIDIsNull() throws Exception {
//arrange
final String connectionString = "testString";
DeviceTwin testTwin = DeviceTwin.createFromConnectionString(connectionString);
new NonStrictExpectations() {
{
mockedDevice.getDeviceId();
result = null;
}
};
//act
testTwin.updateTwin(mockedDevice);
}
Aggregations