TimestampAttribute extends AbstractAttribute implements RangeAttribute { @Override public int registerXAttribute(XAttribute att) { if (att instanceof XAttributeTimestamp && this.getKey().equals(att.getKey())) { long value = ((XAttributeTimestamp) att).getValueMillis(); if (value < start) start = value; if (value > end) end = value; return 0; } else { return -1; } } TimestampAttribute(String key, AttributeLevel level); @Override int registerXAttribute(XAttribute att); @Override Object getMin(); @Override Object getMax();  }
@Test public void testRegisterXAttributeWithInvalidType() { TimestampAttribute att = new TimestampAttribute("timestamp", AttributeLevel.EVENT); int result = att.registerXAttribute(xAttFactory.createAttributeContinuous("timestamp", 100, null)); Assert.assertEquals(-1, result); }
@Test public void testRegisterXAttributeWithInvalidKey() { TimestampAttribute att = new TimestampAttribute("timestamp", AttributeLevel.EVENT); int result = att.registerXAttribute(xAttFactory.createAttributeTimestamp("invalid_key", datetime1, null)); Assert.assertEquals(-1, result); }
@Test public void testRegisterValidXAttribute() { TimestampAttribute att = new TimestampAttribute("timestamp", AttributeLevel.EVENT); XAttributeTimestamp xatt = xAttFactory.createAttributeTimestamp("timestamp", datetime1, null); int result = att.registerXAttribute(xatt); Assert.assertEquals(0, result); }