Config implements ValueProvider { public String getPropertyValue(final Property property) { for (int i = providerChain.size() - 1; i >= 0; i--) { final ValueProvider provider = providerChain.get(i); final String value = provider.getPropertyValue(property); if (value != null) { return value; } } return null; } private  Config(); static Config getInstance(); void setContext(final Context context); String getPropertyValue(final Property property); Integer getPropertyValueAsInt(final Property property);  }
@Test public void get_emptyChain() { toTest.providerChain.clear(); assertNull(toTest.getPropertyValue(null)); }
@Test public void get_null() { assertNull(toTest.getPropertyValue(null)); }
@Test public void get_chainLogic() { final String first = "first"; final String second = "second"; toTest.providerChain.clear(); toTest.providerChain.add(new AbstractValueProvider() { public String getPropertyValue(Property property) { return first; } }); toTest.providerChain.add(new AbstractValueProvider() { public String getPropertyValue(Property property) { return second; } }); toTest.providerChain.add(new AbstractValueProvider() { public String getPropertyValue(Property property) { return null; } }); assertEquals(second, toTest.getPropertyValue(Property.MAP_PROVIDER_SCHEMA)); }