Search in sources :

Example 16 with ProvisioningAmqpOperations

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method constructorSucceeds.

// SRS_ContractAPIAmqp_07_001: [The constructor shall save the scope id and hostname.]
@Test
public void constructorSucceeds() throws ProvisioningDeviceClientException {
    // arrange
    // act
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    // assert
    assertEquals(TEST_SCOPE_ID, Deencapsulation.getField(provisioningAmqpOperations, "idScope"));
    assertEquals(TEST_HOST_NAME, Deencapsulation.getField(provisioningAmqpOperations, "hostName"));
}
Also used : ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Example 17 with ProvisioningAmqpOperations

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method sendStatusThrowsOnResponseCallbackNull.

// SRS_ProvisioningAmqpOperations_07_015: [sendStatusMessage shall throw ProvisioningDeviceClientException if either operationId or responseCallback are null or empty.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendStatusThrowsOnResponseCallbackNull() throws ProvisioningDeviceClientException, IOException, InterruptedException {
    // arrange
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    // act
    provisioningAmqpOperations.sendStatusMessage(TEST_OPERATION_ID, null, null);
// assert
}
Also used : ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Example 18 with ProvisioningAmqpOperations

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method openThrowsOnOpenFailure.

// SRS_ProvisioningAmqpOperations_07_004: [open shall throw ProvisioningDeviceClientException if either registrationId or sslContext are null or empty.]
@Test(expected = ProvisioningDeviceConnectionException.class)
public void openThrowsOnOpenFailure() throws ProvisioningDeviceClientException, IOException {
    // arrange
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    new NonStrictExpectations() {

        {
            mockedAmqpConnection.setListener((AmqpListener) any);
            mockedAmqpConnection.open();
            result = new Exception();
        }
    };
    // act
    provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) ProvisioningDeviceConnectionException(com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceConnectionException) IOException(java.io.IOException) ProvisioningDeviceClientException(com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException) ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Example 19 with ProvisioningAmqpOperations

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method sendRegisterMessageThrowsInterrruptedException.

// SRS_ProvisioningAmqpOperations_07_012: [This method shall throw ProvisioningDeviceClientException if any failure is encountered.]
@Test(expected = ProvisioningDeviceClientException.class)
public void sendRegisterMessageThrowsInterrruptedException() throws Exception {
    // arrange
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    new NonStrictExpectations() {

        {
            mockedAmqpConnection.setListener((AmqpListener) any);
            mockedAmqpConnection.open();
        }
    };
    provisioningAmqpOperations.open(TEST_REGISTRATION_ID, mockedSSLContext, null, false);
    new NonStrictExpectations() {

        {
            mockedAmqpConnection.sendAmqpMessage(mockedAmqpMessage);
            mockedAmqpConnection.isConnected();
            result = new InterruptedException();
        }
    };
    // act
    provisioningAmqpOperations.sendRegisterMessage(mockedResponseCallback, null, null);
// assert
}
Also used : NonStrictExpectations(mockit.NonStrictExpectations) ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Example 20 with ProvisioningAmqpOperations

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations in project azure-iot-sdk-java by Azure.

the class ProvisioningAmqpOperationsTest method openThrowsOnNullRegistrationId.

// SRS_ProvisioningAmqpOperations_07_004: [open shall throw ProvisioningDeviceClientException if either registrationId or sslContext are null or empty.]
@Test(expected = ProvisioningDeviceConnectionException.class)
public void openThrowsOnNullRegistrationId() throws ProvisioningDeviceClientException {
    // arrange
    ProvisioningAmqpOperations provisioningAmqpOperations = new ProvisioningAmqpOperations(TEST_SCOPE_ID, TEST_HOST_NAME);
    // act
    provisioningAmqpOperations.open(null, mockedSSLContext, null, false);
// assert
}
Also used : ProvisioningAmqpOperations(com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations) Test(org.junit.Test)

Aggregations

ProvisioningAmqpOperations (com.microsoft.azure.sdk.iot.provisioning.device.internal.contract.amqp.ProvisioningAmqpOperations)24 Test (org.junit.Test)24 NonStrictExpectations (mockit.NonStrictExpectations)12 Verifications (mockit.Verifications)5 IOException (java.io.IOException)3 AmqpMessage (com.microsoft.azure.sdk.iot.deps.transport.amqp.AmqpMessage)2 ProvisioningDeviceClientException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException)2 ProvisioningDeviceConnectionException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceConnectionException)2