DefaultConfiguration implements Configuration, Serializable { @Override public String get(String key) { Objects.requireNonNull(key, "Key must not be null."); PropertyValue value = configEvaluator.evaluateRawValue(key, configurationContext); if(value==null || value.getValue()==null){ return null; } value = PropertyFiltering.applyFilter(value, configurationContext); if(value!=null){ return value.getValue(); } return null; } DefaultConfiguration(ConfigurationContext configurationContext); @Override String get(String key); List<PropertyValue> getValues(String key); @Override String getOrDefault(String key, String defaultValue); @Override T getOrDefault(String key, Class<T> type, T defaultValue); @Override Map<String, String> getProperties(); @Override T get(String key, Class<T> type); @Override T get(String key, TypeLiteral<T> type); @Override T getOrDefault(String key, TypeLiteral<T> type, T defaultValue); @Override Configuration with(ConfigOperator operator); @Override T query(ConfigQuery<T> query); @Override ConfigurationContext getContext(); @Override ConfigurationSnapshot getSnapshot(Iterable<String> keys); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test(expected = NullPointerException.class) public void getDoesNotAcceptNull() { DefaultConfiguration c = new DefaultConfiguration(new MockedConfigurationContext()); c.get((String)null); }
@Test(expected = NullPointerException.class) public void getDoesNotAcceptNull2() { DefaultConfiguration c = new DefaultConfiguration(new MockedConfigurationContext()); c.get((Iterable<String>) null); }
@SuppressWarnings({"rawtypes", "unchecked"}) @Test(expected = NullPointerException.class) public void getDoesNotAcceptNullForClassTargetType() { DefaultConfiguration c = new DefaultConfiguration(new MockedConfigurationContext()); c.get("a", (Class) null); }
@Test(expected = NullPointerException.class) public void getDoesNotAcceptNullForTypeLiteralTargetType() { DefaultConfiguration c = new DefaultConfiguration(new MockedConfigurationContext()); c.get("a", (TypeLiteral<?>) null); }
@Test public void getReturnsNullOrNotAsAppropriate() { DefaultConfiguration c = new DefaultConfiguration(new MockedConfigurationContext()); assertThat(c.get("valueOfValid")).isNotNull(); assertThat(c.get("valueOfNull")).isNull(); assertThat(c.get("Filternull")).isNull(); }