@Test public void testInvalidJson() { String invalidJson = "invalidJson"; ConfigurationManager.getConfigInstance().setProperty("testInvalid", invalidJson); DynamicContextualProperty<Integer> prop = new DynamicContextualProperty<Integer>("key1", 0); try { new DynamicContextualProperty<Integer>("testInvalid", 0); fail("Exception expected"); } catch (Exception e) { assertNotNull(e); } ConfigurationManager.getConfigInstance().setProperty("key1", invalidJson); assertEquals(0, prop.getValue().intValue()); }
@Override public T getValue() { if (values != null) { for (Value<T> v: values) { if (v.getDimensions() == null || v.getDimensions().isEmpty() || predicate.apply(v.getDimensions())) { return v.getValue(); } } } return defaultValue; }
DynamicContextualProperty extends PropertyWrapper<T> { @Override public T getValue() { if (values != null) { for (Value<T> v: values) { if (v.getDimensions() == null || v.getDimensions().isEmpty() || predicate.apply(v.getDimensions())) { return v.getValue(); } } } return defaultValue; } }
DynamicContextualProperty extends PropertyWrapper<T> { @Override public T getValue() { if (values != null) { for (Value<T> v: values) { if (v.getDimensions() == null || v.getDimensions().isEmpty() || predicate.apply(v.getDimensions())) { return v.getValue(); } } } return defaultValue; } @SuppressWarnings("unchecked")  DynamicContextualProperty(String propName, T defaultValue, Predicate<Map<String, Collection<String>>> predicate); @SuppressWarnings("unchecked")  DynamicContextualProperty(String propName, T defaultValue); }
DynamicContextualProperty extends PropertyWrapper<T> { @Override public T getValue() { if (values != null) { for (Value<T> v: values) { if (v.getDimensions() == null || v.getDimensions().isEmpty() || predicate.apply(v.getDimensions())) { return v.getValue(); } } } return defaultValue; } @SuppressWarnings("unchecked")  DynamicContextualProperty(String propName, T defaultValue, Predicate<Map<String, Collection<String>>> predicate); @SuppressWarnings("unchecked")  DynamicContextualProperty(String propName, T defaultValue); @Override T getValue(); }
DynamicContextualProperty extends PropertyWrapper<T> { @Override public T getValue() { if (values != null) { for (Value<T> v: values) { if (v.getDimensions() == null || v.getDimensions().isEmpty() || predicate.apply(v.getDimensions())) { return v.getValue(); } } } return defaultValue; } @SuppressWarnings("unchecked")  DynamicContextualProperty(String propName, T defaultValue, Predicate<Map<String, Collection<String>>> predicate); @SuppressWarnings("unchecked")  DynamicContextualProperty(String propName, T defaultValue); @Override T getValue();  }