BundleContextProvider implements ContextProvider { @Override public String get(final String key) { for (int i = 0; i < providers.length; ++i) { String value = providers[i].get(key); if (value != null) { return value; } } return null; } BundleContextProvider(final Collection<ContextProvider> providers); @Override Map<String, String> getMapping(); @Override String get(final String key); @Override void put(final String key, final Object value); @Override void remove(final String key); @Override void clear();  }
@Test public void getNonExistentValue() { when(first.get("pi")).thenReturn(null); when(second.get("pi")).thenReturn(null); assertThat(bundle.get("pi")).isNull(); }
@Test public void getExistentValue() { when(first.get("pi")).thenReturn("3.14"); when(second.get("pi")).thenReturn("3.14"); assertThat(bundle.get("pi")).isEqualTo("3.14"); }
@Test public void getExistentValueFromFirst() { when(first.get("pi")).thenReturn("3.14"); when(second.get("pi")).thenReturn(null); assertThat(bundle.get("pi")).isEqualTo("3.14"); }
@Test public void getExistentValueFromSecond() { when(first.get("pi")).thenReturn(null); when(second.get("pi")).thenReturn("3.14"); assertThat(bundle.get("pi")).isEqualTo("3.14"); }