use of com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser in project azure-iot-sdk-java by Azure.
the class ConfigurationMetricsParserTest method constructorFromJson.
// Codes_SRS_CONFIGURATION_METRICS_PARSER_28_002: [The constructor shall take the provided json and convert
// it into a new ConfigurationMetricsParser and return it.]
@Test
public void constructorFromJson() {
// arrange
String json = "{\"results\":{\"abc\":3,\"def\":5}, " + "\"queries\":{\"c\":\"d\",\"e\":\"f\"}}";
// act
ConfigurationMetricsParser parser = new ConfigurationMetricsParser(json);
// assert
assertNotNull(parser);
Map<String, Long> resultsMap = parser.getResults();
assertEquals(new Long(3), resultsMap.get("abc"));
assertEquals(new Long(5), resultsMap.get("def"));
Map<String, String> queriesMap = parser.getQueries();
assertEquals("d", queriesMap.get("c"));
assertEquals("f", queriesMap.get("e"));
}
use of com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser in project azure-iot-sdk-java by Azure.
the class ConfigurationMetricsParserTest method gettersAndSetters.
// Tests_SRS_CONFIGURATION_METRICS_PARSER_28_005: [This method shall return the value of this object's results.]
// Tests_SRS_CONFIGURATION_METRICS_PARSER_28_006: [This method shall set the value of results to the provided value.]
// Tests_SRS_CONFIGURATION_METRICS_PARSER_28_007: [This method shall return the value of this object's queries.]
// Tests_SRS_CONFIGURATION_METRICS_PARSER_28_008: [This method shall set the value of queries to the provided value.]
@Test
public void gettersAndSetters() {
// arrange
HashMap<String, Long> results = new HashMap<String, Long>() {
{
put("abc", 3L);
put("def", 5L);
}
};
HashMap<String, String> queries = new HashMap<String, String>() {
{
put("c", "d");
put("e", "f");
}
};
ConfigurationMetricsParser parser = new ConfigurationMetricsParser();
// act
parser.setResults(results);
parser.setQueries(queries);
// assert
// assert
assertNotNull(parser);
Map<String, Long> resultsMap = parser.getResults();
assertEquals(new Long(3), resultsMap.get("abc"));
assertEquals(new Long(5), resultsMap.get("def"));
Map<String, String> queriesMap = parser.getQueries();
assertEquals("d", queriesMap.get("c"));
assertEquals("f", queriesMap.get("e"));
}
use of com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser 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