DataFetcherImpl implements DataFetcher { @Override public Map<String, List<Object>> fetch(String tableName, Collection<Column> columns, Set<String> ids) { return fetchData(tableName, columns, ids); } @Autowired  DataFetcherImpl(ApplicationContext applicationContext); @PostConstruct void init(); @Override Map<String, List<Object>> fetch(String tableName, Collection<Column> columns, Set<String> ids); @Override DataContainer fetch(String tableName, String tableAlias, Collection<Column> columns);  }
@Test public void testFetchExistingTable() { final String TABLE_ALIAS = "alias"; final String COLUMN_NAME = "column"; DataContainer data = dataFetcher.fetch( "existing", TABLE_ALIAS, Collections.singletonList(new Column(COLUMN_NAME, String.class, null, new MockTable())) ); Map<String, List<String>> columnsMap = data.getColumnsMap(); assertThat(columnsMap.keySet(), hasSize(1)); assertThat(columnsMap.keySet(), contains(TABLE_ALIAS)); assertThat(columnsMap.get(TABLE_ALIAS), hasSize(1)); assertThat(columnsMap.get(TABLE_ALIAS), contains(COLUMN_NAME)); }
@Test(expected = IllegalArgumentException.class) public void testFetchMissingTable() { dataFetcher.fetch( "missing", "anything", Collections.emptyList() ); }