Search in sources :

Example 11 with AmqpResponseVerification

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_UNAUTHORIZED_ACCESS_exception.

//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_004: [** The function shall save IotHubUnathorizedException if the amqp delivery state is rejected and error condition is amqp error code amqp:unauthorized-access **]**
@Test
public void constructor_saves_UNAUTHORIZED_ACCESS_exception() {
    //Arrange
    String errorDescription = "TestDescription";
    new NonStrictExpectations() {

        {
            mockedRejected.getError();
            result = mockedErrorCondition;
            mockedErrorCondition.getCondition();
            result = AmqpError.UNAUTHORIZED_ACCESS;
            mockedErrorCondition.getDescription();
            result = errorDescription;
        }
    };
    //Act
    AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
    //Assert
    new Verifications() {

        {
            assertTrue(testVerification.getException() instanceof IotHubUnathorizedException);
        }
    };
}
Also used : Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Example 12 with AmqpResponseVerification

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_IMPLEMENTED_exception.

//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_002: [** The function shall save IotHubNotSupportedException if the amqp delivery state is rejected and error condition is amqp error code amqp:not-implemented **]**
@Test
public void constructor_saves_NOT_IMPLEMENTED_exception() {
    //Arrange
    String errorDescription = "TestDescription";
    new NonStrictExpectations() {

        {
            mockedRejected.getError();
            result = mockedErrorCondition;
            mockedErrorCondition.getCondition();
            result = AmqpError.NOT_IMPLEMENTED;
            mockedErrorCondition.getDescription();
            result = errorDescription;
        }
    };
    //Act
    AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
    //Assert
    new Verifications() {

        {
            assertTrue(testVerification.getException() instanceof IotHubNotSupportedException);
        }
    };
}
Also used : Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Example 13 with AmqpResponseVerification

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_rejected.

@Test
public void constructor_saves_if_rejected() {
    //Arrange
    new NonStrictExpectations() {

        {
            mockedRejected.getError();
            result = mockedErrorCondition;
            mockedErrorCondition.getCondition();
            result = AmqpError.NOT_FOUND;
        }
    };
    //Act
    AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
    //Assert
    new Verifications() {

        {
            assertNotNull(testVerification.getException());
        }
    };
}
Also used : Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Aggregations

AmqpResponseVerification (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification)13 Test (org.junit.Test)13 Verifications (mockit.Verifications)11 NonStrictExpectations (mockit.NonStrictExpectations)7 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)2 AmqpSendHandler (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpSendHandler)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 Expectations (mockit.Expectations)2