Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Integer coerce(Object obj) {
} else {
// try to parse string to int
try {
return Integer.parseInt(obj.toString());
return Integer.parseInt(obj.toString().trim());
} catch (NumberFormatException e) {
// ugly flow control
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public void givenLongInstanceThenCoerceCastIntoInteger() {
assertEquals(Integer.valueOf(100), sut.coerce(100L));
}

@Test
public void givenWhitespaceStringWithIntegerCoerceCastIntoInteger() {
assertEquals(Integer.valueOf(100), sut.coerce(" 100 "));
}

@Test(expected = IllegalArgumentException.class)
public void givenDoubleInstanceThenCoerceThrowsException() {
sut.coerce(1.1);
Expand Down