Here you can find the source of generateMetricsDataWithPartialWrongTypes(String metricPostfix, boolean generateRandomTenant, long collectionTime)
private static List<Map<String, Object>> generateMetricsDataWithPartialWrongTypes(String metricPostfix, boolean generateRandomTenant, long collectionTime)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Random; import java.util.TreeMap; public class Main { private static final Random random = new Random(); private static List<Map<String, Object>> generateMetricsDataWithPartialWrongTypes(String metricPostfix, boolean generateRandomTenant, long collectionTime) { List<Map<String, Object>> metricsList = generateMetricsDataWithAllWrongTypes(metricPostfix, generateRandomTenant, collectionTime); // add a few valid ones Map<String, Object> testMetric = new TreeMap<String, Object>(); if (generateRandomTenant) { testMetric.put("tenantId", random.nextInt()); }//w w w .jav a 2 s .c om testMetric.put("metricName", "mzord.small.numeric.metric" + metricPostfix); testMetric.put("ttlInSeconds", 1234566); testMetric.put("unit", "milliseconds"); testMetric.put("metricValue", 123); testMetric.put("collectionTime", collectionTime); metricsList.add(testMetric); // numeric metrics testMetric = new TreeMap<String, Object>(); if (generateRandomTenant) { testMetric.put("tenantId", random.nextInt()); } testMetric.put("metricName", "mzord.another.numeric.metric" + metricPostfix); testMetric.put("ttlInSeconds", 1234566); testMetric.put("unit", "ounces"); testMetric.put("metricValue", 4525); testMetric.put("collectionTime", collectionTime); metricsList.add(testMetric); return metricsList; } public static List<Map<String, Object>> generateMetricsDataWithAllWrongTypes(String metricPostfix, boolean generateRandomTenant, long collectionTime) { List<Map<String, Object>> metricsList = new ArrayList<Map<String, Object>>(); // String metric value Map<String, Object> testMetric = new TreeMap<String, Object>(); if (generateRandomTenant) { testMetric.put("tenantId", random.nextInt()); } testMetric.put("metricName", "mzord.string.metric" + metricPostfix); testMetric.put("ttlInSeconds", 1234566); testMetric.put("unit", "milliseconds"); testMetric.put("metricValue", "random_string"); testMetric.put("collectionTime", collectionTime); metricsList.add(testMetric); // String numeric metric value testMetric = new TreeMap<String, Object>(); if (generateRandomTenant) { testMetric.put("tenantId", random.nextInt()); } testMetric.put("metricName", "mzord.string.numeric.metric" + metricPostfix); testMetric.put("ttlInSeconds", 1234566); testMetric.put("unit", "milliseconds"); testMetric.put("metricValue", "666"); testMetric.put("collectionTime", collectionTime); metricsList.add(testMetric); // boolean metric value testMetric = new TreeMap<String, Object>(); if (generateRandomTenant) { testMetric.put("tenantId", random.nextInt()); } testMetric.put("metricName", "mzord.boolean.metric" + metricPostfix); testMetric.put("ttlInSeconds", 1234566); testMetric.put("unit", "milliseconds"); testMetric.put("metricValue", true); testMetric.put("collectionTime", collectionTime); metricsList.add(testMetric); return metricsList; } }