Config implements ValueProvider { public Integer getPropertyValueAsInt(final Property property) { for (int i = providerChain.size() - 1; i >= 0; i--) { final ValueProvider provider = providerChain.get(i); final Integer value = provider.getPropertyValueAsInt(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 getInt_chainLogic() { toTest.providerChain.clear(); for (int i = 0; i < 3; i++) { toTest.providerChain.add(mock(ValueProvider.class)); if (i != 2) { doReturn(i).when(toTest.providerChain.get(i)).getPropertyValueAsInt(any(Property.class)); } else { doReturn(null).when(toTest.providerChain.get(i)).getPropertyValueAsInt(any(Property.class)); } } assertTrue(1 == toTest.getPropertyValueAsInt(Property.MAP_PROVIDER_SCHEMA)); }
@Test public void getInt_emptyChain() { toTest.providerChain.clear(); assertNull(toTest.getPropertyValueAsInt(null)); }