### Question:
VerifierWebWorkerRegistry { public Optional<VerifierWebWorkerProvider> get(final String id) { if (map.containsKey(id)) { return Optional.of(map.get(id)); } else { return Optional.empty(); } } VerifierWebWorkerRegistry(); @Inject  VerifierWebWorkerRegistry(@Any final Instance<VerifierWebWorkerProvider> verifierWebWorkerProviders); Optional<VerifierWebWorkerProvider> get(final String id);  }### Answer:
@Test public void noWebWorkerProviders() throws Exception { final Instance verifierWebWorkerProviders = mock(Instance.class); doReturn(new ArrayList<>().iterator()).when(verifierWebWorkerProviders).iterator(); assertFalse(new VerifierWebWorkerRegistry(verifierWebWorkerProviders).get("something").isPresent()); }
@Test public void wrongId() throws Exception { final Instance verifierWebWorkerProviders = mock(Instance.class); final ArrayList<Object> webWorkerProviders = new ArrayList<>(); webWorkerProviders.add(getWebWorkerProvider("somethingElse")); doReturn(webWorkerProviders.iterator()).when(verifierWebWorkerProviders).iterator(); assertFalse(new VerifierWebWorkerRegistry(verifierWebWorkerProviders).get("something").isPresent()); }
@Test public void correctId() throws Exception { final Instance verifierWebWorkerProviders = mock(Instance.class); final ArrayList<Object> webWorkerProviders = new ArrayList<>(); webWorkerProviders.add(getWebWorkerProvider("something")); doReturn(webWorkerProviders.iterator()).when(verifierWebWorkerProviders).iterator(); assertTrue(new VerifierWebWorkerRegistry(verifierWebWorkerProviders).get("something").isPresent()); }