CloudFilesRestClientModule extends SwiftRestClientModule<CloudFilesClient, CloudFilesAsyncClient> { @VisibleForTesting static <K, V> Supplier<V> valueForKey(final Supplier<Map<K, Supplier<V>>> input, final Supplier<K> key) { return new Supplier<V>() { @Override public V get() { K keyToFind = key.get(); Supplier<V> value = input.get().get(keyToFind); return value != null ? value.get() : null; } @Override public String toString() { return "withKey()"; } }; } CloudFilesRestClientModule();   }
@Test public void testWithKey() { assertEquals( CloudFilesRestClientModule.<String, String> valueForKey( Suppliers.<Map<String, Supplier<String>>> ofInstance(ImmutableMap.of("foo", Suppliers.ofInstance("bar"))), Suppliers.ofInstance("foo")).get(), "bar"); }
@Test public void testWithKeyUnmatchedIsNull() { assertEquals( CloudFilesRestClientModule.<String, String> valueForKey( Suppliers.<Map<String, Supplier<String>>> ofInstance(ImmutableMap.of("boo", Suppliers.ofInstance("bar"))), Suppliers.ofInstance("foo")).get(), null); }