HBaseDataStore implements DataStore { @Override @Timed public Document get(final Table table, String id) { try (org.apache.hadoop.hbase.client.Table hTable = tableWrapper.getTable(table)) { Get get = new Get(Bytes.toBytes(translator.rawStorageIdFromDocumentId(table, id))).addColumn(COLUMN_FAMILY, DOCUMENT_FIELD_NAME) .addColumn(COLUMN_FAMILY, DOCUMENT_META_FIELD_NAME) .addColumn(COLUMN_FAMILY, TIMESTAMP_FIELD_NAME) .setMaxVersions(1); Result getResult = hTable.get(get); if(!getResult.isEmpty()) { byte[] data = getResult.getValue(COLUMN_FAMILY, DOCUMENT_FIELD_NAME); byte[] metadata = getResult.getValue(COLUMN_FAMILY, DOCUMENT_META_FIELD_NAME); byte[] timestamp = getResult.getValue(COLUMN_FAMILY, TIMESTAMP_FIELD_NAME); long time = Bytes.toLong(timestamp); DocumentMetadata documentMetadata = (null != metadata) ? mapper.readValue(metadata, DocumentMetadata.class) : null; return translator.translateBack(new Document(id, time, documentMetadata, mapper.readTree(data))); } else { logger.error("ID missing in HBase - {}", id); throw FoxtrotExceptions.createMissingDocumentException(table, id); } } catch (IOException e) { throw FoxtrotExceptions.createConnectionException(table, e); } } @Inject  HBaseDataStore(HbaseTableConnection tableWrapper, ObjectMapper mapper, DocumentTranslator translator); @Override @Timed void initializeTable(Table table, boolean forceTableCreate); @Override @Timed Document save(final Table table, Document document); @Override @Timed List<Document> saveAll(final Table table, List<Document> documents); @Override @Timed Document get(final Table table, String id); @Override @Timed List<Document> getAll(final Table table, List<String> ids); @VisibleForTesting Put getPutForDocument(Document document); @Override @Timed void updateTable(final Table table);  }
@Test public void testGetSingleMissingDocument() { try { hbaseDataStore.get(TEST_APP, UUID.randomUUID() .toString()); fail(); } catch (FoxtrotException ex) { assertEquals(ErrorCode.DOCUMENT_NOT_FOUND, ex.getCode()); } }