SingletonObjectFactory implements ObjectFactory<T> { @Override public Object getInstance(ApplicationContext context) { return getInstance(); } SingletonObjectFactory(T model, Object object); @Override Object getInstance(ApplicationContext context); Object getInstance(); @Override T getObjectModel();  }
@Test public void returnsInstanceGivenInCreationOfObjectFactory() { Object instance = new Object(); ObjectModel objectModel = mock(ObjectModel.class); SingletonObjectFactory singletonObjectFactory = new SingletonObjectFactory<>(objectModel, instance); Object result = singletonObjectFactory.getInstance(null); assertSame(instance, result); }