removed optional specific function

This commit is contained in:
Deboshree 2023-05-21 23:36:38 +05:30
parent c4431dadf5
commit a0079d22d2
2 changed files with 0 additions and 13 deletions

View File

@ -31,17 +31,6 @@ public class StringToIntConverter {
}
}
Optional<Integer> convertStringToIntUsingOptional(String input){
Optional<Integer> parsedInt;
try {
parsedInt = Optional.of(Integer.parseInt(input));
} catch (Exception e) {
// log or handle the error
parsedInt = Optional.empty();
}
return parsedInt;
}
int convertStringToIntUsingNumberUtils(String input, Integer defaultValue){
return NumberUtils.toInt(input, defaultValue);
}

View File

@ -22,7 +22,6 @@ class stringToIntConverter {
testData.forEach(data -> {
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingOptional(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerDecode(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingNumberUtils(data.input,Integer.MIN_VALUE ));
});
@ -37,7 +36,6 @@ class stringToIntConverter {
testData.forEach(data -> {
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerParseInt(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerValueOf(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingOptional(data.input).orElse(Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingNumberUtils(data.input, Integer.MIN_VALUE));
Assertions.assertEquals(data.expectedOutput, stringToIntConverter.convertStringToIntUsingIntegerDecode(data.input).orElse(Integer.MIN_VALUE));
});