ScopeProviderContainer implements IScopeProviderContainer { public Object createScope(final Object params) throws ScopeProviderException { try { IScope newScope = factory.createScope(params); for (IAction<IScope> handler : handlerStorage) { handler.execute(newScope); } Object uuid = UUID.randomUUID(); scopeStorage.put(uuid, newScope); return uuid; } catch (Throwable e) { throw new ScopeProviderException("Failed to create instance of IScope.", e); } } ScopeProviderContainer(final IScopeFactory factory); IScope getScope(final Object key); IScope getCurrentScope(); void addScope(final Object key, final IScope scope); void setCurrentScope(final IScope scope); void deleteScope(final Object key); Object createScope(final Object params); @Override void subscribeOnCreationNewScope(final IAction<IScope> handler); @Override void clearListOfSubscribers();  }
@Test (expected = ScopeProviderException.class) public void checkScopeProviderExceptionByCreate() throws Exception { IScopeFactory factory = mock(IScopeFactory.class); IScopeProviderContainer scopeProviderContainer = new ScopeProviderContainer(factory); scopeProviderContainer.createScope(null); fail(); }