ninja
ninja copied to clipboard
MockNinjaProperties do not handle default values
Default values in methods getWithDefault, getIntegerWithDefault and getBooleanWithDefault are not implemented correctly. If the value is not present, null is returned and not the default. If the value is present, the default is returned and not the configured / mocked value.
Code snip:
@Override
public String getWithDefault(String key, String defaultValue) {
String value = get(key);
if (value == null) {
return null;
} else {
return defaultValue;
}
}
@Override
public Integer getIntegerWithDefault(String key, Integer defaultValue) {
Integer value = getInteger(key);
if (value == null) {
return null;
} else {
return defaultValue;
}
}
@Override
public Boolean getBooleanWithDefault(String key, Boolean defaultValue) {
Boolean value = getBoolean(key);
if (value == null) {
return null;
} else {
return defaultValue;
}
}
I'm using version 6.4.0. If this is somewhat intended behavior, then it would be good to have javadocs pointing to this.
I just stumbled upon this as well.. can anyone fix this please? Happy to create the MR, but it would probably be faster if the author (@raphaelbauer) just copy/pates the code form the NinjaPropertiesImpl
class (or changes == null
to != null
)