Search in sources :

Example 31 with Verifications

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);
        }
    };
}
Also used : Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Example 32 with Verifications

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);
        }
    };
}
Also used : Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Example 33 with Verifications

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());
        }
    };
}
Also used : Verifications(mockit.Verifications) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Example 34 with Verifications

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());
        }
    };
}
Also used : Verifications(mockit.Verifications) AmqpResponseVerification(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification) Test(org.junit.Test)

Example 35 with Verifications

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;
        }
    };
}
Also used : IOException(java.io.IOException) Verifications(mockit.Verifications) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Aggregations

Verifications (mockit.Verifications)103 Test (org.junit.Test)103 NonStrictExpectations (mockit.NonStrictExpectations)66 MqttIotHubConnection (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection)14 MqttDeviceMethod (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod)12 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)11 AmqpResponseVerification (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification)11 HttpsConnection (com.microsoft.azure.sdk.iot.device.transport.https.HttpsConnection)10 HttpsMethod (com.microsoft.azure.sdk.iot.device.transport.https.HttpsMethod)10 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)10 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)10 FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)9 HttpConnection (com.microsoft.azure.sdk.iot.service.transport.http.HttpConnection)9 HttpMethod (com.microsoft.azure.sdk.iot.service.transport.http.HttpMethod)9 HashMap (java.util.HashMap)9 Template (com.microsoft.azure.sdk.iot.device.Template)8 CustomLogger (com.microsoft.azure.sdk.iot.device.CustomLogger)6 DeviceMethodMessage (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceMethodMessage)6 IOException (java.io.IOException)6 MqttMessaging (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttMessaging)5