ElasticsearchQueryStore implements QueryStore { @Override public TableFieldMapping getFieldMappings(String table) { return tableMetadataManager.getFieldMappings(table, false, false); } @Inject  ElasticsearchQueryStore(TableMetadataManager tableMetadataManager,
                                   ElasticsearchConnection connection,
                                   DataStore dataStore,
                                   List<IndexerEventMutator> mutators,
                                   ObjectMapper mapper,
                                   CardinalityConfig cardinalityConfig); @Override @Timed void initializeTable(String table); @Override @Timed void save(String table, Document document); @Override @Timed void save(String table, List<Document> documents); @Override @Timed Document get(String table, String id); @Override List<Document> getAll(String table, List<String> ids); @Override @Timed List<Document> getAll(String table, List<String> ids, boolean bypassMetalookup); @Override void cleanupAll(); @Override @Timed void cleanup(final String table); @Override @Timed void cleanup(Set<String> tables); @Override ClusterHealthResponse getClusterHealth(); @Override NodesStatsResponse getNodeStats(); @Override IndicesStatsResponse getIndicesStats(); @Override TableFieldMapping getFieldMappings(String table);  }
@Test @Ignore public void testGetFieldMappings() throws FoxtrotException, InterruptedException { doReturn(TestUtils.getMappingDocuments(mapper)).when(dataStore) .saveAll(any(Table.class), anyListOf(Document.class)); queryStore.save(TestUtils.TEST_TABLE_NAME, TestUtils.getMappingDocuments(mapper)); await().pollDelay(500, TimeUnit.MILLISECONDS).until(() -> true); Set<FieldMetadata> mappings = new HashSet<FieldMetadata>(); mappings.add(FieldMetadata.builder() .field("time") .type(FieldType.LONG) .build()); mappings.add(FieldMetadata.builder() .field("word") .type(FieldType.STRING) .build()); mappings.add(FieldMetadata.builder() .field("data.data") .type(FieldType.STRING) .build()); mappings.add(FieldMetadata.builder() .field("header.hello") .type(FieldType.STRING) .build()); mappings.add(FieldMetadata.builder() .field("head.hello") .type(FieldType.LONG) .build()); TableFieldMapping tableFieldMapping = new TableFieldMapping(TestUtils.TEST_TABLE_NAME, mappings); TableFieldMapping responseMapping = queryStore.getFieldMappings(TestUtils.TEST_TABLE_NAME); assertEquals(tableFieldMapping.getTable(), responseMapping.getTable()); assertEquals(tableFieldMapping.getMappings(), responseMapping.getMappings()); }
@Test public void testGetFieldMappingsNonExistingTable() throws FoxtrotException { try { queryStore.getFieldMappings(TestUtils.TEST_TABLE + "-test"); fail(); } catch (FoxtrotException qse) { assertEquals(ErrorCode.INVALID_REQUEST, qse.getCode()); } }
@Test public void testGetFieldMappingsNoDocumentsInTable() throws FoxtrotException { TableFieldMapping request = new TableFieldMapping(TestUtils.TEST_TABLE_NAME, new HashSet<>()); TableFieldMapping response = queryStore.getFieldMappings(TestUtils.TEST_TABLE_NAME); assertEquals(request.getTable(), response.getTable()); assertEquals(request.getMappings(), response.getMappings()); }