Search in sources :

Example 1 with JobPropertiesParser

use of com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser in project azure-iot-sdk-java by Azure.

the class JobPropertiesTest method fromJobPropertiesParser.

// Tests_SRS_SERVICE_SDK_JAVA_JOB_PROPERTIES_34_003: [This method shall convert the provided parser into a JobProperty object and return it.]
@Test
public void fromJobPropertiesParser() {
    // arrange
    JobPropertiesParser parser = Deencapsulation.newInstance(JobPropertiesParser.class);
    parser.setEndTimeUtc(new Date(System.currentTimeMillis()));
    parser.setStartTimeUtc(new Date(System.currentTimeMillis()));
    parser.setFailureReason("failureReason");
    parser.setInputBlobContainerUri("inputContainerUri");
    parser.setOutputBlobContainerUri("outputContainerUri");
    parser.setProgress(0);
    parser.setExcludeKeysInExport(false);
    parser.setJobId("jobId");
    parser.setStatus(JobProperties.JobStatus.COMPLETED.toString());
    parser.setType(JobProperties.JobType.IMPORT.toString());
    // act
    JobProperties jobProperties = jobPropertiesConstructorWithParser(parser);
    // assert
    assertEquals(parser.getInputBlobContainerUri(), jobProperties.getInputBlobContainerUri());
    assertEquals(parser.getOutputBlobContainerUri(), jobProperties.getOutputBlobContainerUri());
    assertEquals(parser.isExcludeKeysInExport(), jobProperties.getExcludeKeysInExport());
    assertEquals(parser.getType(), jobProperties.getType().toString());
    assertEquals(parser.getStatus(), jobProperties.getStatus().toString());
    assertEquals(parser.getProgress(), jobProperties.getProgress());
    assertEquals(parser.getJobIdFinal(), jobProperties.getJobId());
    assertEquals(parser.getFailureReason(), jobProperties.getFailureReason());
    assertEquals(parser.getEndTimeUtc(), jobProperties.getEndTimeUtc());
    assertEquals(parser.getStartTimeUtc(), jobProperties.getStartTimeUtc());
}
Also used : JobProperties(com.microsoft.azure.sdk.iot.service.JobProperties) JobPropertiesParser(com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser) Date(java.util.Date) Test(org.junit.Test)

Example 2 with JobPropertiesParser

use of com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser in project azure-iot-sdk-java by Azure.

the class JobPropertiesParserTest method jobIdCannotBeSetToNull.

// Tests_SRS_JOB_PROPERTIES_PARSER_34_005: [If the provided jobId is null, an IllegalArgumentException shall be thrown.]
@Test(expected = IllegalArgumentException.class)
public void jobIdCannotBeSetToNull() {
    // arrange
    JobPropertiesParser parser = new JobPropertiesParser();
    // act
    parser.setJobId(null);
}
Also used : JobPropertiesParser(com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser) Test(org.junit.Test)

Example 3 with JobPropertiesParser

use of com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser in project azure-iot-sdk-java by Azure.

the class JobPropertiesTest method toJobPropertiesParser.

// Tests_SRS_SERVICE_SDK_JAVA_JOB_PROPERTIES_34_002: [This method shall convert this into a JobPropertiesParser object and return it.]
@Test
public void toJobPropertiesParser() {
    // arrange
    JobProperties jobProperties = new JobProperties();
    jobProperties.setEndTimeUtc(new Date(System.currentTimeMillis()));
    jobProperties.setStartTimeUtc(new Date(System.currentTimeMillis()));
    jobProperties.setFailureReason("failureReason");
    jobProperties.setInputBlobContainerUri("inputContainerUri");
    jobProperties.setOutputBlobContainerUri("outputContainerUri");
    jobProperties.setProgress(0);
    jobProperties.setExcludeKeysInExport(false);
    jobProperties.setJobIdFinal("jobId");
    jobProperties.setStatus(JobProperties.JobStatus.COMPLETED);
    jobProperties.setType(JobProperties.JobType.IMPORT);
    // act
    JobPropertiesParser parser = toJobPropertiesParser(jobProperties);
    // assert
    assertEquals(parser.getInputBlobContainerUri(), jobProperties.getInputBlobContainerUri());
    assertEquals(parser.getOutputBlobContainerUri(), jobProperties.getOutputBlobContainerUri());
    assertEquals(parser.isExcludeKeysInExport(), jobProperties.getExcludeKeysInExport());
    assertEquals(parser.getType().toUpperCase(), jobProperties.getType().toString());
    assertEquals(parser.getStatus(), jobProperties.getStatus().toString());
    assertEquals(parser.getProgress(), jobProperties.getProgress());
    assertEquals(parser.getJobIdFinal(), jobProperties.getJobId());
    assertEquals(parser.getFailureReason(), jobProperties.getFailureReason());
    assertEquals(parser.getEndTimeUtc(), jobProperties.getEndTimeUtc());
    assertEquals(parser.getStartTimeUtc(), jobProperties.getStartTimeUtc());
}
Also used : JobProperties(com.microsoft.azure.sdk.iot.service.JobProperties) JobPropertiesParser(com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser) Date(java.util.Date) Test(org.junit.Test)

Example 4 with JobPropertiesParser

use of com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser in project azure-iot-sdk-java by Azure.

the class JobPropertiesParserTest method testBasicFunctionality.

// Tests_SRS_JOB_PROPERTIES_PARSER_34_001: [The constructor shall create and return an instance of a JobPropertiesParser object based off the provided json.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_002: [This method shall return a json representation of this.]
@Test
public void testBasicFunctionality() {
    // arrange
    Date date = new Date();
    JobPropertiesParser parser = new JobPropertiesParser();
    parser.setEndTimeUtc(date);
    parser.setStartTimeUtc(date);
    parser.setFailureReason("failureReason");
    parser.setInputBlobContainerUri("inputContainerUri");
    parser.setOutputBlobContainerUri("outputContainerUri");
    parser.setProgress(0);
    parser.setExcludeKeysInExport(false);
    parser.setJobId("jobId");
    parser.setStatus("status");
    parser.setType("type");
    parser.setStorageAuthenticationType(StorageAuthenticationType.KEY);
    // act
    JobPropertiesParser processedParser = new JobPropertiesParser(parser.toJson());
    // assert
    assertEquals(parser.isExcludeKeysInExport(), processedParser.isExcludeKeysInExport());
    assertEquals(parser.getFailureReason(), processedParser.getFailureReason());
    assertEquals(parser.getJobIdFinal(), processedParser.getJobIdFinal());
    assertEquals(parser.getInputBlobContainerUri(), processedParser.getInputBlobContainerUri());
    assertEquals(parser.getOutputBlobContainerUri(), processedParser.getOutputBlobContainerUri());
    assertEquals(parser.getProgress(), processedParser.getProgress());
    assertEquals(parser.getStatus(), processedParser.getStatus());
    assertEquals(parser.getType(), processedParser.getType());
    assertEquals(parser.getStorageAuthenticationType(), processedParser.getStorageAuthenticationType());
    String startTimeUtc = Deencapsulation.getField(processedParser, "startTimeUtcString");
    String endTimeUtc = Deencapsulation.getField(processedParser, "startTimeUtcString");
    assertEquals(ParserUtility.getDateStringFromDate(parser.getStartTimeUtc()), startTimeUtc);
    assertEquals(ParserUtility.getDateStringFromDate(parser.getEndTimeUtc()), endTimeUtc);
}
Also used : JobPropertiesParser(com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser) Date(java.util.Date) Test(org.junit.Test)

Example 5 with JobPropertiesParser

use of com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser in project azure-iot-sdk-java by Azure.

the class JobPropertiesParserTest method testGettersAndSetters.

// Tests_SRS_JOB_PROPERTIES_PARSER_34_010: [This method shall set the value of this object's JobId equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_011: [This method shall set the value of this object's type equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_012: [This method shall return the value of this object's type.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_013: [This method shall set the value of this object's inputBlobContainerUri equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_014: [This method shall return the value of this object's inputBlobContainerUri.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_015: [This method shall set the value of this object's outputBlobContainerUri equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_016: [This method shall return the value of this object's outputBlobContainerUri.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_018: [This method shall return the value of this object's jobId.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_019: [This method shall set the value of this object's startTimeUtc equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_020: [This method shall return the value of this object's startTimeUtc.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_021: [This method shall set the value of this object's endTimeUtc equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_022: [This method shall return the value of this object's endTimeUtc.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_023: [This method shall set the value of this object's status equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_024: [This method shall return the value of this object's status.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_025: [This method shall set the value of this object's progress equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_026: [This method shall return the value of this object's progress.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_027: [This method shall set the value of this object's excludeKeysInExport equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_028: [This method shall return the value of this object's excludeKeysInExport.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_029: [This method shall set the value of this object's failureReason equal to the provided value.]
// Tests_SRS_JOB_PROPERTIES_PARSER_34_030: [This method shall return the value of this object's failureReason.]
@Test
public void testGettersAndSetters() {
    // arrange
    Date date = new Date();
    String failureReason = "failureReason";
    String inputContainerUri = "inputContainerUri";
    String outputContainerUri = "outputContainerUri";
    int progress = 2;
    boolean excludeKeysInExport = false;
    String jobId = "jobId";
    String status = "status";
    String type = "type";
    JobPropertiesParser parser = new JobPropertiesParser();
    // act
    parser.setEndTimeUtc(date);
    parser.setStartTimeUtc(date);
    parser.setFailureReason(failureReason);
    parser.setInputBlobContainerUri(inputContainerUri);
    parser.setOutputBlobContainerUri(outputContainerUri);
    parser.setProgress(progress);
    parser.setExcludeKeysInExport(excludeKeysInExport);
    parser.setJobId(jobId);
    parser.setStatus(status);
    parser.setType(type);
    // assert
    assertEquals(date, parser.getStartTimeUtc());
    assertEquals(date, parser.getEndTimeUtc());
    assertEquals(failureReason, parser.getFailureReason());
    assertEquals(inputContainerUri, parser.getInputBlobContainerUri());
    assertEquals(outputContainerUri, parser.getOutputBlobContainerUri());
    assertEquals(progress, parser.getProgress());
    assertEquals(excludeKeysInExport, parser.isExcludeKeysInExport());
    assertEquals(jobId, parser.getJobId());
    assertEquals(status, parser.getStatus());
    assertEquals(type, parser.getType());
}
Also used : JobPropertiesParser(com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser) Date(java.util.Date) Test(org.junit.Test)

Aggregations

JobPropertiesParser (com.microsoft.azure.sdk.iot.deps.serializer.JobPropertiesParser)7 Test (org.junit.Test)5 Date (java.util.Date)4 JobProperties (com.microsoft.azure.sdk.iot.service.JobProperties)2