Search in sources :

Example 91 with Verifications

use of mockit.Verifications in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationReceiverTest method constructorSaveProperties.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_002: [** The constructor shall create a new instance of AmqpFileUploadNotificationReceive object **]**
@Test
public void constructorSaveProperties() throws Exception {
    // Arrange
    final String hostName = "aaa";
    final String userName = "bbb";
    final String sasToken = "ccc";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    // Act
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol, mockedProxyOptions, mockedSslContext);
    new Verifications() {

        {
            new AmqpFileUploadNotificationReceive(anyString, anyString, anyString, iotHubServiceClientProtocol, (ProxyOptions) any, (SSLContext) any);
            times = 1;
        }
    };
}
Also used : FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) Verifications(mockit.Verifications) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) AmqpFileUploadNotificationReceive(com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpFileUploadNotificationReceive) Test(org.junit.Test)

Example 92 with Verifications

use of mockit.Verifications in project azure-iot-sdk-java by Azure.

the class FileUploadNotificationReceiverTest method openAsync.

// Tests_SRS_SERVICE_SDK_JAVA_FILEUPLOADNOTIFICATIONRECEIVER_25_010: [ The function shall create an async wrapper around the open() function call ]
@Test
public void openAsync() throws Exception {
    // Arrange
    final String hostName = "xxx";
    final String userName = "xxx";
    final String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FileUploadNotificationReceiver fileUploadNotificationReceiver = Deencapsulation.newInstance(FileUploadNotificationReceiver.class, hostName, userName, sasToken, iotHubServiceClientProtocol, mockedProxyOptions, mockedSslContext);
    // Act
    CompletableFuture<Void> completableFuture = fileUploadNotificationReceiver.openAsync();
    completableFuture.get();
    // Assert
    new Verifications() {

        {
            amqpFileUploadNotificationReceive.open();
            times = 1;
            fileUploadNotificationReceiver.open();
            times = 1;
        }
    };
}
Also used : FileUploadNotificationReceiver(com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver) Verifications(mockit.Verifications) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) Test(org.junit.Test)

Example 93 with Verifications

use of mockit.Verifications in project azure-iot-sdk-java by Azure.

the class ServiceAuthenticationWithSharedAccessPolicyTokenTest method populateStorePolicyNameAndToken.

/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_TOKEN_21_005: [The populateWithAuthenticationProperties shall save the policyName and token to the target object.] */
@Test
public void populateStorePolicyNameAndToken() {
    // arrange
    final String policyName = "validPolicyName";
    final String token = "validToken";
    final ProvisioningConnectionString provisioningConnectionString = mockedProvisioningConnectionString;
    Object authenticationMethodResult = Deencapsulation.newInstance("com.microsoft.azure.sdk.iot.provisioning.service.auth.ServiceAuthenticationWithSharedAccessPolicyToken", new Class[] { String.class, String.class }, policyName, token);
    // act
    Deencapsulation.invoke(authenticationMethodResult, "populateWithAuthenticationProperties", new Class[] { ProvisioningConnectionString.class }, provisioningConnectionString);
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKeyName", policyName);
            times = 1;
            Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessSignature", token);
            times = 1;
        }
    };
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) Verifications(mockit.Verifications) Test(org.junit.Test)

Example 94 with Verifications

use of mockit.Verifications in project azure-iot-sdk-java by Azure.

the class ServiceAuthenticationWithSharedAccessPolicyTokenTest method populateSetKeyToNull.

/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_TOKEN_21_006: [The populateWithAuthenticationProperties shall set the access key to null.] */
@Test
public void populateSetKeyToNull() {
    // arrange
    final String policyName = "validPolicyName";
    final String token = "validToken";
    final ProvisioningConnectionString provisioningConnectionString = mockedProvisioningConnectionString;
    Object authenticationMethodResult = Deencapsulation.newInstance("com.microsoft.azure.sdk.iot.provisioning.service.auth.ServiceAuthenticationWithSharedAccessPolicyToken", new Class[] { String.class, String.class }, policyName, token);
    // act
    Deencapsulation.invoke(authenticationMethodResult, "populateWithAuthenticationProperties", new Class[] { ProvisioningConnectionString.class }, provisioningConnectionString);
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKey", new Class[] { String.class }, (String) null);
            times = 1;
        }
    };
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) Verifications(mockit.Verifications) Test(org.junit.Test)

Example 95 with Verifications

use of mockit.Verifications in project azure-iot-sdk-java by Azure.

the class ServiceAuthenticationWithSharedAccessPolicyKeyTest method populateStorePolicyNameAndKey.

/* Tests_SRS_SERVICE_AUTHENTICATION_WITH_SHARED_ACCESS_POLICY_KEY_21_005: [The populateWithAuthenticationProperties shall save the policyName and key to the target object.] */
@Test
public void populateStorePolicyNameAndKey() {
    // arrange
    final String policyName = "validPolicyName";
    final String key = "validKey";
    final ProvisioningConnectionString provisioningConnectionString = mockedProvisioningConnectionString;
    Object authenticationMethodResult = Deencapsulation.newInstance("com.microsoft.azure.sdk.iot.provisioning.service.auth.ServiceAuthenticationWithSharedAccessPolicyKey", new Class[] { String.class, String.class }, policyName, key);
    // act
    Deencapsulation.invoke(authenticationMethodResult, "populateWithAuthenticationProperties", new Class[] { ProvisioningConnectionString.class }, provisioningConnectionString);
    // assert
    new Verifications() {

        {
            Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKeyName", policyName);
            times = 1;
            Deencapsulation.invoke(mockedProvisioningConnectionString, "setSharedAccessKey", key);
            times = 1;
        }
    };
}
Also used : ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) ProvisioningConnectionString(com.microsoft.azure.sdk.iot.provisioning.service.auth.ProvisioningConnectionString) Verifications(mockit.Verifications) Test(org.junit.Test)

Aggregations

Verifications (mockit.Verifications)329 Test (org.junit.Test)326 NonStrictExpectations (mockit.NonStrictExpectations)163 Expectations (mockit.Expectations)52 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)34 Tuple (org.apache.storm.tuple.Tuple)28 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)24 AmqpResponseVerification (com.microsoft.azure.sdk.iot.service.transport.amqps.AmqpResponseVerification)22 HttpConnection (com.microsoft.azure.sdk.iot.service.transport.http.HttpConnection)21 HttpMethod (com.microsoft.azure.sdk.iot.service.transport.http.HttpMethod)21 ArrayList (java.util.ArrayList)21 List (java.util.List)21 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)20 FileUploadNotificationReceiver (com.microsoft.azure.sdk.iot.service.FileUploadNotificationReceiver)18 MqttDeviceMethod (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod)17 HashMap (java.util.HashMap)16 MqttIotHubConnection (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttIotHubConnection)14 IOException (java.io.IOException)14 Values (org.apache.storm.tuple.Values)14 SaslListenerImpl (com.microsoft.azure.sdk.iot.deps.transport.amqp.SaslListenerImpl)13