Skip to content

Commit

Permalink
Changing ReplicationPluginInterface to static object
Browse files Browse the repository at this point in the history
Signed-off-by: aggarwalShivani <shivani.aggarwal@nokia.com>
  • Loading branch information
aggarwalShivani committed Mar 3, 2025
1 parent 833d9af commit 0b3c563
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
package org.opensearch.commons.replication

import org.opensearch.action.support.clustermanager.AcknowledgedResponse
import org.opensearch.transport.client.Client
import org.opensearch.transport.client.node.NodeClient
import org.opensearch.commons.replication.action.ReplicationActions.INTERNAL_STOP_REPLICATION_ACTION_TYPE
import org.opensearch.commons.replication.action.StopIndexReplicationRequest
import org.opensearch.commons.utils.recreateObject
import org.opensearch.core.action.ActionListener
import org.opensearch.core.action.ActionResponse
import org.opensearch.core.common.io.stream.Writeable
import org.opensearch.transport.client.Client
import org.opensearch.transport.client.node.NodeClient

/**
* Transport action plugin interfaces for the cross-cluster-replication plugin.
*/
open class ReplicationPluginInterface {
object ReplicationPluginInterface {

/**
* Stop replication.
Expand All @@ -26,7 +26,7 @@ open class ReplicationPluginInterface {
* @param listener The listener for getting response
*/

open fun stopReplication(
fun stopReplication(
client: Client,
request: StopIndexReplicationRequest,
listener: ActionListener<AcknowledgedResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import org.mockito.Mockito.mock
import org.mockito.Mockito.verify
import org.mockito.junit.jupiter.MockitoExtension
import org.opensearch.action.support.clustermanager.AcknowledgedResponse
import org.opensearch.transport.client.node.NodeClient
import org.opensearch.commons.replication.action.StopIndexReplicationRequest
import org.opensearch.core.action.ActionListener
import org.opensearch.core.action.ActionResponse
import org.opensearch.transport.client.node.NodeClient

@ExtendWith(MockitoExtension::class)
internal class ReplicationPluginInterfaceTests {
Expand All @@ -36,9 +36,8 @@ internal class ReplicationPluginInterfaceTests {
actionListener.onResponse(acknowledgedResponse) // Simulate success
}

val replicationPluginInterface = ReplicationPluginInterface()
// Call method under test
replicationPluginInterface.stopReplication(client, request, listener)
ReplicationPluginInterface.stopReplication(client, request, listener)
// Verify that listener.onResponse is called with the correct response
verify(listener).onResponse(acknowledgedResponse)
}
Expand All @@ -58,9 +57,8 @@ internal class ReplicationPluginInterfaceTests {
actionListener.onFailure(exception) // Simulate failure
}

val replicationPluginInterface = ReplicationPluginInterface()
// Call method under test
replicationPluginInterface.stopReplication(client, request, listener)
ReplicationPluginInterface.stopReplication(client, request, listener)
// Verify that listener.onResponse is called with the correct response
verify(listener).onFailure(exception)
}
Expand Down

0 comments on commit 0b3c563

Please sign in to comment.