Search in sources :

Example 1 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 constructorWithErrorJsonSucceed.

// SRS_DeviceRegistrationResultParser_25_010: [ This method shall return the parsed errorCode. ]
// SRS_DeviceRegistrationResultParser_25_011: [ This method shall return the parsed errorMessage. ]
@Test
public void constructorWithErrorJsonSucceed() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigning\"," + "\"registrationState\":" + "{\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"errorCode\":\"" + TEST_ERROR_CODE + "\"," + "\"errorMessage\":\"" + TEST_ERROR_MESSAGE + "\"," + "\"status\":\"assigning\"}" + "}";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
    assertNotNull(operationsRegistrationOperationStatusParser.getOperationId());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getRegistrationId());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getStatus());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getErrorCode());
    assertEquals((Integer) Integer.parseInt(TEST_ERROR_CODE), operationsRegistrationOperationStatusParser.getRegistrationState().getErrorCode());
    assertNotNull(operationsRegistrationOperationStatusParser.getStatus());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getErrorMessage());
    assertEquals(TEST_ERROR_MESSAGE, operationsRegistrationOperationStatusParser.getRegistrationState().getErrorMessage());
    assertNotNull(operationsRegistrationOperationStatusParser.getStatus());
    assertNull(operationsRegistrationOperationStatusParser.getRegistrationState().getTpm());
    assertNull(operationsRegistrationOperationStatusParser.getRegistrationState().getX509());
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 2 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 constructorWithX509JsonThrowsOnNullNotBeforeUtc.

// SRS_RegistrationOperationStatusParser_25_012: [ This method shall throw IllegalArgumentException if NotAfterUtc from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullNotBeforeUtc() 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 + "\"," + "\"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 + "\"," + "\"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 3 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 constructorWithX509JsonThrowsOnNullIssuerName.

// SRS_RegistrationOperationStatusParser_25_007: [ This method shall throw IllegalArgumentException if Issuer Name from X509 Certificate Info cannot be parsed. ]
@Test(expected = IllegalArgumentException.class)
public void constructorWithX509JsonThrowsOnNullIssuerName() 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 + "\"," + "\"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 + "\"," + "\"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 4 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 constructorWithNoHSMJsonSucceed.

// SRS_RegistrationOperationStatusParser_25_002: [ This method shall parse the provided Json. ]
@Test
public void constructorWithNoHSMJsonSucceed() throws IllegalArgumentException, JsonParseException {
    final String json = "{\"operationId\":\"" + TEST_OPERATION_ID + "\"," + "\"status\":\"assigning\"," + "\"registrationState\":" + "{\"registrationId\":\"" + TEST_REGISTRATION_ID + "\"," + "\"status\":\"assigning\"}" + "}";
    RegistrationOperationStatusParser operationsRegistrationOperationStatusParser = RegistrationOperationStatusParser.createFromJson(json);
    assertNotNull(operationsRegistrationOperationStatusParser.getOperationId());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getRegistrationId());
    assertNotNull(operationsRegistrationOperationStatusParser.getRegistrationState().getStatus());
    assertNotNull(operationsRegistrationOperationStatusParser.getStatus());
    assertNull(operationsRegistrationOperationStatusParser.getRegistrationState().getTpm());
    assertNull(operationsRegistrationOperationStatusParser.getRegistrationState().getX509());
}
Also used : RegistrationOperationStatusParser(com.microsoft.azure.sdk.iot.provisioning.device.internal.parser.RegistrationOperationStatusParser) Test(org.junit.Test)

Example 5 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 constructorThrowsOnNullJson.

// SRS_RegistrationOperationStatusParser_25_001: [ This method shall throw IllegalArgumentException if provided Json is null or empty. ]
@Test(expected = IllegalArgumentException.class)
public void constructorThrowsOnNullJson() throws IllegalArgumentException, JsonParseException {
    final String json = null;
    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