BlobToByteArrayMapper implements TypeMapper<Blob, byte[]> { @Override public byte[] toJavaType(Column column, Class<?> entityType, Blob value) { if (value == null) { return null; } else try { if (value.length() < Integer.MAX_VALUE) { return value.getBytes(1, (int) value.length()); } else { throw new SpeedmentTypeMapperException( "The provided Blob contains too many characters >" + Integer.MAX_VALUE ); } } catch (final SQLException sqle) { throw new SpeedmentTypeMapperException("Unable to convert Blob to byte[].", sqle); } }  @Override String getLabel(); @Override Type getJavaType(Column column); @Override byte[] toJavaType(Column column, Class<?> entityType, Blob value); @Override Blob toDatabaseType(byte[] value);  }
@Test void toJavaType() { assertEquals(byte[].class,mapper.getJavaType(null)); }
@Test void javaTypeToDbType() { byte[] array= new byte[10]; Blob blob = new StandardBlob(array); byte[] actual = mapper.toJavaType(null,null,blob); assertArrayEquals(array,actual); }