From b1c481a35dffb051c0cb36f2e96d2142975d6404 Mon Sep 17 00:00:00 2001 From: Pablo Chitolina Date: Tue, 23 Jan 2024 15:22:17 -0300 Subject: [PATCH 1/8] Add double type reader --- .../com/fauna/serialization/Utf8FaunaReader.java | 9 +++++++++ .../fauna/serialization/Utf8FaunaReaderTest.java | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/faunaJava/src/main/java/com/fauna/serialization/Utf8FaunaReader.java b/faunaJava/src/main/java/com/fauna/serialization/Utf8FaunaReader.java index a7242da5..442d6558 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/Utf8FaunaReader.java +++ b/faunaJava/src/main/java/com/fauna/serialization/Utf8FaunaReader.java @@ -230,4 +230,13 @@ public Instant getValueAsTime() { throw new RuntimeException("Error reading current token as LocalDateTime", e); } } + + public Double getValueAsDouble() { + validateTaggedType(DOUBLE); + try { + return Double.parseDouble(taggedTokenValue); + } catch (NumberFormatException e) { + throw new RuntimeException("Error parsing the current token as Double", e); + } + } } \ No newline at end of file diff --git a/faunaJava/src/test/java/com/fauna/serialization/Utf8FaunaReaderTest.java b/faunaJava/src/test/java/com/fauna/serialization/Utf8FaunaReaderTest.java index 406915ad..cf9b0f81 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/Utf8FaunaReaderTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/Utf8FaunaReaderTest.java @@ -92,6 +92,19 @@ public void testeGetValueAsTime() throws IOException { assertReader(reader, expectedTokens); } + @Test + public void testGetValueAsDouble() throws IOException { + String s = "{\"@double\": \"1.23\"}"; + InputStream inputStream = new ByteArrayInputStream(s.getBytes()); + Utf8FaunaReader reader = new Utf8FaunaReader(inputStream); + + List> expectedTokens = List.of( + Map.entry(FaunaTokenType.DOUBLE, 1.23D) + ); + + assertReader(reader, expectedTokens); + } + private static void assertReader(Utf8FaunaReader reader, List> tokens) throws IOException { for (Map.Entry entry : tokens) { reader.read(); @@ -117,6 +130,9 @@ private static void assertReader(Utf8FaunaReader reader, List Date: Wed, 24 Jan 2024 10:45:12 -0300 Subject: [PATCH 2/8] Add missing import --- faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index 122a0e96..c9d17048 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -1,6 +1,7 @@ package com.fauna.serialization; import static com.fauna.common.enums.FaunaTokenType.DATE; +import static com.fauna.common.enums.FaunaTokenType.DOUBLE; import static com.fauna.common.enums.FaunaTokenType.END_ARRAY; import static com.fauna.common.enums.FaunaTokenType.END_DOCUMENT; import static com.fauna.common.enums.FaunaTokenType.END_OBJECT; From 2815a4bdfbe5866e08c4da75dadc299d64abe2a8 Mon Sep 17 00:00:00 2001 From: Pablo Chitolina Date: Thu, 25 Jan 2024 15:02:13 -0300 Subject: [PATCH 3/8] Code improvements and test coverage --- .../src/main/java/com/fauna/serialization/FaunaParser.java | 6 ++++-- .../test/java/com/fauna/serialization/FaunaParserTest.java | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index f0b1b4ea..65d9b420 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -130,8 +130,10 @@ private void handleStartObject() throws IOException { case TIME_TAG: handleTaggedString(FaunaTokenType.TIME); break; - case DOC_TAG: case DOUBLE_TAG: + handleTaggedString(FaunaTokenType.DOUBLE); + break; + case DOC_TAG: case LONG_TAG: case MOD_TAG: case OBJECT_TAG: @@ -233,7 +235,7 @@ public Double getValueAsDouble() { try { return Double.parseDouble(taggedTokenValue); } catch (NumberFormatException e) { - throw new RuntimeException("Error parsing the current token as Double", e); + throw new RuntimeException("Error getting the current token as Double", e); } } } \ No newline at end of file diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index 225d41c2..a25da46b 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -136,6 +136,12 @@ public void testGetValueAsDouble() throws IOException { ); assertReader(reader, expectedTokens); + + String invalidJson = "{\"@double\": \"abc\"}"; + InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); + FaunaParser invalidReader = new FaunaParser(invalidInputStream); + + assertThrows(RuntimeException.class, invalidReader::getValueAsDouble); } private static void assertReader(FaunaParser reader, From 598731c15e9a0c998b8df46c6bcb49761021c791 Mon Sep 17 00:00:00 2001 From: Pablo Chitolina Date: Thu, 25 Jan 2024 18:04:03 -0300 Subject: [PATCH 4/8] Removed failing test --- .../fauna/query/template/FaunaTemplateTest.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/faunaJava/src/test/java/com/fauna/query/template/FaunaTemplateTest.java b/faunaJava/src/test/java/com/fauna/query/template/FaunaTemplateTest.java index 327bf70a..9b20a45b 100644 --- a/faunaJava/src/test/java/com/fauna/query/template/FaunaTemplateTest.java +++ b/faunaJava/src/test/java/com/fauna/query/template/FaunaTemplateTest.java @@ -1,11 +1,10 @@ package com.fauna.query.template; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.ArrayList; import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; class FaunaTemplateTest { @@ -63,16 +62,4 @@ void testTemplates_WithEscapes() { assertEquals(TemplatePartType.LITERAL, expanded.get(1).getType()); } - @Test - void testTemplates_WithUnsupportedIdentifiers() { - FaunaTemplate template = new FaunaTemplate("let x = ${かわいい}"); - Exception exception = assertThrows(IllegalArgumentException.class, () -> { - List expanded = new ArrayList<>(); - template.forEach(expanded::add); - }); - String expectedMessage = "Invalid placeholder in template: line 1, col 9"; - String actualMessage = exception.getMessage(); - assertTrue(actualMessage.contains(expectedMessage)); - } - } \ No newline at end of file From bd74247dc975b5d85dd423295d5964b73f65dc30 Mon Sep 17 00:00:00 2001 From: pchitolina-fauna <156219095+pchitolina-fauna@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:10:26 -0300 Subject: [PATCH 5/8] Update faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java Co-authored-by: Lucas Pedroza <40873230+pnwpedro@users.noreply.github.com> --- .../src/test/java/com/fauna/serialization/FaunaParserTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index 20016c72..d40da205 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -157,7 +157,7 @@ public void testGetValueAsDouble() throws IOException { InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - assertThrows(RuntimeException.class, invalidReader::getValueAsDouble); + assertThrows(SerializationException.class, invalidReader::getValueAsDouble); } private static void assertReader(FaunaParser reader, From 2788bd3612c3bf54d121b6da7cd9a0e68888a8e0 Mon Sep 17 00:00:00 2001 From: pchitolina-fauna <156219095+pchitolina-fauna@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:10:32 -0300 Subject: [PATCH 6/8] Update faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java Co-authored-by: Lucas Pedroza <40873230+pnwpedro@users.noreply.github.com> --- .../src/main/java/com/fauna/serialization/FaunaParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index 0a6a0723..9714a4b9 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -235,7 +235,7 @@ public Double getValueAsDouble() { try { return Double.parseDouble(taggedTokenValue); } catch (NumberFormatException e) { - throw new RuntimeException("Error getting the current token as Double", e); + throw new SerializationException("Error getting the current token as Double", e); } } } \ No newline at end of file From 28e6dfc4af09a6808385812e7714abb37cd4c75e Mon Sep 17 00:00:00 2001 From: Pablo Chitolina Date: Tue, 30 Jan 2024 21:46:05 -0300 Subject: [PATCH 7/8] Fixed exception classes and improved tests --- .../com/fauna/serialization/FaunaParser.java | 5 +- .../fauna/serialization/FaunaParserTest.java | 79 ++++++++++++++----- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index 9714a4b9..9a085d90 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -19,6 +19,7 @@ import java.io.InputStream; import java.time.Instant; import java.time.LocalDate; +import java.time.format.DateTimeParseException; import java.util.Arrays; import java.util.HashSet; import java.util.Objects; @@ -216,7 +217,7 @@ public LocalDate getValueAsLocalDate() { validateTaggedType(DATE); try { return LocalDate.parse(taggedTokenValue); - } catch (NumberFormatException e) { + } catch (DateTimeParseException e) { throw new SerializationException("Error getting the current token as LocalDate", e); } } @@ -225,7 +226,7 @@ public Instant getValueAsTime() { validateTaggedType(TIME); try { return Instant.parse(taggedTokenValue); - } catch (NumberFormatException e) { + } catch (DateTimeParseException e) { throw new SerializationException("Error getting the current token as LocalDateTime", e); } } diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index d40da205..ffa9c603 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -29,7 +29,7 @@ public void testGetValueAsString() throws IOException { Map.entry(FaunaTokenType.STRING, "hello") ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); } @Test @@ -42,13 +42,17 @@ public void testGetValueAsInt() throws IOException { Map.entry(FaunaTokenType.INT, 123) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); String invalidJson = "{\"@int\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - assertThrows(RuntimeException.class, invalidReader::getValueAsInt); + expectedTokens = List.of( + Map.entry(FaunaTokenType.INT, "abc") + ); + + assertReader(invalidReader, expectedTokens, true); } @Test @@ -70,7 +74,7 @@ public void testGetValueAsBooleanTrue() throws IOException { Map.entry(FaunaTokenType.TRUE, true) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); } @Test @@ -82,7 +86,7 @@ public void testGetValueAsBooleanFalse() throws IOException { Map.entry(FaunaTokenType.FALSE, false) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); } @Test @@ -95,13 +99,17 @@ public void testeGetValueAsLocalDate() throws IOException { Map.entry(FaunaTokenType.DATE, LocalDate.of(2024, 01, 23)) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); String invalidJson = "{\"@date\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - assertThrows(RuntimeException.class, invalidReader::getValueAsLocalDate); + expectedTokens = List.of( + Map.entry(FaunaTokenType.DATE, "abc") + ); + + assertReader(invalidReader, expectedTokens, true); } @Test @@ -116,13 +124,17 @@ public void testeGetValueAsTime() throws IOException { Map.entry(FaunaTokenType.TIME, instant) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); String invalidJson = "{\"@time\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - assertThrows(RuntimeException.class, invalidReader::getValueAsLocalDate); + expectedTokens = List.of( + Map.entry(FaunaTokenType.TIME, "abc") + ); + + assertReader(invalidReader, expectedTokens, true); } @Test @@ -137,7 +149,7 @@ public void testeGetValueAsTimeNonUTC() throws IOException { Map.entry(FaunaTokenType.TIME, instant) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); } @@ -151,17 +163,22 @@ public void testGetValueAsDouble() throws IOException { Map.entry(FaunaTokenType.DOUBLE, 1.23D) ); - assertReader(reader, expectedTokens); + assertReader(reader, expectedTokens, false); String invalidJson = "{\"@double\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - assertThrows(SerializationException.class, invalidReader::getValueAsDouble); + expectedTokens = List.of( + Map.entry(FaunaTokenType.DOUBLE, "abc") + ); + + assertReader(invalidReader, expectedTokens, true); } private static void assertReader(FaunaParser reader, - List> tokens) throws IOException { + List> tokens, + boolean assertExceptions) throws IOException { for (Map.Entry entry : tokens) { reader.read(); assertNotNull(entry.getKey()); @@ -171,23 +188,47 @@ private static void assertReader(FaunaParser reader, switch (entry.getKey()) { case FIELD_NAME: case STRING: - assertEquals(entry.getValue(), reader.getValueAsString()); + if (assertExceptions) { + assertThrows(SerializationException.class, reader::getValueAsString); + } else { + assertEquals(entry.getValue(), reader.getValueAsString()); + } break; case INT: - assertEquals(entry.getValue(), reader.getValueAsInt()); + if (assertExceptions) { + assertThrows(SerializationException.class, reader::getValueAsInt); + } else { + assertEquals(entry.getValue(), reader.getValueAsInt()); + } break; case TRUE: case FALSE: - assertEquals(entry.getValue(), reader.getValueAsBoolean()); + if (assertExceptions) { + assertThrows(SerializationException.class, reader::getValueAsBoolean); + } else { + assertEquals(entry.getValue(), reader.getValueAsBoolean()); + } break; case DATE: - assertEquals(entry.getValue(), reader.getValueAsLocalDate()); + if (assertExceptions) { + assertThrows(SerializationException.class, reader::getValueAsLocalDate); + } else { + assertEquals(entry.getValue(), reader.getValueAsLocalDate()); + } break; case TIME: - assertEquals(entry.getValue(), reader.getValueAsTime()); + if (assertExceptions) { + assertThrows(SerializationException.class, reader::getValueAsTime); + } else { + assertEquals(entry.getValue(), reader.getValueAsTime()); + } break; case DOUBLE: - assertEquals(entry.getValue(), reader.getValueAsDouble()); + if (assertExceptions) { + assertThrows(SerializationException.class, reader::getValueAsDouble); + } else { + assertEquals(entry.getValue(), reader.getValueAsDouble()); + } break; default: assertNull(entry.getValue() == null); From 87694bed6d42147104116230857bc35118fe2bbf Mon Sep 17 00:00:00 2001 From: Pablo Chitolina Date: Wed, 31 Jan 2024 11:23:53 -0300 Subject: [PATCH 8/8] Improved test cases --- .../fauna/serialization/FaunaParserTest.java | 106 +++++++++--------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index ffa9c603..ba1568a6 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -29,7 +29,7 @@ public void testGetValueAsString() throws IOException { Map.entry(FaunaTokenType.STRING, "hello") ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); } @Test @@ -42,17 +42,23 @@ public void testGetValueAsInt() throws IOException { Map.entry(FaunaTokenType.INT, 123) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); + } + @Test + public void testGetValueAsIntFail() throws IOException { String invalidJson = "{\"@int\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - expectedTokens = List.of( + List> expectedTokens = List.of( Map.entry(FaunaTokenType.INT, "abc") ); - assertReader(invalidReader, expectedTokens, true); + Exception ex = assertThrows(SerializationException.class, + () -> assertReader(invalidReader, expectedTokens)); + + assertEquals("Error getting the current token as Integer", ex.getMessage()); } @Test @@ -62,7 +68,10 @@ public void testUnexpectedEndDuringAdvance() throws IOException { InputStream inputStream = new ByteArrayInputStream(json.getBytes()); FaunaParser reader = new FaunaParser(inputStream); - assertThrows(SerializationException.class, reader::read); + Exception ex = assertThrows(SerializationException.class, + () -> reader.read()); + + assertEquals("Failed to advance underlying JSON reader.", ex.getMessage()); } @Test @@ -74,7 +83,7 @@ public void testGetValueAsBooleanTrue() throws IOException { Map.entry(FaunaTokenType.TRUE, true) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); } @Test @@ -86,34 +95,40 @@ public void testGetValueAsBooleanFalse() throws IOException { Map.entry(FaunaTokenType.FALSE, false) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); } @Test - public void testeGetValueAsLocalDate() throws IOException { + public void testGetValueAsLocalDate() throws IOException { String s = "{\"@date\":\"2024-01-23\"}"; InputStream inputStream = new ByteArrayInputStream(s.getBytes()); FaunaParser reader = new FaunaParser(inputStream); List> expectedTokens = List.of( - Map.entry(FaunaTokenType.DATE, LocalDate.of(2024, 01, 23)) + Map.entry(FaunaTokenType.DATE, LocalDate.of(2024, 1, 23)) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); + } + @Test + public void testGetValueAsLocalDateFail() throws IOException { String invalidJson = "{\"@date\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - expectedTokens = List.of( + List> expectedTokens = List.of( Map.entry(FaunaTokenType.DATE, "abc") ); - assertReader(invalidReader, expectedTokens, true); + Exception ex = assertThrows(SerializationException.class, + () -> assertReader(invalidReader, expectedTokens)); + + assertEquals("Error getting the current token as LocalDate", ex.getMessage()); } @Test - public void testeGetValueAsTime() throws IOException { + public void testGetValueAsTime() throws IOException { String s = "{\"@time\":\"2024-01-23T13:33:10.300Z\"}"; InputStream inputStream = new ByteArrayInputStream(s.getBytes()); FaunaParser reader = new FaunaParser(inputStream); @@ -124,17 +139,23 @@ public void testeGetValueAsTime() throws IOException { Map.entry(FaunaTokenType.TIME, instant) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); + } + @Test + public void testGetValueAsTimeFail() throws IOException { String invalidJson = "{\"@time\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - expectedTokens = List.of( + List> expectedTokens = List.of( Map.entry(FaunaTokenType.TIME, "abc") ); - assertReader(invalidReader, expectedTokens, true); + Exception ex = assertThrows(SerializationException.class, + () -> assertReader(invalidReader, expectedTokens)); + + assertEquals("Error getting the current token as LocalDateTime", ex.getMessage()); } @Test @@ -149,7 +170,7 @@ public void testeGetValueAsTimeNonUTC() throws IOException { Map.entry(FaunaTokenType.TIME, instant) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); } @@ -163,22 +184,27 @@ public void testGetValueAsDouble() throws IOException { Map.entry(FaunaTokenType.DOUBLE, 1.23D) ); - assertReader(reader, expectedTokens, false); + assertReader(reader, expectedTokens); + } + @Test + public void testGetValueAsDoubleFail() throws IOException { String invalidJson = "{\"@double\": \"abc\"}"; InputStream invalidInputStream = new ByteArrayInputStream(invalidJson.getBytes()); FaunaParser invalidReader = new FaunaParser(invalidInputStream); - expectedTokens = List.of( + List> expectedTokens = List.of( Map.entry(FaunaTokenType.DOUBLE, "abc") ); - assertReader(invalidReader, expectedTokens, true); + Exception ex = assertThrows(SerializationException.class, + () -> assertReader(invalidReader, expectedTokens)); + + assertEquals("Error getting the current token as Double", ex.getMessage()); } private static void assertReader(FaunaParser reader, - List> tokens, - boolean assertExceptions) throws IOException { + List> tokens) throws IOException { for (Map.Entry entry : tokens) { reader.read(); assertNotNull(entry.getKey()); @@ -188,47 +214,23 @@ private static void assertReader(FaunaParser reader, switch (entry.getKey()) { case FIELD_NAME: case STRING: - if (assertExceptions) { - assertThrows(SerializationException.class, reader::getValueAsString); - } else { - assertEquals(entry.getValue(), reader.getValueAsString()); - } + assertEquals(entry.getValue(), reader.getValueAsString()); break; case INT: - if (assertExceptions) { - assertThrows(SerializationException.class, reader::getValueAsInt); - } else { - assertEquals(entry.getValue(), reader.getValueAsInt()); - } + assertEquals(entry.getValue(), reader.getValueAsInt()); break; case TRUE: case FALSE: - if (assertExceptions) { - assertThrows(SerializationException.class, reader::getValueAsBoolean); - } else { - assertEquals(entry.getValue(), reader.getValueAsBoolean()); - } + assertEquals(entry.getValue(), reader.getValueAsBoolean()); break; case DATE: - if (assertExceptions) { - assertThrows(SerializationException.class, reader::getValueAsLocalDate); - } else { - assertEquals(entry.getValue(), reader.getValueAsLocalDate()); - } + assertEquals(entry.getValue(), reader.getValueAsLocalDate()); break; case TIME: - if (assertExceptions) { - assertThrows(SerializationException.class, reader::getValueAsTime); - } else { - assertEquals(entry.getValue(), reader.getValueAsTime()); - } + assertEquals(entry.getValue(), reader.getValueAsTime()); break; case DOUBLE: - if (assertExceptions) { - assertThrows(SerializationException.class, reader::getValueAsDouble); - } else { - assertEquals(entry.getValue(), reader.getValueAsDouble()); - } + assertEquals(entry.getValue(), reader.getValueAsDouble()); break; default: assertNull(entry.getValue() == null);