BundleContextProvider implements ContextProvider { @Override public Map<String, String> getMapping() { Map<String, String> mapping = new HashMap<String, String>(); for (int i = 0; i < providers.length; ++i) { mapping.putAll(providers[i].getMapping()); } return mapping; } 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 getEmptyMapping() { when(first.getMapping()).thenReturn(emptyMap()); when(second.getMapping()).thenReturn(emptyMap()); assertThat(bundle.getMapping()).isEmpty(); }
@Test public void getSameMapping() { when(first.getMapping()).thenReturn(doubletonMap("pi", "3.14", "e", "2.71")); when(second.getMapping()).thenReturn(doubletonMap("pi", "3.14", "e", "2.71")); assertThat(bundle.getMapping()).containsOnly(entry("pi", "3.14"), entry("e", "2.71")); }
@Test public void getDifferentMapping() { when(first.getMapping()).thenReturn(doubletonMap("pi", "3.14", "e", "2.71")); when(second.getMapping()).thenReturn(singletonMap("pi", "3.14")); assertThat(bundle.getMapping()).containsOnly(entry("pi", "3.14"), entry("e", "2.71")); }
@Test public void getConflictiveMapping() { when(first.getMapping()).thenReturn(doubletonMap("pi", "3.14", "G", "0.91")); when(second.getMapping()).thenReturn(doubletonMap("pi", "3.14", "G", "0.92")); assertThat(bundle.getMapping()).containsEntry("pi", "3.14").has(anyOf("G", "0.91", "0.92")).hasSize(2); }