### Question:
WorkerModule extends FlagBindingModule { @VisibleForTesting static TransferExtension findTransferExtension( ImmutableList<TransferExtension> transferExtensions, String service) { try { return transferExtensions .stream() .filter(ext -> ext.getServiceId().toLowerCase().equals(service.toLowerCase())) .collect(onlyElement()); } catch (IllegalArgumentException e) { throw new IllegalStateException( "Found multiple transfer extensions for service " + service, e); } catch (NoSuchElementException e) { throw new IllegalStateException( "Did not find a valid transfer extension for service " + service, e); } } WorkerModule(
      ExtensionContext context,
      CloudExtension cloudExtension,
      List<TransferExtension> transferExtensions,
      SecurityExtension securityExtension,
      IdempotentImportExecutor idempotentImportExecutor,
      SymmetricKeyGenerator symmetricKeyGenerator,
      JobHooks jobHooks); @Provides @Singleton IdempotentImportExecutor getIdempotentImportExecutor();  }### Answer:
@Test public void findTransferExtension() { ImmutableList<TransferExtension> transferExtensions = ImmutableList.of(FOO_UPPER, BAR_UPPER); assertThat(WorkerModule.findTransferExtension(transferExtensions, "FOO")).isEqualTo(FOO_UPPER); assertThat(WorkerModule.findTransferExtension(transferExtensions, "foo")).isEqualTo(FOO_UPPER); }
@Test public void findTransferExtension_mixedCasing() { ImmutableList<TransferExtension> transferExtensions = ImmutableList.of(FOO_UPPER, BAR_LOWER); assertThat(WorkerModule.findTransferExtension(transferExtensions, "FOO")).isEqualTo(FOO_UPPER); assertThat(WorkerModule.findTransferExtension(transferExtensions, "foo")).isEqualTo(FOO_UPPER); assertThat(WorkerModule.findTransferExtension(transferExtensions, "BAR")).isEqualTo(BAR_LOWER); assertThat(WorkerModule.findTransferExtension(transferExtensions, "bar")).isEqualTo(BAR_LOWER); }
@Test public void findTransferExtension_noMatch() { ImmutableList<TransferExtension> transferExtensions = ImmutableList.of(FOO_UPPER, BAR_UPPER); assertThrows(IllegalStateException.class, () -> WorkerModule.findTransferExtension(transferExtensions, "BAZ")); }
@Test public void findTransferExtension_duplicateMatches() { ImmutableList<TransferExtension> transferExtensions = ImmutableList.of(FOO_UPPER, FOO_LOWER); assertThrows(IllegalStateException.class, () -> WorkerModule.findTransferExtension(transferExtensions, "FOO")); }