### Question:
DataModelUtil { @SuppressWarnings("unchecked") public static <E> Class<E> resolveType(Class<E> type, Schema schema) { if (type == Object.class) { type = ReflectData.get().getClass(schema); } if (type == null) { type = (Class<E>) GenericData.Record.class; } return type; }  static GenericData getDataModelForType(Class<E> type); static boolean isGeneric(Class<?> type); @SuppressWarnings("unchecked") static DatumReader<E> getDatumReaderForType(Class<E> type, Schema writerSchema); @SuppressWarnings("unchecked") static Class<E> resolveType(Class<E> type, Schema schema); static Schema getReaderSchema(Class<E> type, Schema schema); static Schema getWriterSchema(Class<E> type, Schema schema); @SuppressWarnings("unchecked") static E createRecord(Class<E> type, Schema schema); static EntityAccessor<E> accessor(Class<E> type, Schema schema);  }### Answer:
@Test public void testResolveTypeGenericToGeneric() { Class<GenericData.Record> type = GenericData.Record.class; Schema schema = StandardEvent.getClassSchema(); Class expResult = type; Class result = DataModelUtil.resolveType(type, schema); assertEquals(expResult, result); }
@Test public void testResolveTypeSpecifcToSpecifc() { Class<StandardEvent> type = StandardEvent.class; Schema schema = StandardEvent.getClassSchema(); Class expResult = type; Class result = DataModelUtil.resolveType(type, schema); assertEquals(expResult, result); }
@Test public void testResolveTypeReflectToReflect() { Class<String> type = String.class; Schema schema = Schema.create(Schema.Type.STRING); Class expResult = type; Class result = DataModelUtil.resolveType(type, schema); assertEquals(expResult, result); }
@Test public void testResolveTypeObjectToSpecifc() { Class<Object> type = Object.class; Schema schema = StandardEvent.getClassSchema(); Class expResult = StandardEvent.class; Class result = DataModelUtil.resolveType(type, schema); assertEquals(expResult, result); }
@Test public void testResolveTypeObjectToGeneric() { Class<Object> type = Object.class; Schema schema = SchemaBuilder.record("User").fields() .requiredString("name") .requiredString("color") .endRecord(); Class expResult = GenericData.Record.class; Class result = DataModelUtil.resolveType(type, schema); assertEquals(expResult, result); }
@Test public void testResolveTypeObjectToReflect() { Class<Object> type = Object.class; Schema schema = ReflectData.get().getSchema(String.class); Class expResult = String.class; Class result = DataModelUtil.resolveType(type, schema); assertEquals(expResult, result); }