MultiIndexDao implements IndexDao { @Override public Map<String, FieldType> getColumnMetadata(List<String> in) throws IOException { for(IndexDao dao : indices) { Map<String, FieldType> r = dao.getColumnMetadata(in); if(r != null) { return r; } } return null; } MultiIndexDao(IndexDao... composedDao);  MultiIndexDao(Iterable<IndexDao> composedDao);  MultiIndexDao(Iterable<IndexDao> composedDao, Function<IndexDao, IndexDao> decoratorTransformation); @Override Document update(final Document update, Optional<String> index); @Override Map<Document, Optional<String>> batchUpdate(Map<Document, Optional<String>> updates); @Override Map<String, FieldType> getColumnMetadata(List<String> in); @Override Document addCommentToAlert(CommentAddRemoveRequest request); @Override Document addCommentToAlert(CommentAddRemoveRequest request, Document latest); @Override Document removeCommentFromAlert(CommentAddRemoveRequest request); @Override Document removeCommentFromAlert(CommentAddRemoveRequest request, Document latest); @Override SearchResponse search(SearchRequest searchRequest); @Override GroupResponse group(GroupRequest groupRequest); @Override void init(AccessConfig config); @Override Document getLatest(final String guid, String sensorType); @Override Iterable<Document> getAllLatest(List<GetRequest> getRequests); List<IndexDao> getIndices();  }
@Test public void shouldGetColumnMetadata() throws Exception { List<String> indices = Collections.singletonList("bro"); Map<String, FieldType> expected = new HashMap<String, FieldType>() {{ put("bro", FieldType.TEXT); }}; when(dao1.getColumnMetadata(eq(indices))).thenReturn(null); when(dao2.getColumnMetadata(eq(indices))).thenReturn(expected); Map<String, FieldType> actual = multiIndexDao.getColumnMetadata(indices); assertEquals(expected, actual); }
@Test public void shouldGetColumnMetadataWithNulls() throws Exception { List<String> indices = Collections.singletonList("bro"); when(dao1.getColumnMetadata(eq(indices))).thenReturn(null); when(dao2.getColumnMetadata(eq(indices))).thenReturn(null); Map<String, FieldType> actual = multiIndexDao.getColumnMetadata(indices); assertNull(actual); }