BytesWritableConverter implements Serializable { public DocumentWrapper convertToDocumentWrapper(BytesWritable bytesWritable) { Preconditions.checkNotNull(bytesWritable); DocumentWrapper docWrapper = null; try { docWrapper = DocumentWrapper.parseFrom(bytesWritable.copyBytes()); } catch (Exception e) { throw new IllegalArgumentException(e); } return docWrapper; }  DocumentWrapper convertToDocumentWrapper(BytesWritable bytesWritable); Tuple2<String, DocumentWrapper> convertToDocumentWrapperTuple2(BytesWritable bytesWritable);  }
@Test(expectedExceptions=NullPointerException.class) public void convertToDocumentWrapper_NULL() { bytesWritableConverter.convertToDocumentWrapper(null); }
@Test public void convertToDocumentWrapper() { BytesWritable bytesWritable = new BytesWritable(docWrapper.toByteArray()); DocumentWrapper retDocWrapper = bytesWritableConverter.convertToDocumentWrapper(bytesWritable); assertFalse(docWrapper == retDocWrapper); assertEquals(docWrapper.getDocumentMetadata().getKey(), retDocWrapper.getDocumentMetadata().getKey()); }
@Test(expectedExceptions=IllegalArgumentException.class) public void convertToDocumentWrapper_Wrong_Arg() { BytesWritable bytesWritable = new BytesWritable(new byte[] {9, 126, 12}); bytesWritableConverter.convertToDocumentWrapper(bytesWritable); }