DefaultCRestConfig implements CRestConfig { public <T> T get(String key) { return (T) config.get(key); } DefaultCRestConfig(Map<String, Object> m); CRestConfig merge(Map<String, Object> m); T get(String key); T get(String propName, T defaultIfNotFound); T get(Class<?> key); T get(Class<?> key, T defaultIfNotFound); int getMaxAttempts(); String getDateFormat(); String getBooleanTrue(); String getBooleanFalse(); int getConcurrencyLevel();  }
@Test public void getShouldDelegateToMap(){ when(config.get("a")).thenReturn("b"); assertEquals("b", toTest.get("a")); }
@Test public void getWithDefaultShouldReturnMapValueWhenPresent(){ when(config.containsKey("a")).thenReturn(true); when(config.get("a")).thenReturn("b"); assertEquals("b", toTest.get("a", "c")); }
@Test public void getWithDefaultShouldReturnDefaultWhenNotInMap(){ assertEquals("c", toTest.get("b", "c")); }
@Test public void getWithClassShouldLookForPropWithClassName(){ when(config.containsKey(DefaultCRestConfigTest.class.getName())).thenReturn(true); when(config.get(DefaultCRestConfigTest.class.getName())).thenReturn("b"); assertEquals("b", toTest.get(DefaultCRestConfigTest.class)); }
@Test public void getWithClassAndDefaultShouldLookForPropWithClassNameAndReturnIt(){ when(config.containsKey(DefaultCRestConfigTest.class.getName())).thenReturn(true); when(config.get(DefaultCRestConfigTest.class.getName())).thenReturn("b"); assertEquals("b", toTest.get(DefaultCRestConfigTest.class, "c")); }
@Test public void getWithClassAndDefaultShouldLookForPropWithClassNameAndReturnDefault(){ assertEquals("c", toTest.get(DefaultCRestConfigTest.class, "c")); }