### Question:
ConcurrentDoubleLockingScope implements Scope { @Override public <T> T getScopedObject(ScopeKey<T> key, Provider<T> provider) { Object result = singletonMap.get(key); if (result == null) { Object value = provider.get(); result = singletonMap.putIfAbsent(key, value); if (result == null) { result = value; } } return (T) result; }  @Override T getScopedObject(ScopeKey<T> key, Provider<T> provider);  }### Answer:
@Test public void testScopedBuild() { when(builder.get()).thenReturn(scopeTarget); ScopeTarget resultTarget = scope.getScopedObject(ScopeKey.of(ScopeTarget.class), builder); assertEquals(scopeTarget, resultTarget); ScopeTarget secondResultTarget = scope.getScopedObject(ScopeKey.of(ScopeTarget.class), builder); assertEquals(scopeTarget, secondResultTarget); }
@Test public void testKeyScope(){ class ScopeTargetBuilderImpl implements ScopeTargetBuilder{ @Override public ScopeTarget get() { return new ScopeTarget(); } } ScopeTarget scoped1 = scope.getScopedObject(ScopeKey.of(ScopeTarget.class), new ScopeTargetBuilderImpl()); ScopeTarget scoped2 = scope.getScopedObject(ScopeKey.of(ScopeTarget.class), new ScopeTargetBuilderImpl()); ScopeTarget scoped3 = scope.getScopedObject(ScopeKey.of(ScopeTarget.class), new ScopeTargetBuilderImpl()); ScopeTarget scoped4 = scope.getScopedObject(ScopeKey.of(ScopeTarget.class).annotatedBy("@test"), new ScopeTargetBuilderImpl()); ScopeTarget scoped5 = scope.getScopedObject(ScopeKey.of(ScopeTarget.class).annotatedBy("@test"), new ScopeTargetBuilderImpl()); ScopeTarget scoped6 = scope.getScopedObject(ScopeKey.of(ScopeTarget.class).annotatedBy("@test2"), new ScopeTargetBuilderImpl()); assertSame(scoped1, scoped2); assertSame(scoped1, scoped3); assertSame(scoped4, scoped5); assertNotSame(scoped1, scoped4); assertNotSame(scoped1, scoped4); assertNotSame(scoped1, scoped6); assertNotSame(scoped5, scoped6); }