From 1b2690c66371cf71b055feb98bbb8145e2ebca95 Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Sat, 24 Aug 2024 20:55:39 -0600 Subject: [PATCH] Added UT for PersistenceInjectionModule Signed-off-by: Alfredo Gutierrez --- .../PersistenceInjectionModuleTest.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/com/hedera/block/server/persistence/PersistenceInjectionModuleTest.java b/server/src/test/java/com/hedera/block/server/persistence/PersistenceInjectionModuleTest.java index 49596d204..76641b764 100644 --- a/server/src/test/java/com/hedera/block/server/persistence/PersistenceInjectionModuleTest.java +++ b/server/src/test/java/com/hedera/block/server/persistence/PersistenceInjectionModuleTest.java @@ -18,4 +18,50 @@ import static org.junit.jupiter.api.Assertions.*; -class PersistenceInjectionModuleTest {} +import com.hedera.block.server.config.BlockNodeContext; +import com.hedera.block.server.persistence.storage.PersistenceStorageConfig; +import com.hedera.block.server.persistence.storage.read.BlockReader; +import com.hedera.block.server.persistence.storage.write.BlockWriter; +import com.hedera.block.server.util.TestConfigUtil; +import com.hedera.hapi.block.stream.Block; +import com.hedera.hapi.block.stream.BlockItem; +import java.io.IOException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class PersistenceInjectionModuleTest { + + @Mock private BlockNodeContext blockNodeContext; + + @Mock private PersistenceStorageConfig persistenceStorageConfig; + + @BeforeEach + void setup() throws IOException { + // Setup any necessary mocks before each test + blockNodeContext = TestConfigUtil.getTestBlockNodeContext(); + persistenceStorageConfig = + blockNodeContext.configuration().getConfigData(PersistenceStorageConfig.class); + } + + @Test + void testProvidesBlockWriter() { + + BlockWriter blockWriter = + PersistenceInjectionModule.providesBlockWriter(blockNodeContext); + + assertNotNull(blockWriter); + } + + @Test + void testProvidesBlockReader() { + + BlockReader blockReader = + PersistenceInjectionModule.providesBlockReader(persistenceStorageConfig); + + assertNotNull(blockReader); + } +}