use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method sendComplete_flow_OK.
/*
Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_029: [** The event handler shall check the status queue to get the response for the sent message **]**
Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_030: [** The event handler shall remove the response from the queue **]**
Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_031: [** The event handler shall get the exception from the response and throw is it is not null **]**
*/
@Test
public void sendComplete_flow_OK(@Mocked final AmqpResponseVerification mockedVerification) throws IotHubException, IOException {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpSendHandler amqpSendHandler = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
Queue<AmqpResponseVerification> testsendStatusQueue = new LinkedBlockingQueue<>();
testsendStatusQueue.add(mockedVerification);
Deencapsulation.setField(amqpSendHandler, "sendStatusQueue", testsendStatusQueue);
// Assert
new Expectations() {
{
mockedVerification.getException();
result = null;
}
};
// Act
amqpSendHandler.sendComplete();
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification in project azure-iot-sdk-java by Azure.
the class AmqpSendHandlerTest method sendComplete_throws_exception_if_found.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPSENDHANDLER_25_031: [** The event handler shall get the exception from the response and throw is it is not null **]**
@Test(expected = IotHubException.class)
public void sendComplete_throws_exception_if_found(@Mocked final AmqpResponseVerification mockedVerification, @Mocked final IotHubException mockedIotHubException) throws IotHubException, IOException {
// Arrange
String hostName = "aaa";
String userName = "bbb";
String sasToken = "ccc";
IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
AmqpSendHandler amqpSendHandler = new AmqpSendHandler(hostName, userName, sasToken, iotHubServiceClientProtocol);
Queue<AmqpResponseVerification> testsendStatusQueue = new LinkedBlockingQueue<>();
testsendStatusQueue.add(mockedVerification);
Deencapsulation.setField(amqpSendHandler, "sendStatusQueue", testsendStatusQueue);
// Assert
new Expectations() {
{
mockedVerification.getException();
result = mockedIotHubException;
}
};
// Act
amqpSendHandler.sendComplete();
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_if_released.
@Test
public void constructor_saves_if_released() {
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedReleased);
//Assert
new Verifications() {
{
assertNull(testVerification.getException());
}
};
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_NOT_ALLOWED_exception.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_003: [** The function shall save IotHubInvalidOperationException if the amqp delivery state is rejected and error condition is amqp error code amqp:not-allowed **]**
@Test
public void constructor_saves_NOT_ALLOWED_exception() {
//Arrange
String errorDescription = "TestDescription";
new NonStrictExpectations() {
{
mockedRejected.getError();
result = mockedErrorCondition;
mockedErrorCondition.getCondition();
result = AmqpError.NOT_ALLOWED;
mockedErrorCondition.getDescription();
result = errorDescription;
}
};
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
//Assert
new Verifications() {
{
assertTrue(testVerification.getException() instanceof IotHubInvalidOperationException);
}
};
}
use of com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification 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);
}
};
}
Aggregations