SpaceConfigStorageRegistryImpl implements SpaceConfigStorageRegistry { @Override public SpaceConfigStorage get(final String spaceName) { return storageBySpaceName.computeIfAbsent(spaceName, name -> { final SpaceConfigStorage spaceConfigStorage = spaceConfigStorages.get(); spaceConfigStorage.setup(spaceName); return spaceConfigStorage; }); } SpaceConfigStorageRegistryImpl(); @Inject  SpaceConfigStorageRegistryImpl(final Instance<SpaceConfigStorage> spaceConfigStorages); @Override SpaceConfigStorage get(final String spaceName); @Override SpaceConfigStorageBatch getBatch(String spaceName); @Override void remove(String spaceName); @Override boolean exist(String spaceName);  }
@Test public void getTest() { doReturn(mySpaceConfigStorage).when(spaceConfigStorages).get(); final SpaceConfigStorage spaceConfigStorage1 = spaceConfigStorageRegistry.get(SPACE_NAME); assertSame(mySpaceConfigStorage, spaceConfigStorage1); doReturn(otherSpaceConfigStorage).when(spaceConfigStorages).get(); final SpaceConfigStorage spaceConfigStorage2 = spaceConfigStorageRegistry.get(SPACE_NAME); assertSame(mySpaceConfigStorage, spaceConfigStorage2); }