BooleanAttribute extends AbstractIndexableAttribute { @Override public int registerXAttribute(XAttribute att) { if (att instanceof XAttributeBoolean && this.getKey().equals(att.getKey())) { boolean value = ((XAttributeBoolean)att).getValue(); if (!values.contains(value)) { values.add(value); return (values.size()-1); } else { return -1; } } else { return -1; } } BooleanAttribute(String key, AttributeLevel level); @Override int registerXAttribute(XAttribute att); @Override ImmutableList<Object> getValues(); @Override int getValueIndex(Object value); @Override Object getValue(int index); @Override int getValueSize();  }
@Test public void testRegisterXAttributeWithInvalidType() { BooleanAttribute att = new BooleanAttribute("concept:name", AttributeLevel.EVENT); int result = att.registerXAttribute(xAttFactory.createAttributeContinuous("concept:name", 100, null)); Assert.assertEquals(-1, result); }
@Test public void testRegisterXAttributeWithInvalidKey() { BooleanAttribute att = new BooleanAttribute("concept:name", AttributeLevel.EVENT); int result = att.registerXAttribute(xAttFactory.createAttributeBoolean("invalid_key", true, null)); Assert.assertEquals(-1, result); }
@Test public void testRegisterValidXAttribute() { BooleanAttribute att = new BooleanAttribute("concept:name", AttributeLevel.EVENT); XAttributeBoolean xatt = xAttFactory.createAttributeBoolean("concept:name", true, null); int result = att.registerXAttribute(xatt); Assert.assertEquals(0, result); }