From cd2d4affc2a397877eafaca69197cdb49ece4abc Mon Sep 17 00:00:00 2001 From: Atanas Atanasov Date: Wed, 11 Dec 2024 13:36:12 +0200 Subject: [PATCH] additional test for empty optional Signed-off-by: Atanas Atanasov --- .../storage/read/BlockAsLocalFileReaderTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsLocalFileReaderTest.java b/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsLocalFileReaderTest.java index 5f7187ee..519900cc 100644 --- a/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsLocalFileReaderTest.java +++ b/server/src/test/java/com/hedera/block/server/persistence/storage/read/BlockAsLocalFileReaderTest.java @@ -140,6 +140,21 @@ void testSuccessfulBlockReadContents(final long blockNumber) throws IOException, .containsExactlyElementsOf(blockItemUnparsed); } + /** + * This test aims to verify that the + * {@link BlockAsLocalFileReader#read(long) correctly returns an empty + * {@link Optional} when no block file is found for the given valid block + * number. + */ + @ParameterizedTest + @MethodSource("validBlockNumbers") + void testEmptyOptWhenNoBLockFileFound(final long blockNumber) throws IOException, ParseException { + final Optional actual = toTest.read(blockNumber); + assertThat(actual) + .isNotNull() + .isEmpty(); + } + /** * This test aims to verify that the * {@link BlockAsLocalFileReader#read(long)} correctly throws an