ConfigCoreContext extends ConfigContext { @Override public <T> List<T> list(Class<T> configurable) { doLookup(); Schema s = schemaManager.getSchema(configurable); initFile(configurable); Map<BeanId, Bean> beans = new HashMap<>(); Map<BeanId, Bean> found = beanManager.list(s.getName()); if (found.isEmpty()) { for (Bean bean : FILE_CONFIG.values()) { if (bean.getId().getSchemaName().equals(s.getName())) { beans.put(bean.getId(), bean); } } } for (Bean foundBean : found.values()) { beans.put(foundBean.getId(), foundBean); } schemaManager.setSchema(beans.values()); for (Bean bean : beans.values()) { setSingletonReferences(bean); if (cacheManager.isPresent()) { cacheManager.get().put(bean); } } ArrayList<T> objects = new ArrayList<>(); for(Object object : schemaManager.convertBeans(beans.values())) { objects.add((T) object); } return objects; }  @Override void register(Class<?>... configurable); @Override void unregister(Class<?>... configurable); @Override T get(Class<T> configurable); @Override List<T> list(Class<T> configurable); @Override Optional<T> get(String id, Class<T> configurable); @Override ConfigQuery<T> newQuery(Class<T> configurable); @Override void registerObserver(ConfigObserver observer); void doLookup();  }
@Test public void test_list_file_fallback() throws Exception { List<Grandfather> grandfathers = config.list(Grandfather.class); assertThat(grandfathers.size(), is(3)); for (Grandfather g : grandfathers) { if (g.getBeanId().equals("g10")) { assertGrandfather10(g); } } }
@Test public void test_admin_override_list_file_fallback() { Grandfather g10 = new Grandfather("g10"); g10.setProp1("g10"); Grandfather g11 = new Grandfather("g11"); g10.setProp1("g11"); admin.createObjects(Arrays.asList(getGrandfather("g10"), getGrandfather("g11"))); List<Grandfather> result = config.list(Grandfather.class); assertThat(result.size(), is(2)); for (Grandfather g : result) { if (g.getBeanId().equals("g10")) { assertEquals(g.getProp1(), "g10"); } if (g.getBeanId().equals("g11")) { assertEquals(g.getProp1(), "g11"); } } }