Skip to content
Merged
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 @@ -6,6 +6,7 @@

import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.exc.InvalidFormatException;
import tools.jackson.databind.exc.MismatchedInputException;
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator;

Expand All @@ -29,10 +30,29 @@ public void shouldDeserialize() throws Exception {
@Test
public void shouldNotDeserializeInvalidCurrency() {
final InvalidFormatException e = assertThrows(InvalidFormatException.class, () ->
unit.readValue("\"FOO\"", CurrencyUnit.class));
unit.readValue(a2q("'FOO'"), CurrencyUnit.class));
assertThat(e.getMessage()).contains("FOO");
assertThat(e.getValue()).isEqualTo("FOO");
}

@Test
public void shouldNotDeserializeFromNumber() {
assertThrows(MismatchedInputException.class, () ->
unit.readValue("12", CurrencyUnit.class));
}

@Test
public void shouldNotDeserializeFromObject() {
assertThrows(MismatchedInputException.class, () ->
unit.readValue(a2q("{'a':1}"), CurrencyUnit.class));
}

@Test
public void shouldNotDeserializeFromArray() {
assertThrows(MismatchedInputException.class, () ->
unit.readValue("[1,2]", CurrencyUnit.class));
}

@Test
public void shouldDeserializeWithTyping() throws Exception {
ObjectMapper mapper = JsonMapper.builder()
Expand All @@ -45,4 +65,8 @@ public void shouldDeserializeWithTyping() throws Exception {

assertThat(actual).isEqualTo(expected);
}

private static String a2q(final String json) {
return json.replace("'", "\"");
}
}
Loading