complexValueType.get("map-int-value", DESCRIPTION).set("An int map value");
complexValueType.get("map-int-value", TYPE).set(ModelType.OBJECT);
complexValueType.get("map-int-value", VALUE_TYPE).set(ModelType.INT);
description.get(VALUE_TYPE).set(complexValueType);
TypeConverter converter = getConverter(description);
CompositeType type = assertCast(CompositeType.class, converter.getOpenType());
Set<String> keys = type.keySet();
Assert.assertEquals(10, keys.size());
assertCompositeType(type, "int-value", Integer.class.getName(), "An int value");
//TODO big integer not working properly in current version of dmr
//assertCompositeType(composite, "bigint-value", BigInteger.class.getName(), "A biginteger value");
assertCompositeType(type, "bigdecimal-value", BigDecimal.class.getName(), "A bigdecimal value");
assertCompositeType(type, "boolean-value", Boolean.class.getName(), "A boolean value");
assertCompositeType(type, "bytes-value", byte[].class.getName(), "A bytes value");
assertCompositeType(type, "double-value", Double.class.getName(), "A double value");
assertCompositeType(type, "string-value", String.class.getName(), "A string value");
assertCompositeType(type, "long-value", Long.class.getName(), "A long value");
assertCompositeType(type, "type-value", String.class.getName(), "A type value");
assertCompositeType(type, "list-int-value", Integer[].class.getName(), "An int list value");
assertMapType(assertCast(TabularType.class, assertCompositeType(type, "map-int-value", TabularType.class.getName(), "An int map value", false)), SimpleType.STRING, SimpleType.INTEGER);
ModelNode node = new ModelNode();
node.get("int-value").set(1);
//node.get("bigint-value").set(BigInteger.valueOf(2));
node.get("bigdecimal-value").set(BigDecimal.valueOf(3));
node.get("boolean-value").set(Boolean.TRUE);
node.get("bytes-value").set(new byte[] {4,5});
node.get("double-value").set(Double.valueOf(6));
node.get("string-value").set("Seven");
node.get("long-value").set(Long.valueOf(8));
node.get("type-value").set(ModelType.INT);
node.get("list-int-value").add(9);
node.get("list-int-value").add(10);
node.get("map-int-value", "one").set(11);
node.get("map-int-value", "two").set(12);
CompositeData data = assertCast(CompositeData.class, converter.fromModelNode(node));
Assert.assertEquals(type, data.getCompositeType());
Assert.assertEquals(node, converter.toModelNode(data));
//Another test testing missing data in fromModelNode();
node = new ModelNode();
node.get("int-value").set(1);
data = assertCast(CompositeData.class, converter.fromModelNode(node));
Assert.assertEquals(node, converter.toModelNode(data));
//And another test testing missing data in fromModelNode();
node = new ModelNode();
node.get("boolean-value").set(true);
data = assertCast(CompositeData.class, converter.fromModelNode(node));
Assert.assertEquals(node, converter.toModelNode(data));
}