pass default value as method param
This commit is contained in:
parent
60eb348df5
commit
d694564141
@ -46,8 +46,8 @@ public class StringToIntConverter {
|
||||
return parsedInt.orElse(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
public static int convertStringToIntUsingNumberUtils(String input){
|
||||
return NumberUtils.toInt(input, Integer.MIN_VALUE);
|
||||
public static int convertStringToIntUsingNumberUtils(String input, Integer defaultValue){
|
||||
return NumberUtils.toInt(input, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class StringToIntConverterUnitTest {
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingOptional(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingIntegerDecode(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingNumberUtils(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingNumberUtils(data.input,Integer.MIN_VALUE ));
|
||||
});
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class StringToIntConverterUnitTest {
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingOptional(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingNumberUtils(data.input));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingNumberUtils(data.input, Integer.MIN_VALUE));
|
||||
Assertions.assertEquals(data.expectedOutput, StringToIntConverter.convertStringToIntUsingIntegerDecode(data.input));
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user