@Test
public void testMetricType() {
Locator locator = Locator.createLocatorFromPathComponents("tenantId", "metricName");
Metric metric = new Metric(locator, "Foo", System.currentTimeMillis(), new TimeValue(5, TimeUnit.HOURS), "Unknown");
Assert.assertEquals("S", metric.getDataType().toString());
Assert.assertTrue(metric.getDataType().equals(DataType.STRING));
Assert.assertTrue("Metric should be string", metric.isString());
Assert.assertTrue(DataType.isKnownMetricType(metric.getDataType()));
metric = new Metric(locator, 1234567L, System.currentTimeMillis(), new TimeValue(5, TimeUnit.HOURS), "Unknown");
Assert.assertEquals("L", metric.getDataType().toString());
Assert.assertTrue(metric.getDataType().equals(DataType.LONG));
Assert.assertTrue("Metric should be numeric", metric.isNumeric());
Assert.assertTrue(DataType.isKnownMetricType(metric.getDataType()));
metric = new Metric(locator, 1234567.678, System.currentTimeMillis(), new TimeValue(5, TimeUnit.HOURS), "Unknown");
Assert.assertEquals("D", metric.getDataType().toString());
Assert.assertTrue(metric.getDataType().equals(DataType.DOUBLE));
Assert.assertTrue("Metric should be numeric", metric.isNumeric());
Assert.assertTrue(DataType.isKnownMetricType(metric.getDataType()));
metric = new Metric(locator, 1234567, System.currentTimeMillis(), new TimeValue(5, TimeUnit.HOURS), "Unknown");
Assert.assertEquals("I", metric.getDataType().toString());
Assert.assertTrue(metric.getDataType().equals(DataType.INT));
Assert.assertTrue("Metric should be numeric", metric.isNumeric());
Assert.assertTrue(DataType.isKnownMetricType(metric.getDataType()));
metric = new Metric(locator, false, System.currentTimeMillis(), new TimeValue(5, TimeUnit.HOURS), "Unknown");
Assert.assertEquals("B", metric.getDataType().toString());
Assert.assertTrue(metric.getDataType().equals(DataType.BOOLEAN));
Assert.assertTrue("Metric should be boolean", metric.isBoolean());
Assert.assertTrue(DataType.isKnownMetricType(metric.getDataType()));