Skip to content

Commit

Permalink
Added Test case for ConfigInjectionModule to retrieve the newly confi…
Browse files Browse the repository at this point in the history
…g object.

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Nov 27, 2024
1 parent 25ff10d commit 01128d4
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.junit.jupiter.api.Assertions.*;

import com.hedera.block.server.ServerConfig;
import com.hedera.block.server.consumer.ConsumerConfig;
import com.hedera.block.server.mediator.MediatorConfig;
import com.hedera.block.server.notifier.NotifierConfig;
Expand All @@ -36,12 +37,10 @@ void testProvidePersistenceStorageConfig() throws IOException {

BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext();
Configuration configuration = context.configuration();
PersistenceStorageConfig persistenceStorageConfig =
configuration.getConfigData(PersistenceStorageConfig.class);
PersistenceStorageConfig persistenceStorageConfig = configuration.getConfigData(PersistenceStorageConfig.class);

// Call the method under test
PersistenceStorageConfig providedConfig =
ConfigInjectionModule.providePersistenceStorageConfig(configuration);
PersistenceStorageConfig providedConfig = ConfigInjectionModule.providePersistenceStorageConfig(configuration);

// Verify that the correct config data is returned
assertNotNull(providedConfig);
Expand Down Expand Up @@ -71,8 +70,7 @@ void testProvidePrometheusConfig() throws IOException {
PrometheusConfig prometheusConfig = configuration.getConfigData(PrometheusConfig.class);

// Call the method under test
PrometheusConfig providedConfig =
ConfigInjectionModule.providePrometheusConfig(configuration);
PrometheusConfig providedConfig = ConfigInjectionModule.providePrometheusConfig(configuration);

// Verify that the correct config data is returned
assertNotNull(providedConfig);
Expand Down Expand Up @@ -119,4 +117,17 @@ void testProvideNotifierConfig() throws IOException {
assertNotNull(providedConfig);
assertSame(notifierConfig, providedConfig);
}

@Test
void testServerConfig() throws IOException {
BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext();
Configuration configuration = context.configuration();
ServerConfig serverConfig = configuration.getConfigData(ServerConfig.class);

ServerConfig providedConfig = ConfigInjectionModule.provideServerConfig(configuration);

// Verify the config
assertNotNull(providedConfig);
assertSame(serverConfig, providedConfig);
}
}

0 comments on commit 01128d4

Please sign in to comment.