diff --git a/server/src/main/java/com/hedera/block/server/mediator/MediatorInjectionModule.java b/server/src/main/java/com/hedera/block/server/mediator/MediatorInjectionModule.java index 24240647..7a8c2290 100644 --- a/server/src/main/java/com/hedera/block/server/mediator/MediatorInjectionModule.java +++ b/server/src/main/java/com/hedera/block/server/mediator/MediatorInjectionModule.java @@ -20,6 +20,7 @@ import com.hedera.block.server.notifier.Notifiable; import com.hedera.block.server.service.ServiceStatus; import com.hedera.hapi.block.SubscribeStreamResponse; +import dagger.Binds; import dagger.Module; import dagger.Provides; import edu.umd.cs.findbugs.annotations.NonNull; @@ -44,32 +45,23 @@ static LiveStreamMediator providesLiveStreamMediator( } /** - * Provides the subscription handler. + * Binds the subscription handler to the live stream mediator. * - * @param blockNodeContext the block node context - * @param serviceStatus the service status + * @param liveStreamMediator the live stream mediator * @return the subscription handler */ - @Provides + @Binds @Singleton - static SubscriptionHandler provideSubscriptionHandler( - @NonNull final BlockNodeContext blockNodeContext, - @NonNull final ServiceStatus serviceStatus) { - return LiveStreamMediatorBuilder.newBuilder(blockNodeContext, serviceStatus).build(); - } + SubscriptionHandler bindSubscriptionHandler( + @NonNull final LiveStreamMediator liveStreamMediator); /** - * Provides the mediator as a Notifiable instance. + * Binds the mediator to the notifiable interface. * - * @param blockNodeContext the block node context - * @param serviceStatus the service status - * @return the mediator as a Notifiable instance + * @param liveStreamMediator the live stream mediator + * @return the notifiable interface */ - @Provides + @Binds @Singleton - static Notifiable provideMediator( - @NonNull final BlockNodeContext blockNodeContext, - @NonNull final ServiceStatus serviceStatus) { - return LiveStreamMediatorBuilder.newBuilder(blockNodeContext, serviceStatus).build(); - } + Notifiable bindMediator(@NonNull final LiveStreamMediator liveStreamMediator); } diff --git a/server/src/test/java/com/hedera/block/server/mediator/MediatorInjectionModuleTest.java b/server/src/test/java/com/hedera/block/server/mediator/MediatorInjectionModuleTest.java index c7f81c4e..5ba33db4 100644 --- a/server/src/test/java/com/hedera/block/server/mediator/MediatorInjectionModuleTest.java +++ b/server/src/test/java/com/hedera/block/server/mediator/MediatorInjectionModuleTest.java @@ -19,7 +19,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import com.hedera.block.server.config.BlockNodeContext; -import com.hedera.block.server.notifier.Notifiable; import com.hedera.block.server.service.ServiceStatus; import com.hedera.block.server.util.TestConfigUtil; import com.hedera.hapi.block.SubscribeStreamResponse; @@ -53,30 +52,4 @@ void testProvidesStreamMediator() throws IOException { // Verify that the streamMediator is correctly instantiated assertNotNull(streamMediator); } - - @Test - void testProvidesSubscriptionHandler() throws IOException { - - BlockNodeContext blockNodeContext = TestConfigUtil.getTestBlockNodeContext(); - - // Call the method under test - SubscriptionHandler subscriptionHandler = - MediatorInjectionModule.provideSubscriptionHandler(blockNodeContext, serviceStatus); - - // Verify that the subscriptionHandler is correctly instantiated - assertNotNull(subscriptionHandler); - } - - @Test - void testProvidesMediator() throws IOException { - - BlockNodeContext blockNodeContext = TestConfigUtil.getTestBlockNodeContext(); - - // Call the method under test - Notifiable mediator = - MediatorInjectionModule.provideMediator(blockNodeContext, serviceStatus); - - // Verify that the mediator is correctly instantiated - assertNotNull(mediator); - } }