ElasticsearchQueryStore implements QueryStore { @Override public Document get(String table, String id) throws QueryStoreException { table = ElasticsearchUtils.getValidTableName(table); Table fxTable = null; try { if (!tableMetadataManager.exists(table)) { throw new QueryStoreException(QueryStoreException.ErrorCode.NO_SUCH_TABLE, "No table exists with the name: " + table); } fxTable = tableMetadataManager.get(table); } catch (Exception ex) { throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_GET_ERROR, ex.getMessage(), ex); } try { return dataStore.get(fxTable, id); } catch (DataStoreException ex) { if (ex.getErrorCode().equals(DataStoreException.ErrorCode.STORE_NO_DATA_FOUND_FOR_ID)) { throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_NOT_FOUND, ex.getMessage(), ex); } throw new QueryStoreException(QueryStoreException.ErrorCode.DOCUMENT_GET_ERROR, ex.getMessage(), ex); } } ElasticsearchQueryStore(TableMetadataManager tableMetadataManager,
                                   ElasticsearchConnection connection,
                                   DataStore dataStore); @Override void save(String table, Document document); @Override void save(String table, List<Document> documents); @Override Document get(String table, String id); @Override List<Document> get(String table, List<String> ids); @Override TableFieldMapping getFieldMappings(String table); @Override void cleanupAll(); @Override void cleanup(final String table); @Override void cleanup(Set<String> tables);  }
@Test public void testGetSingleInvalidId() throws Exception { try { queryStore.get(TestUtils.TEST_TABLE_NAME, UUID.randomUUID().toString()); } catch (QueryStoreException qse) { assertEquals(QueryStoreException.ErrorCode.DOCUMENT_NOT_FOUND, qse.getErrorCode()); } }
@Test public void testGetBulkInvalidIds() throws Exception { try { queryStore.get(TestUtils.TEST_TABLE_NAME, Arrays.asList(UUID.randomUUID().toString(), UUID.randomUUID().toString())); fail(); } catch (QueryStoreException qse) { assertEquals(QueryStoreException.ErrorCode.DOCUMENT_NOT_FOUND, qse.getErrorCode()); } }