### Question:
MemoryBackedRegistry extends AbstractRegistry<T> { public void add(T t) { resources.put(t.id(), t); if (autoReload) { reload(); } } MemoryBackedRegistry(); private  MemoryBackedRegistry(boolean autoReload); void add(T t); void removeById(Id id); void reset(); @Override CompletableFuture<ReloadResult> reload();  }### Answer:
@Test public void addsResources() { BackendService landing = backendService("landing", 9091); BackendService shopping = backendService("shopping", 9090); MemoryBackedRegistry<BackendService> registry = new MemoryBackedRegistry<>(); registry.add(landing); registry.addListener(listener); registry.add(shopping); assertThat(registry.get(), containsInAnyOrder(landing, shopping)); verify(listener).onChange(eq(added(shopping))); }
@Test public void updatesResources() { BackendService landing = backendService("landing", 9091); MemoryBackedRegistry<BackendService> registry = new MemoryBackedRegistry<>(); registry.add(backendService("shopping", 9090)); registry.add(landing); registry.addListener(listener); BackendService shopping = backendService("shopping", 9091); registry.add(shopping); assertThat(registry.get(), containsInAnyOrder(landing, shopping)); verify(listener).onChange(eq(updated(shopping))); }