Skip to content

Commit

Permalink
Moved PersistenceInjectionModule to persistance package instead of pe…
Browse files Browse the repository at this point in the history
…rsistence.storage

Added export metricsService to the module-info

Refactored Dagger Component to receive a Configuration from outside.

Added UT for MediatorInjectionModule

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Aug 25, 2024
1 parent 30cda24 commit 99aa01f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.hedera.block.server.health.HealthInjectionModule;
import com.hedera.block.server.mediator.MediatorInjectionModule;
import com.hedera.block.server.metrics.MetricsInjectionModule;
import com.hedera.block.server.persistence.storage.PersistenceInjectionModule;
import com.hedera.block.server.persistence.PersistenceInjectionModule;
import com.swirlds.config.api.Configuration;
import dagger.BindsInstance;
import dagger.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

package com.hedera.block.server.persistence.storage;
package com.hedera.block.server.persistence;

import com.hedera.block.server.config.BlockNodeContext;
import com.hedera.block.server.persistence.storage.PersistenceStorageConfig;
import com.hedera.block.server.persistence.storage.read.BlockAsDirReaderBuilder;
import com.hedera.block.server.persistence.storage.read.BlockReader;
import com.hedera.block.server.persistence.storage.write.BlockAsDirWriterBuilder;
Expand Down
1 change: 1 addition & 0 deletions server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
exports com.hedera.block.server.metrics;
exports com.hedera.block.server.data;
exports com.hedera.block.server.health;
exports com.hedera.block.server.persistence;

requires com.hedera.block.stream;
requires com.google.protobuf;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.mediator;

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

import com.hedera.block.server.ServiceStatus;
import com.hedera.block.server.config.BlockNodeContext;
import com.hedera.block.server.data.ObjectEvent;
import com.hedera.block.server.persistence.storage.write.BlockWriter;
import com.hedera.hapi.block.SubscribeStreamResponse;
import com.hedera.hapi.block.stream.BlockItem;
import org.junit.jupiter.api.BeforeEach;
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 MediatorInjectionModuleTest {

@Mock private BlockWriter<BlockItem> blockWriter;

@Mock private BlockNodeContext blockNodeContext;

@Mock private ServiceStatus serviceStatus;

@BeforeEach
void setup() {
// Any setup before each test can be done here
}

@Test
void testProvidesStreamMediator() {
// Call the method under test
StreamMediator<BlockItem, ObjectEvent<SubscribeStreamResponse>> streamMediator =
MediatorInjectionModule.providesStreamMediator(
blockWriter, blockNodeContext, serviceStatus);

// Verify that the streamMediator is correctly instantiated
assertNotNull(streamMediator);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.persistence;

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

class PersistenceInjectionModuleTest {}

0 comments on commit 99aa01f

Please sign in to comment.