WindowScope implements Scope { @SuppressWarnings("unchecked") @Override public Object get(String name, ObjectFactory<?> objectFactory) { WindowScopeManager.ScopeMap scopeMap = getScopeMap(); Object bean = scopeMap.get(name); if (bean == null) { bean = objectFactory.getObject(); scopeMap.put(name, bean); } return bean; }  @SuppressWarnings("unchecked") @Override Object get(String name, ObjectFactory<?> objectFactory); @Override Object remove(String name); @Override void registerDestructionCallback(String name, Runnable runnable); @Override Object resolveContextualObject(String name); @Override String getConversationId();  }
@SuppressWarnings("unchecked") @Test public void get() { assertThat(this.scopeMap).doesNotContainKeys("foo"); Object bean = new Object(); assertThat(this.windowScope.get("foo", () -> bean)) .isSameAs(bean); assertThat(this.scopeMap).containsKey("foo"); assertThat(this.windowScope.get("foo", () -> { fail("The bean should already exist"); return null; })) .isSameAs(bean); }