@SuppressWarnings("unchecked") @Test public void get_from_unconfigured_aso() { ApplicationStatePersistenceStrategy strategy = mockApplicationStatePersistenceStrategy(); ApplicationStatePersistenceStrategySource source = mockApplicationStatePersistenceStrategySource(); Class asoClass = ReadOnlyBean.class; final Holder holder = new Holder(); ObjectLocator locator = mockObjectLocator(); train_get(source, ApplicationStateManagerImpl.DEFAULT_STRATEGY, strategy); IAnswer answer = new IAnswer() { public Object answer() throws Throwable { ApplicationStateCreator creator = (ApplicationStateCreator) EasyMock .getCurrentArguments()[1]; Object aso = creator.create(); holder.put(aso); return aso; } }; expect(strategy.get(eq(asoClass), isA(ApplicationStateCreator.class))).andAnswer(answer); expect(locator.autobuild(EasyMock.isA(String.class), EasyMock.eq(asoClass))).andReturn( new ReadOnlyBean()); replay(); Map<Class, ApplicationStateContribution> configuration = Collections.emptyMap(); ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source, locator); Object actual = manager.get(asoClass); assertSame(actual, holder.get()); verify(); }
public <T> T get(Class<T> ssoClass) { return getAdapter(ssoClass).getOrCreate(); }
ApplicationStateManagerImpl implements ApplicationStateManager { public <T> T get(Class<T> ssoClass) { return getAdapter(ssoClass).getOrCreate(); } }
ApplicationStateManagerImpl implements ApplicationStateManager { public <T> T get(Class<T> ssoClass) { return getAdapter(ssoClass).getOrCreate(); } @SuppressWarnings("unchecked")  ApplicationStateManagerImpl(Map<Class, ApplicationStateContribution> configuration,
            ApplicationStatePersistenceStrategySource source, ObjectLocator locator); }
ApplicationStateManagerImpl implements ApplicationStateManager { public <T> T get(Class<T> ssoClass) { return getAdapter(ssoClass).getOrCreate(); } @SuppressWarnings("unchecked")  ApplicationStateManagerImpl(Map<Class, ApplicationStateContribution> configuration,
            ApplicationStatePersistenceStrategySource source, ObjectLocator locator); T get(Class<T> ssoClass); T getIfExists(Class<T> ssoClass); void set(Class<T> ssoClass, T sso); boolean exists(Class<T> ssoClass); }
ApplicationStateManagerImpl implements ApplicationStateManager { public <T> T get(Class<T> ssoClass) { return getAdapter(ssoClass).getOrCreate(); } @SuppressWarnings("unchecked")  ApplicationStateManagerImpl(Map<Class, ApplicationStateContribution> configuration,
            ApplicationStatePersistenceStrategySource source, ObjectLocator locator); T get(Class<T> ssoClass); T getIfExists(Class<T> ssoClass); void set(Class<T> ssoClass, T sso); boolean exists(Class<T> ssoClass);  }