-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UT for missing InjectionModules, removed unneeded configuration…
… definition from ConfigExtensions Signed-off-by: Alfredo Gutierrez <[email protected]>
- Loading branch information
1 parent
1b2690c
commit 689b6fc
Showing
5 changed files
with
202 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
server/src/test/java/com/hedera/block/server/config/ConfigInjectionModuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.server.config; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.hedera.block.server.consumer.ConsumerConfig; | ||
import com.hedera.block.server.persistence.storage.PersistenceStorageConfig; | ||
import com.hedera.block.server.util.TestConfigUtil; | ||
import com.swirlds.common.metrics.config.MetricsConfig; | ||
import com.swirlds.common.metrics.platform.prometheus.PrometheusConfig; | ||
import com.swirlds.config.api.Configuration; | ||
import java.io.IOException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ConfigInjectionModuleTest { | ||
|
||
@Test | ||
void testProvidePersistenceStorageConfig() throws IOException { | ||
|
||
BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext(); | ||
Configuration configuration = context.configuration(); | ||
PersistenceStorageConfig persistenceStorageConfig = | ||
configuration.getConfigData(PersistenceStorageConfig.class); | ||
|
||
// Call the method under test | ||
PersistenceStorageConfig providedConfig = | ||
ConfigInjectionModule.providePersistenceStorageConfig(configuration); | ||
|
||
// Verify that the correct config data is returned | ||
assertNotNull(providedConfig); | ||
assertSame(persistenceStorageConfig, providedConfig); | ||
} | ||
|
||
@Test | ||
void testProvideMetricsConfig() throws IOException { | ||
|
||
BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext(); | ||
Configuration configuration = context.configuration(); | ||
MetricsConfig metricsConfig = configuration.getConfigData(MetricsConfig.class); | ||
|
||
// Call the method under test | ||
MetricsConfig providedConfig = ConfigInjectionModule.provideMetricsConfig(configuration); | ||
|
||
// Verify that the correct config data is returned | ||
assertNotNull(providedConfig); | ||
assertSame(metricsConfig, providedConfig); | ||
} | ||
|
||
@Test | ||
void testProvidePrometheusConfig() throws IOException { | ||
|
||
BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext(); | ||
Configuration configuration = context.configuration(); | ||
PrometheusConfig prometheusConfig = configuration.getConfigData(PrometheusConfig.class); | ||
|
||
// Call the method under test | ||
PrometheusConfig providedConfig = | ||
ConfigInjectionModule.providePrometheusConfig(configuration); | ||
|
||
// Verify that the correct config data is returned | ||
assertNotNull(providedConfig); | ||
assertSame(prometheusConfig, providedConfig); | ||
} | ||
|
||
@Test | ||
void testProvideConsumerConfig() throws IOException { | ||
|
||
BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext(); | ||
Configuration configuration = context.configuration(); | ||
ConsumerConfig consumerConfig = configuration.getConfigData(ConsumerConfig.class); | ||
|
||
// Call the method under test | ||
ConsumerConfig providedConfig = ConfigInjectionModule.provideConsumerConfig(configuration); | ||
|
||
// Verify that the correct config data is returned | ||
assertNotNull(providedConfig); | ||
assertSame(consumerConfig, providedConfig); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
server/src/test/java/com/hedera/block/server/metrics/MetricsInjectionModuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2024 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.block.server.metrics; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.hedera.block.server.config.BlockNodeContext; | ||
import com.hedera.block.server.util.TestConfigUtil; | ||
import com.swirlds.config.api.Configuration; | ||
import com.swirlds.metrics.api.Metrics; | ||
import java.io.IOException; | ||
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 MetricsInjectionModuleTest { | ||
|
||
@Mock private Metrics metrics; | ||
|
||
@Test | ||
void testProvideMetricsService() { | ||
// Call the method under test | ||
MetricsService metricsService = MetricsInjectionModule.provideMetricsService(metrics); | ||
|
||
// Verify that the metricsService is correctly instantiated | ||
assertNotNull(metricsService); | ||
} | ||
|
||
@Test | ||
void testProvideMetrics() throws IOException { | ||
BlockNodeContext context = TestConfigUtil.getTestBlockNodeContext(); | ||
Configuration configuration = context.configuration(); | ||
|
||
// Call the method under test | ||
Metrics providedMetrics = MetricsInjectionModule.provideMetrics(configuration); | ||
|
||
assertNotNull(providedMetrics); | ||
} | ||
} |