-
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.
Signed-off-by: Alfredo Gutierrez <[email protected]>
- Loading branch information
1 parent
e4a2bbc
commit 835bc88
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
server/src/test/java/com/hedera/block/server/config/BlockNodeContextFactoryTest.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,17 @@ | ||
package com.hedera.block.server.config; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class BlockNodeContextFactoryTest { | ||
|
||
@Test | ||
void create_returnsBlockNodeContext() { | ||
BlockNodeContext context = BlockNodeContextFactory.create(); | ||
|
||
assertNotNull(context.metrics()); | ||
assertNotNull(context.configuration()); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
server/src/test/java/com/hedera/block/server/config/BlockNodeContextTest.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,21 @@ | ||
package com.hedera.block.server.config; | ||
|
||
import com.swirlds.config.api.Configuration; | ||
import com.swirlds.metrics.api.Metrics; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
class BlockNodeContextTest { | ||
|
||
@Test | ||
void BlockNodeContext_initializesWithMetricsAndConfiguration() { | ||
Metrics metrics = mock(Metrics.class); | ||
Configuration configuration = mock(Configuration.class); | ||
|
||
BlockNodeContext context = new BlockNodeContext(metrics, configuration); | ||
|
||
assertEquals(metrics, context.metrics()); | ||
assertEquals(configuration, context.configuration()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
server/src/test/java/com/hedera/block/server/metrics/MetricsServiceTest.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,38 @@ | ||
package com.hedera.block.server.metrics; | ||
|
||
import com.swirlds.metrics.api.Counter; | ||
import com.swirlds.metrics.api.LongGauge; | ||
import com.swirlds.metrics.api.Metrics; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
class MetricsServiceTest { | ||
|
||
@Test | ||
void MetricsService_initializesExampleGauge() { | ||
Metrics metrics = mock(Metrics.class); | ||
LongGauge exampleGauge = mock(LongGauge.class); | ||
when(metrics.getOrCreate(any(LongGauge.Config.class))).thenReturn(exampleGauge); | ||
|
||
MetricsService service = new MetricsService(metrics); | ||
|
||
assertEquals(exampleGauge, service.exampleGauge); | ||
} | ||
|
||
@Test | ||
void MetricsService_initializesExampleCounter() { | ||
Metrics metrics = mock(Metrics.class); | ||
Counter exampleCounter = mock(Counter.class); | ||
when(metrics.getOrCreate(any(Counter.Config.class))).thenReturn(exampleCounter); | ||
|
||
MetricsService service = new MetricsService(metrics); | ||
|
||
assertEquals(exampleCounter, service.exampleCounter); | ||
} | ||
|
||
@Test | ||
void MetricsService_handlesNullMetrics() { | ||
assertThrows(NullPointerException.class, () -> new MetricsService(null)); | ||
} | ||
} |