TypeRegistry builder = new TypeRegistry().add(A.class).add(A.class);
assertEquals(1, builder.typeFields.size());
}
@Test public void registerHierarchy() {
TypeRegistry reg = new TypeRegistry().add(A.class).add(B.class);
assertEquals(2, reg.typeFields.size());
assertEquals(2, reg.typeDiscriminators.size());
assertEquals(Abstract.class, reg.getTypeHoldingTypeField(A.class));
assertEquals(Abstract.class, reg.getTypeHoldingTypeField(B.class));
assertEquals(Abstract.class, reg.getTypeHoldingTypeField(Abstract.class));
assertNull(reg.getTypeHoldingTypeField(C.class));
reg.add(C.class);
assertEquals(3, reg.typeFields.size());
assertEquals(3, reg.typeDiscriminators.size());
assertEquals(Abstract.class, reg.getTypeHoldingTypeField(C.class));
assertEquals(A.class, reg.getType(Abstract.class, "A"));
assertEquals(B.class, reg.getType(Abstract.class, "B"));
assertEquals(C.class, reg.getType(Abstract.class, "C"));
}