DefaultConfigurationSnapshot implements ConfigurationSnapshot, Serializable { @Override public String get(String key) { return this.snapshot.get(key); } DefaultConfigurationSnapshot(Configuration config, Iterable<String> keys);  DefaultConfigurationSnapshot(Configuration config); @Override ConfigurationSnapshot getSnapshot(Iterable<String> keys); @Override Set<String> getKeys(); @Override String get(String key); @Override String getOrDefault(String key, String defaultValue); @Override T getOrDefault(String key, Class<T> type, T defaultValue); @SuppressWarnings("unchecked") @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 Map<String, String> getProperties(); @Override ConfigurationContext getContext(); @Override long getTimestamp(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); UUID getId();  }
@Test public void testGet() { Configuration config = Configuration.current(); DefaultConfigurationSnapshot snapshot = new DefaultConfigurationSnapshot(config, Arrays.asList("confkey1", "confkey2", "confkey3")); assertThat("javaconf-value1").isEqualTo(snapshot.get("confkey1")); assertThat("javaconf-value2").isEqualTo(snapshot.get("confkey2")); assertThat("javaconf-value3").isEqualTo(snapshot.get("confkey3")); assertThat(snapshot.getOrDefault("confkey4", null)).isNull(); assertThat("javaconf-value1").isEqualTo(snapshot.get("confkey1", String.class)); assertThat("javaconf-value2").isEqualTo(snapshot.get("confkey2", String.class)); assertThat("javaconf-value3").isEqualTo(snapshot.get("confkey3", String.class)); assertThat(snapshot.getOrDefault("confkey4", String.class, null)).isNull(); assertThat("javaconf-value1").isEqualTo(snapshot.get("confkey1", TypeLiteral.of(String.class))); assertThat("javaconf-value2").isEqualTo(snapshot.get("confkey2", TypeLiteral.of(String.class))); assertThat("javaconf-value3").isEqualTo(snapshot.get("confkey3", TypeLiteral.of(String.class))); assertThat((String) snapshot.getOrDefault("confkey4", TypeLiteral.of(String.class), null)).isNull(); }
@Test public void testGet_with_MultiKey() { Configuration config = Configuration.current(); DefaultConfigurationSnapshot snapshot = new DefaultConfigurationSnapshot(config, Arrays.asList("confkey1", "confkey2", "confkey3")); assertThat("javaconf-value1").isEqualTo(snapshot.get(Arrays.asList("confkey1", "foo"))); assertThat("javaconf-value2").isEqualTo(snapshot.get(Arrays.asList("foo", "confkey2"))); assertThat("javaconf-value1").isEqualTo(snapshot.get(Arrays.asList("confkey1", "foo"), String.class)); assertThat("javaconf-value2").isEqualTo(snapshot.get(Arrays.asList("foo", "confkey2"), String.class)); }