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;
}
};
}
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;
}
};
}
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;
}
};
}
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;
}
};
}
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;
}
};
}
Aggregations