OracleTimestampNormaliser implements TypeTransformer { @Override public Object transform(Object o) throws SQLException { if (o == null) return null; if (!(o instanceof oracle.sql.TIMESTAMP)) { throw new UnsupportedOperationException( "OracleTimestampNormaliser cannot work with " + o.getClass()); } oracle.sql.TIMESTAMP ts = (oracle.sql.TIMESTAMP) o; return ts.timestampValue(); }  @Override Object transform(Object o);  }
@Test public void shouldReturnNullIfGivenNull() throws SQLException { assertNull(new OracleTimestampNormaliser().transform(null)); }
@Test public void shouldThrowCorrectExceptionIfNotGivenAnOracleTIMESTAMP() throws SQLException { expectedEx.expect(UnsupportedOperationException.class); expectedEx.expectMessage("OracleTimestampNormaliser cannot work with class java.lang.String"); new OracleTimestampNormaliser().transform("Any Old Object"); }
@Test public void shouldReturnContentsOfClobIFAllOkay() throws SQLException { TIMESTAMP ts = mock(TIMESTAMP.class); when(ts.timestampValue()).thenReturn(new Timestamp(0l)); assertEquals(new Timestamp(0l), new OracleTimestampNormaliser().transform(ts)); }