TypeLoaderUsingMetadata implements TypeLoader, InitializingBean { public Type getType(String id) { return getType(id, null); } TypeLoaderUsingMetadata();  TypeLoaderUsingMetadata(
			final RecordTypeDefinitionDao recordTypeDefinitionDao); void setRecordTypeDefinitionDao(
			RecordTypeDefinitionDao recordTypeDefinitionDao); void afterPropertiesSet(); Type getType(String id);  }
@Test public void testPrimitiveType() { Assert.assertEquals(PrimitiveType.BOOLEAN, typeLoader.getType("boolean")); Assert.assertEquals(PrimitiveType.STRING, typeLoader.getType("string")); Assert.assertEquals(PrimitiveType.BYTE, typeLoader.getType("byte")); Assert.assertEquals(PrimitiveType.SHORT, typeLoader.getType("short")); Assert.assertEquals(PrimitiveType.INTEGER, typeLoader.getType("integer")); Assert.assertEquals(PrimitiveType.LONG, typeLoader.getType("long")); Assert.assertEquals(PrimitiveType.BIGINTEGER, typeLoader.getType("biginteger")); Assert.assertEquals(PrimitiveType.FLOAT, typeLoader.getType("float")); Assert.assertEquals(PrimitiveType.DOUBLE, typeLoader.getType("double")); Assert.assertEquals(PrimitiveType.BIGDECIMAL, typeLoader.getType("bigdecimal")); Assert.assertEquals(PrimitiveType.CALENDAR, typeLoader.getType("calendar")); }
@Test public void testSimpleRecord() { String id = "header"; Type type = typeLoader.getType(id); Assert.assertEquals(id, type.getId()); Assert.assertEquals(RecordType.class, type.getClass()); Assert.assertEquals(PrimitiveType.STRING, ((RecordType) type).getFieldType("serviceId")); }
@Test public void testComplexRecord() { String id = "messageJuminCheck"; Type type = typeLoader.getType(id); Assert.assertEquals(id, type.getId()); Assert.assertEquals(RecordType.class, type.getClass()); RecordType recordType = (RecordType) type; Assert.assertEquals(PrimitiveType.STRING, recordType.getFieldType("serviceId")); Assert.assertEquals(typeLoader.getType("recordJuminCheck"), recordType.getFieldType("body")); }
@Test public void testInheritance() { String id = "messageJuminCheckList"; Type type = typeLoader.getType(id); Assert.assertEquals(id, type.getId()); Assert.assertEquals(RecordType.class, type.getClass()); RecordType recordType = (RecordType) type; Assert.assertEquals(PrimitiveType.INTEGER, recordType.getFieldType("serviceId")); }
@Test public void testCircularReference() { String id = "messageJuminCheckList"; Type type = typeLoader.getType(id); Assert.assertEquals(id, type.getId()); Assert.assertEquals(RecordType.class, type.getClass()); RecordType recordType = (RecordType) type; Type bodyFieldType = recordType.getFieldType("body"); Assert.assertEquals(RecordType.class, bodyFieldType.getClass()); RecordType bodyRecordType = (RecordType) bodyFieldType; Type listFieldType = bodyRecordType.getFieldType("list"); Assert.assertEquals(ListType.class, listFieldType.getClass()); Assert.assertEquals(typeLoader.getType("recordJuminCheck"), ((ListType) listFieldType).getElementType()); Type elementType = ((ListType) listFieldType).getElementType(); Assert.assertEquals(RecordType.class, elementType.getClass()); RecordType elementRecordType = (RecordType) elementType; Assert.assertEquals(bodyFieldType, elementRecordType.getFieldType("children")); }
@Test public void testNoSuchTypeException() { try { typeLoader.getType("noMessage"); Assert.fail(); } catch (NoSuchTypeException e) { } catch (Exception e) { Assert.fail(); } }
@Test public void testCircularInheritanceException() { try { typeLoader.getType("messageCircularA"); Assert.fail(); } catch (CircularInheritanceException e) { } catch (Exception e) { Assert.fail(); } }