FactoryManager { List<FactoryBase<?,R>> getRemovedFactories(Collection<FactoryBase<?,R>> previousFactories, Set<FactoryBase<?,R>> newFactories){ final ArrayList<FactoryBase<?,R>> result = new ArrayList<>(previousFactories); result.removeAll(newFactories); return result; } FactoryManager(FactoryExceptionHandler<L,R> factoryExceptionHandler); FactoryUpdateLog<R> update(R commonVersion , R newVersion, Function<String,Boolean> permissionChecker); MergeDiffInfo<R> simulateUpdate(R commonVersion , R newVersion,  Function<String, Boolean> permissionChecker); R getCurrentFactory(); L start(RootFactoryWrapper<R> newFactory); void stop(); void resetAfterCrash(); boolean isStarted();  }
@Test public void test_getRemoved_factories() { FactoryManager<ExampleLiveObjectA, ExampleFactoryA> factoryManager = new FactoryManager<ExampleLiveObjectA, ExampleFactoryA>(new RethrowingFactoryExceptionHandler<>()); ArrayList<FactoryBase<?, ExampleFactoryA>> previousFactories = new ArrayList<>(); HashSet<FactoryBase<?, ExampleFactoryA>> newFactories = new HashSet<>(); ExampleFactoryB both = new ExampleFactoryB(); previousFactories.add(both); newFactories.add(both); ExampleFactoryB removed = new ExampleFactoryB(); previousFactories.add(removed); List<FactoryBase<?, ExampleFactoryA>> removedFactories = factoryManager.getRemovedFactories(previousFactories, newFactories); Assertions.assertEquals(1,removedFactories.size()); Assertions.assertEquals(removed,removedFactories.get(0)); }
@Test public void test_getRemoved_factories_no_removed() { FactoryManager<ExampleLiveObjectA, ExampleFactoryA> factoryManager = new FactoryManager<ExampleLiveObjectA, ExampleFactoryA>(new RethrowingFactoryExceptionHandler<>()); ArrayList<FactoryBase<?, ExampleFactoryA>> previousFactories = new ArrayList<>(); HashSet<FactoryBase<?, ExampleFactoryA>> newFactories = new HashSet<>(); ExampleFactoryB both = new ExampleFactoryB(); previousFactories.add(both); newFactories.add(both); List<FactoryBase<?, ExampleFactoryA>> removedFactories = factoryManager.getRemovedFactories(previousFactories, newFactories); Assertions.assertEquals(0,removedFactories.size()); }