ContinuousAttribute extends AbstractAttribute implements RangeAttribute { @Override public int registerXAttribute(XAttribute att) { if (att instanceof XAttributeContinuous && this.getKey().equals(att.getKey())) { double value = ((XAttributeContinuous) att).getValue(); if (!indexMap.containsKey(value)) { values.add(value); indexMap.put(value, values.size()-1); return (values.size()-1); } else { return -1; } } else { return -1; } } ContinuousAttribute(String key, AttributeLevel level); @Override int registerXAttribute(XAttribute att); @Override Object getMin(); @Override Object getMax();  }
@Test public void testRegisterXAttributeWithInvalidType() { ContinuousAttribute att = new ContinuousAttribute("concept:name", AttributeLevel.EVENT); int result = att.registerXAttribute(xAttFactory.createAttributeDiscrete("concept:name", 100, null)); Assert.assertEquals(-1, result); }
@Test public void testRegisterXAttributeWithInvalidKey() { ContinuousAttribute att = new ContinuousAttribute("concept:name", AttributeLevel.EVENT); int result = att.registerXAttribute(xAttFactory.createAttributeContinuous("invalid_key", 100.1, null)); Assert.assertEquals(-1, result); }
@Test public void testRegisterValidXAttribute() { ContinuousAttribute att = new ContinuousAttribute("concept:name", AttributeLevel.EVENT); XAttributeContinuous xatt = xAttFactory.createAttributeContinuous("concept:name", 100.1, null); int result = att.registerXAttribute(xatt); Assert.assertEquals(0, result); }