Search in sources :

Example 1 with ConfigurationContentParser

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

the class ConfigurationContent method toConfigurationContentParser.

public ConfigurationContentParser toConfigurationContentParser() {
    ConfigurationContentParser parser = new ConfigurationContentParser();
    parser.setModulesContent(this.modulesContent);
    parser.setDeviceContent(this.deviceContent);
    return parser;
}
Also used : ConfigurationContentParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationContentParser)

Example 2 with ConfigurationContentParser

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

the class ConfigurationContentTest method ToParserSuccess.

// Tests_SRS_SERVICE_SDK_JAVA_CONFIGURATION_CONTENT_34_003: [This function shall return a configuration parser instance with the same modules content and device content as this object.]
@Test
public void ToParserSuccess() {
    // arrange
    Map<String, Map<String, Object>> mc = new HashMap<String, Map<String, Object>>() {

        {
            put("mproperty", new HashMap<String, Object>() {

                {
                    put("abc", "123");
                    put("cde", "456");
                }
            });
        }
    };
    Map<String, Object> dc = new HashMap<String, Object>() {

        {
            put("dproperty", new HashMap<String, Integer>() {

                {
                    put("c", 3);
                    put("d", 4);
                }
            });
        }
    };
    ConfigurationContent cc = new ConfigurationContent();
    // act
    ConfigurationContentParser parser = cc.toConfigurationContentParser();
    // assert
    assertEquals(cc.getDeviceContent(), parser.getDeviceContent());
    assertEquals(cc.getModulesContent(), parser.getModulesContent());
}
Also used : HashMap(java.util.HashMap) ConfigurationContent(com.microsoft.azure.sdk.iot.service.ConfigurationContent) Map(java.util.Map) HashMap(java.util.HashMap) ConfigurationContentParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationContentParser) Test(org.junit.Test)

Example 3 with ConfigurationContentParser

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

the class Configuration method toConfigurationParser.

/**
 * Converts this into a ConfigurationParser object. To serialize a Configuration object, it must first be converted
 * to a ConfigurationParser object.
 *
 * @return the ConfigurationParser object that can be serialized.
 */
ConfigurationParser toConfigurationParser() {
    // Codes_SRS_SERVICE_SDK_JAVA_CONFIGURATION_28_004: [This method shall return a new instance of a ConfigurationParser
    // object that is populated using the properties of this.]
    ConfigurationParser configurationParser = new ConfigurationParser();
    configurationParser.setId(this.id);
    configurationParser.setSchemaVersion(this.schemaVersion);
    configurationParser.setLabels(this.labels);
    configurationParser.setTargetCondition(this.targetCondition);
    configurationParser.setCreatedTimeUtc(ParserUtility.getDateTimeUtc(this.createdTimeUtc));
    configurationParser.setLastUpdatedTimeUtc(ParserUtility.getDateTimeUtc(this.lastUpdatedTimeUtc));
    configurationParser.setPriority(this.priority);
    configurationParser.setETag(this.etag);
    if (this.content != null) {
        ConfigurationContentParser parser = new ConfigurationContentParser();
        parser.setDeviceContent(this.content.getDeviceContent());
        parser.setModulesContent(this.content.getModulesContent());
        parser.setModuleContent(this.content.getModuleContent());
        configurationParser.setContent(parser);
    }
    if (this.systemMetrics != null) {
        ConfigurationMetricsParser parser = new ConfigurationMetricsParser();
        parser.setQueries(this.systemMetrics.getQueries());
        parser.setResults(this.systemMetrics.getResults());
        configurationParser.setSystemMetrics(parser);
    }
    if (this.metrics != null) {
        ConfigurationMetricsParser parser = new ConfigurationMetricsParser();
        parser.setQueries(this.metrics.getQueries());
        parser.setResults(this.metrics.getResults());
        configurationParser.setMetrics(parser);
    }
    return configurationParser;
}
Also used : ConfigurationParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationParser) ConfigurationMetricsParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser) ConfigurationContentParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationContentParser)

Aggregations

ConfigurationContentParser (com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationContentParser)3 ConfigurationMetricsParser (com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser)1 ConfigurationParser (com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationParser)1 ConfigurationContent (com.microsoft.azure.sdk.iot.service.ConfigurationContent)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1