OrmFactoryRegistryImpl implements OrmFactoryRegistry { @Override public <T extends Thing> List<OrmFactory<? extends T>> getFactoriesOfType(Class<T> type) { return getFactoryStreamOfType(type).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 getFactoriesByTypeClassTest() { List<OrmFactory<? extends Thing>> result = registry.getFactoriesOfType(Thing.class); assertEquals(1, result.size()); List<OrmFactory<? extends A>> result2 = registry.getFactoriesOfType(A.class); assertEquals(4, result2.size()); List<OrmFactory<? extends B>> result3 = registry.getFactoriesOfType(B.class); assertEquals(2, result3.size()); List<OrmFactory<? extends C>> result4 = registry.getFactoriesOfType(C.class); assertEquals(1, result4.size()); }
@Test public void getFactoriesByTypeClassThatDoesNotExistTest() throws Exception { List<OrmFactory<? extends Error>> result = registry.getFactoriesOfType(Error.class); assertEquals(0, result.size()); }
@Test public void getFactoriesByTypeStringTest() throws Exception { List<OrmFactory<? extends Thing>> result = registry.getFactoriesOfType(Thing.TYPE); assertEquals(1, result.size()); result = registry.getFactoriesOfType(A.TYPE); assertEquals(4, result.size()); result = registry.getFactoriesOfType(B.TYPE); assertEquals(2, result.size()); result = registry.getFactoriesOfType(C.TYPE); assertEquals(1, result.size()); }
@Test public void getFactoriesByTypeStringThatDoesNotExistTest() throws Exception { List<OrmFactory<? extends Thing>> result = registry.getFactoriesOfType(Error.TYPE); assertEquals(0, result.size()); }
@Test public void getFactoriesByTypeIriTest() throws Exception { List<OrmFactory<? extends Thing>> result = registry.getFactoriesOfType(thingIRI); assertEquals(1, result.size()); result = registry.getFactoriesOfType(aIRI); assertEquals(4, result.size()); result = registry.getFactoriesOfType(bIRI); assertEquals(2, result.size()); result = registry.getFactoriesOfType(cIRI); assertEquals(1, result.size()); }
@Test public void getFactoriesByTypeIriThatDoesNotExistTest() throws Exception { List<OrmFactory<? extends Thing>> result = registry.getFactoriesOfType(errorIRI); assertEquals(0, result.size()); }