Skip to content

Commit

Permalink
Merge branch 'feature/BT-4418-utf8faunareader_read_long' into feature/B…
Browse files Browse the repository at this point in the history
  • Loading branch information
pchitolina-fauna committed Jan 29, 2024
2 parents 168bc6d + 5d6d572 commit 7ec2fc6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 5 additions & 5 deletions faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public String getValueAsString() {
try {
return jsonParser.getValueAsString();
} catch (IOException e) {
throw new RuntimeException("Error getting the current token as String", e);
throw new SerializationException("Error getting the current token as String", e);
}
}

Expand All @@ -202,15 +202,15 @@ public Integer getValueAsInt() {
try {
return Integer.parseInt(taggedTokenValue);
} catch (NumberFormatException e) {
throw new RuntimeException("Error getting the current token as Integer", e);
throw new SerializationException("Error getting the current token as Integer", e);
}
}

public Boolean getValueAsBoolean() {
try {
return jsonParser.getValueAsBoolean();
} catch (IOException e) {
throw new RuntimeException("Error getting the current token as Boolean", e);
throw new SerializationException("Error getting the current token as Boolean", e);
}
}

Expand All @@ -219,7 +219,7 @@ public LocalDate getValueAsLocalDate() {
try {
return LocalDate.parse(taggedTokenValue);
} catch (NumberFormatException e) {
throw new RuntimeException("Error getting the current token as LocalDate", e);
throw new SerializationException("Error getting the current token as LocalDate", e);
}
}

Expand All @@ -228,7 +228,7 @@ public Instant getValueAsTime() {
try {
return Instant.parse(taggedTokenValue);
} catch (NumberFormatException e) {
throw new RuntimeException("Error getting the current token as LocalDateTime", e);
throw new SerializationException("Error getting the current token as LocalDateTime", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ public void testeGetValueAsTime() throws IOException {
assertThrows(RuntimeException.class, invalidReader::getValueAsLocalDate);
}

@Test
public void testeGetValueAsTimeNonUTC() throws IOException {
String s = "{\"@time\":\"2023-12-03T05:52:10.000001-09:00\"}";
InputStream inputStream = new ByteArrayInputStream(s.getBytes());
FaunaParser reader = new FaunaParser(inputStream);

Instant instant = Instant.parse("2023-12-03T05:52:10.000001-09:00");

List<Map.Entry<FaunaTokenType, Object>> expectedTokens = List.of(
Map.entry(FaunaTokenType.TIME, instant)
);

assertReader(reader, expectedTokens);

}

@Test
public void testGetValueAsDouble() throws IOException {
String s = "{\"@double\": \"1.23\"}";
Expand Down

0 comments on commit 7ec2fc6

Please sign in to comment.