pass default value as method param
This commit is contained in:
Deboshree 2023-04-10 08:30:15 +05:30
parent 60eb348df5
commit d694564141
2 changed files with 4 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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));
});
}