OrmFactoryRegistryImpl implements OrmFactoryRegistry { @Override public <T extends Thing> List<OrmFactory<? extends T>> getSortedFactoriesOfType(Class<T> type) { return getFactoryStreamOfType(type) .sorted((factory1, factory2) -> factory2.getParentTypeIRIs().size() - factory1.getParentTypeIRIs().size()) .collect(Collectors.toList()); }  @Override @SuppressWarnings("unchecked") Optional<OrmFactory<T>> getFactoryOfType(Class<T> type); @Override Optional<OrmFactory<? extends Thing>> getFactoryOfType(String typeIRI); @Override Optional<OrmFactory<? extends Thing>> getFactoryOfType(IRI typeIRI); @Override List<OrmFactory<? extends T>> getFactoriesOfType(Class<T> type); @Override List<OrmFactory<? extends T>> getSortedFactoriesOfType(Class<T> type); @Override List<OrmFactory<? extends Thing>> getFactoriesOfType(String typeIRI); @Override List<OrmFactory<? extends Thing>> getSortedFactoriesOfType(String typeIRI); @Override List<OrmFactory<? extends Thing>> getFactoriesOfType(IRI typeIRI); @Override List<OrmFactory<? extends Thing>> getSortedFactoriesOfType(IRI typeIRI); @Override T createNew(Resource resource, Model model, Class<T> type); @Override Optional<T> getExisting(Resource resource, Model model, Class<T> type); @Override Collection<T> getAllExisting(Model model, Class<T> type); @Override void processAllExisting(Model model, Consumer<T> consumer, Class<T> type);  }
@Test public void getSortedFactoriesByTypeClassTest() throws Exception { List<OrmFactory<? extends A>> result = registry.getSortedFactoriesOfType(A.class); assertEquals(cFactory, result.get(0)); assertEquals(aFactory, result.get(result.size() - 1)); }
@Test public void getSortedFactoriesByTypeStringTest() throws Exception { List<OrmFactory<? extends Thing>> result = registry.getSortedFactoriesOfType(A.TYPE); assertEquals(cFactory, result.get(0)); assertEquals(aFactory, result.get(result.size() - 1)); }
@Test public void getSortedFactoriesByTypeIRITest() throws Exception { List<OrmFactory<? extends Thing>> result = registry.getSortedFactoriesOfType(aIRI); assertEquals(cFactory, result.get(0)); assertEquals(aFactory, result.get(result.size() - 1)); }