Skip to content

Commit

Permalink
chore: spotless apply and cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: georgi-l95 <[email protected]>
  • Loading branch information
georgi-l95 committed Oct 24, 2024
1 parent 55be112 commit 889c464
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ public PublishStreamGrpcClientImpl(
@NonNull GrpcConfig grpcConfig, @NonNull BlockStreamConfig blockStreamConfig) {
this.grpcConfig = grpcConfig;
this.blockStreamConfig = blockStreamConfig;

}

/**
* Initialize the channel and stub for publishBlockStream with the desired configuration.
*/
@Override
public void init() {
channel =
channel =
ManagedChannelBuilder.forAddress(grpcConfig.serverAddress(), grpcConfig.port())
.usePlaintext()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
* and provides the behavior for a mode where only consumption of block data
* occurs.
*
* <p>This mode handles dual operations in the block streaming process, utilizing the
* <p>This mode handles single operation in the block streaming process, utilizing the
* {@link BlockStreamConfig} for configuration settings. It is designed for scenarios where
* the simulator needs to handle both the consumption and publication of blocks in parallel.
* the simulator needs to handle the consumption of blocks.
*
* <p>For now, the actual start behavior is not implemented, as indicated by the
* {@link UnsupportedOperationException}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import java.io.IOException;

/**
* The {@code PublisherModeHandler} class implements the {@link SimulatorModeHandler} interface
* and provides the behavior for a mode where only publishing of block data
* occurs.
*
* <p>This mode handles single operation in the block streaming process, utilizing the
* {@link BlockStreamConfig} for configuration settings. It is designed for scenarios where
* the simulator needs to handle publication of blocks.
*/
public class PublisherModeHandler implements SimulatorModeHandler {
private static final System.Logger LOGGER =
System.getLogger(PublisherModeHandler.class.getName());
Expand All @@ -38,6 +47,11 @@ public class PublisherModeHandler implements SimulatorModeHandler {
private final int millisecondsPerBlock;
private final int NANOS_PER_MILLI = 1_000_000;

/**
* Constructs a new {@code PublisherModeHandler} with the specified block stream configuration and publisher client.
*
* @param blockStreamConfig the configuration data for managing block streams
*/
public PublisherModeHandler(
@NonNull final BlockStreamConfig blockStreamConfig,
@NonNull PublishStreamGrpcClient publishStreamGrpcClient) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.simulator.mode;

import static org.junit.jupiter.api.Assertions.*;
Expand All @@ -9,23 +25,19 @@
import com.hedera.block.simulator.grpc.PublishStreamGrpcClient;
import com.hedera.hapi.block.stream.Block;
import com.hedera.hapi.block.stream.BlockItem;
import java.io.IOException;
import java.util.Arrays;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.*;

import java.io.IOException;
import java.util.Arrays;

public class PublisherModeHandlerTest {

@Mock
private BlockStreamConfig blockStreamConfig;
@Mock private BlockStreamConfig blockStreamConfig;

@Mock
private PublishStreamGrpcClient publishStreamGrpcClient;
@Mock private PublishStreamGrpcClient publishStreamGrpcClient;

@Mock
private BlockStreamManager blockStreamManager;
@Mock private BlockStreamManager blockStreamManager;

private PublisherModeHandler publisherModeHandler;

Expand Down Expand Up @@ -123,8 +135,7 @@ void testStartWithExceptionDuringStreaming() throws Exception {

publisherModeHandler = new PublisherModeHandler(blockStreamConfig, publishStreamGrpcClient);

when(blockStreamManager.getNextBlock())
.thenThrow(new IOException("Test exception"));
when(blockStreamManager.getNextBlock()).thenThrow(new IOException("Test exception"));

assertThrows(IOException.class, () -> publisherModeHandler.start(blockStreamManager));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected static GenericContainer<?> getContainer() {
portBindings.add(String.format("%d:%2d", blockNodePort, blockNodePort));
blockNodeContainer =
new GenericContainer<>(
DockerImageName.parse("block-node-server:" + blockNodeVersion))
DockerImageName.parse("block-node-server:" + blockNodeVersion))
.withExposedPorts(blockNodePort)
.withEnv("VERSION", blockNodeVersion)
.waitingFor(Wait.forListeningPort())
Expand Down

0 comments on commit 889c464

Please sign in to comment.