ValueMarshallerImpl implements ValueMarshaller { @Override public Object getJavaObject(OrcStruct struct) throws UnexpectedTypeException { Object writable = inspector.getStructFieldData(struct, structField); try { return converter.toJavaObject(writable); } catch (UnexpectedTypeException e) { throw new UnexpectedTypeException(writable, structField.getFieldName(), e); } } ValueMarshallerImpl(SettableStructObjectInspector inspector, StructField structField, Converter converter); @Override Object getJavaObject(OrcStruct struct); @Override Object getWritableObject(OrcStruct struct); @Override void setWritableObject(OrcStruct struct, Object javaObject);  }
@Test public void getJava() throws UnexpectedTypeException { when(inspector.getStructFieldData(null, structField)).thenReturn(text); when(converter.toJavaObject(text)).thenReturn(string); Object javaObject = marshaller.getJavaObject(null); assertThat(javaObject, is((Object) string)); verify(inspector).getStructFieldData(null, structField); verify(converter).toJavaObject(text); }
@Test(expected = UnexpectedTypeException.class) public void getJavaException() throws UnexpectedTypeException { when(inspector.getStructFieldData(null, structField)).thenReturn(text); doThrow(new UnexpectedTypeException()).when(converter).toJavaObject(text); marshaller.getJavaObject(null); }