Search in sources :

Example 6 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorThrowsOnMalformedJson.

// SRS_RegistrationOperationStatusParser_25_003: [ This method shall throw IllegalArgumentException if Json cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorThrowsOnMalformedJson() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigning\"";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 7 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullSha256ThumbprintSigningCert.

// SRS_RegistrationOperationStatusParser_25_018: [ This method shall throw IllegalArgumentException if SHA256 Thumbprint from X509 Signing Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullSha256ThumbprintSigningCert() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 8 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorThrowsOnNullStatus.

// SRS_RegistrationOperationStatusParser_25_006: [ This method shall throw IllegalArgumentException if status cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorThrowsOnNullStatus() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigning\"," + "\"registrationState\":" + "{\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"" + "}" + "}";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 9 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorWithX509JsonThrowsOnNullVersionSigningCert.

// SRS_RegistrationOperationStatusParser_25_022: [ This method shall throw IllegalArgumentException if Version from X509 Signing Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullVersionSigningCert() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigned\"," + "\"registrationState\":" + "{\"x509\":" + "{\"certificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"," + "\"version\":" + TEST_VERSION + "}," + "\"enrollmentGroupId\":\"" + TEST_ENROLLMENT_GROUP_ID + "\"," + "\"signingCertificateInfo\":" + "{\"subjectName\":\"" + TEST_SUBJECT_NAME + "\"," + "\"sha1Thumbprint\":\"" + TEST_SHA1_THUMBPRINT + "\"," + "\"sha256Thumbprint\":\"" + TEST_SHA256_THUMBPRINT + "\"," + "\"issuerName\":\"" + TEST_ISSUER_NAME + "\"," + "\"notBeforeUtc\":\"2017-01-01T00:00:00Z\"," + "\"notAfterUtc\":\"2037-01-01T00:00:00Z\"," + "\"serialNumber\":\"" + TEST_SERIAL_NUMBER + "\"" + "}" + "}," + "\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"createdDateTimeUtc\":\"2017-07-21T20:56:19.3109747Z\"," + "\"assignedHub\":\"" + TEST_ASSIGNED_HUB + "\"," + "\"deviceId\":\"" + TEST_DEVICE_ID + "\"," + "\"status\":\"assigned\"," + "\"etag\":\"172d963d-ec26-41ba-84c4-afe5f6c93ef4\"," + "\"lastUpdatedDateTimeUtc\":\"2017-07-21T20:56:19.7978138Z\"}}\n";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 10 with RegistrationOperationStatusParser

use of com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser in project azure-iot-sdk-java by Azure.

the class RegistrationOperationStatusParserTest method constructorThrowsOnEmptyJson.

@Test(expected = IllegalArgumentException.class)
public void constructorThrowsOnEmptyJson() throws IllegalArgumentException, JsonParseException {
    final String json = "";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Aggregations

RegistrationOperationStatusParser (com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser)31 Test (org.junit.Test)27 ProvisioningDeviceClientAuthenticationException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientAuthenticationException)2 ProvisioningDeviceClientException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceClientException)2 ProvisioningDeviceHubException (com.microsoft.azure.sdk.iot.provisioning.device.internal.exceptions.ProvisioningDeviceHubException)1 DeviceRegistrationResultParser (com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.DeviceRegistrationResultParser)1 SecurityProviderTpm (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProviderTpm)1 SecurityProviderX509 (com.microsoft.azure.sdk.iot.provisioning.security.SecurityProviderX509)1 SecurityProviderException (com.microsoft.azure.sdk.iot.provisioning.security.exceptions.SecurityProviderException)1