From e945fb10558cff1285b5ae5b2c09fdc8646588a4 Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Sat, 24 Aug 2024 15:34:13 -0600 Subject: [PATCH] Improving test and including missing java docs Signed-off-by: Alfredo Gutierrez --- .../com/hedera/block/server/BlockNodeApp.java | 8 ++-- .../server/BlockNodeAppInjectionModule.java | 14 ++++++ .../server/config/ConfigInjectionModule.java | 43 ++++++++++++++++++- .../storage/PersistenceInjectionModule.java | 6 +++ .../hedera/block/server/BlockNodeAppTest.java | 2 - 5 files changed, 67 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/com/hedera/block/server/BlockNodeApp.java b/server/src/main/java/com/hedera/block/server/BlockNodeApp.java index 5b0b8a9fe..8bbcad0aa 100644 --- a/server/src/main/java/com/hedera/block/server/BlockNodeApp.java +++ b/server/src/main/java/com/hedera/block/server/BlockNodeApp.java @@ -44,10 +44,12 @@ public class BlockNodeApp { private final WebServerConfig.Builder webServerBuilder; /** - * Has all needed dependencies to start the server and initialize the context. + * Constructs a new BlockNodeApp with the specified dependencies. * - * @param serviceStatus the status of the service - * @param healthService the health service + * @param serviceStatus has the status of the service + * @param healthService handles the health API requests + * @param blockStreamService handles the GRPC API requests + * @param webServerBuilder used to build the web server and start it */ @Inject public BlockNodeApp( diff --git a/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java b/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java index b50e16b96..a0049ce37 100644 --- a/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/BlockNodeAppInjectionModule.java @@ -64,6 +64,15 @@ static BlockNodeContext provideBlockNodeContext() { } } + /** + * Provides a block stream service singleton using DI. + * + * @param streamMediator should come from DI + * @param blockReader should come from DI + * @param serviceStatus should come from DI + * @param blockNodeContext should come from DI + * @return a block stream service singleton + */ @Singleton @Provides static BlockStreamService provideBlockStreamService( @@ -76,6 +85,11 @@ static BlockStreamService provideBlockStreamService( return new BlockStreamService(streamMediator, blockReader, serviceStatus, blockNodeContext); } + /** + * Provides a web server config builder singleton using DI. + * + * @return a web server config builder singleton + */ @Singleton @Provides static WebServerConfig.Builder provideWebServerConfigBuilder() { diff --git a/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java b/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java index 6c1016bce..4b60e0434 100644 --- a/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/config/ConfigInjectionModule.java @@ -33,11 +33,22 @@ import java.nio.file.Path; import javax.inject.Singleton; +/** + * A Dagger module for providing configuration dependencies, any specific configuration should be + * part of this module. + */ @Module public interface ConfigInjectionModule { - static final String APPLICATION_PROPERTIES = "app.properties"; + /** The application properties file name within the resources package. */ + String APPLICATION_PROPERTIES = "app.properties"; + /** + * Provides a configuration singleton using the configuration builder. Injected by the DI + * Framework. + * + * @return a configuration singleton + */ @Singleton @Provides static Configuration provideConfiguration() { @@ -53,6 +64,12 @@ static Configuration provideConfiguration() { } } + /** + * Provides a persistence storage configuration singleton using the configuration. + * + * @param configuration is the configuration singleton + * @return a persistence storage configuration singleton + */ @Singleton @Provides static PersistenceStorageConfig providePersistenceStorageConfig( @@ -60,24 +77,48 @@ static PersistenceStorageConfig providePersistenceStorageConfig( return configuration.getConfigData(PersistenceStorageConfig.class); } + /** + * Provides a metrics configuration singleton using the configuration. + * + * @param configuration is the configuration singleton + * @return a metrics configuration singleton + */ @Singleton @Provides static MetricsConfig provideMetricsConfig(@NonNull Configuration configuration) { return configuration.getConfigData(MetricsConfig.class); } + /** + * Provides a Prometheus configuration singleton using the configuration. + * + * @param configuration is the configuration singleton + * @return a Prometheus configuration singleton + */ @Singleton @Provides static PrometheusConfig providePrometheusConfig(@NonNull Configuration configuration) { return configuration.getConfigData(PrometheusConfig.class); } + /** + * Provides a consumer configuration singleton using the configuration. + * + * @param configuration is the configuration singleton + * @return a consumer configuration singleton + */ @Singleton @Provides static ConsumerConfig provideConsumerConfig(@NonNull Configuration configuration) { return configuration.getConfigData(ConsumerConfig.class); } + /** + * Provides a basic common configuration singleton using the configuration. + * + * @param configuration is the configuration singleton + * @return a basic common configuration singleton + */ @Singleton @Provides static BasicCommonConfig provideBasicCommonConfig(@NonNull Configuration configuration) { diff --git a/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceInjectionModule.java b/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceInjectionModule.java index 4669f93bf..eabe3285b 100644 --- a/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/persistence/storage/PersistenceInjectionModule.java @@ -49,6 +49,12 @@ static BlockWriter providesBlockWriter(@NonNull BlockNodeContext bloc } } + /** + * Provides a block reader singleton using the persistence storage config. + * + * @param config the persistence storage configuration needed to build the block reader + * @return a block reader singleton + */ @Provides @Singleton static BlockReader providesBlockReader(@NonNull PersistenceStorageConfig config) { diff --git a/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java b/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java index 92f7f480f..f989f4c44 100644 --- a/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java +++ b/server/src/test/java/com/hedera/block/server/BlockNodeAppTest.java @@ -40,8 +40,6 @@ class BlockNodeAppTest { @Mock private HealthService healthService; - @Mock private BlockStreamService blockStreamService; - @Mock private WebServerConfig.Builder webServerBuilder; @Mock private WebServer webServer;