use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_RESOURCE_LIMIT_EXCEEDED_exception.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_005: [** The function shall save IotHubDeviceMaximumQueueDepthExceededException if the amqp delivery state is rejected and error condition is amqp error code amqp:resource-limit-exceeded **]**
@Test
public void constructor_saves_RESOURCE_LIMIT_EXCEEDED_exception() {
//Arrange
String errorDescription = "TestDescription";
new NonStrictExpectations() {
{
mockedRejected.getError();
result = mockedErrorCondition;
mockedErrorCondition.getCondition();
result = AmqpError.RESOURCE_LIMIT_EXCEEDED;
mockedErrorCondition.getDescription();
result = errorDescription;
}
};
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
//Assert
new Verifications() {
{
assertTrue(testVerification.getException() instanceof IotHubDeviceMaximumQueueDepthExceededException);
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method getExceptionGets.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_007: [** The function shall return the exception saved earlier by the constructor **]**
@Test
public void getExceptionGets() {
//Arrange
String errorDescription = "TestDescription";
new NonStrictExpectations() {
{
mockedRejected.getError();
result = mockedErrorCondition;
mockedErrorCondition.getCondition();
result = AmqpError.RESOURCE_LIMIT_EXCEEDED;
mockedErrorCondition.getDescription();
result = errorDescription;
}
};
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
//Assert
new Verifications() {
{
assertTrue(testVerification.getException() instanceof IotHubDeviceMaximumQueueDepthExceededException);
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_if_accepted.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_006: [** The function shall save null exception if the amqp delivery state is accepted or received or released or modified **]**
@Test
public void constructor_saves_if_accepted() {
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedAccepted);
//Assert
new Verifications() {
{
assertNull(testVerification.getException());
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_if_modified.
@Test
public void constructor_saves_if_modified() {
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedModified);
//Assert
new Verifications() {
{
assertNull(testVerification.getException());
}
};
}
use of mockit.Verifications in project azure-iot-sdk-java by Azure.
the class DeviceClientTest method openBadOpensTransportThrows.
/* Codes_SRS_DEVICECLIENT_21_007: [If the opening a connection via deviceIO is not successful, the open shall throw IOException.] */
@Test
public void openBadOpensTransportThrows() throws IOException, URISyntaxException {
// arrange
final String connString = "HostName=iothub.device.com;CredentialType=SharedAccessKey;DeviceId=testdevice;" + "SharedAccessKey=adjkl234j52=";
final IotHubClientProtocol protocol = IotHubClientProtocol.AMQPS;
new NonStrictExpectations() {
{
mockDeviceIO.open();
result = new IOException();
}
};
DeviceClient client = new DeviceClient(connString, protocol);
// act
try {
client.open();
} catch (IOException expected) {
// Don't do anything, throw expected.
}
// assert
new Verifications() {
{
mockDeviceIO.open();
times = 1;
}
};
}
Aggregations