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