Skip to content

Commit

Permalink
Fix test compiling. Still expect failures on exceptions/messages
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed May 10, 2024
1 parent 79b2e1f commit b5d0e2a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ static Connector createConnector(XContentBuilder builder, String connectorProtoc
}
}


@Override
default Custom parse(XContentParser parser) throws IOException {
return createConnector(parser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.opensearch.ml.common.transport.connector.MLConnectorDeleteRequest;
import org.opensearch.ml.helper.ConnectorAccessControlHelper;
import org.opensearch.ml.utils.TestHelper;
import org.opensearch.sdk.SdkClient;
import org.opensearch.search.SearchHit;
import org.opensearch.search.SearchHits;
import org.opensearch.search.aggregations.InternalAggregations;
Expand All @@ -59,6 +60,9 @@ public class DeleteConnectorTransportActionTests extends OpenSearchTestCase {
@Mock
Client client;

@Mock
SdkClient sdkClient;

@Mock
TransportService transportService;

Expand Down Expand Up @@ -93,7 +97,14 @@ public void setup() throws IOException {

Settings settings = Settings.builder().build();
deleteConnectorTransportAction = spy(
new DeleteConnectorTransportAction(transportService, actionFilters, client, xContentRegistry, connectorAccessControlHelper)
new DeleteConnectorTransportAction(
transportService,
actionFilters,
client,
sdkClient,
xContentRegistry,
connectorAccessControlHelper
)
);

doAnswer(invocation -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.ml.common.transport.connector.MLConnectorGetRequest;
import org.opensearch.ml.common.transport.connector.MLConnectorGetResponse;
import org.opensearch.ml.helper.ConnectorAccessControlHelper;
import org.opensearch.sdk.SdkClient;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;
Expand All @@ -47,6 +48,9 @@ public class GetConnectorTransportActionTests extends OpenSearchTestCase {
@Mock
Client client;

@Mock
SdkClient sdkClient;

@Mock
NamedXContentRegistry xContentRegistry;

Expand Down Expand Up @@ -75,7 +79,14 @@ public void setup() throws IOException {
Settings settings = Settings.builder().build();

getConnectorTransportAction = spy(
new GetConnectorTransportAction(transportService, actionFilters, client, xContentRegistry, connectorAccessControlHelper)
new GetConnectorTransportAction(
transportService,
actionFilters,
client,
sdkClient,
xContentRegistry,
connectorAccessControlHelper
)
);

doAnswer(invocation -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.opensearch.ml.engine.indices.MLIndicesHandler;
import org.opensearch.ml.helper.ConnectorAccessControlHelper;
import org.opensearch.ml.model.MLModelManager;
import org.opensearch.sdk.SdkClient;
import org.opensearch.tasks.Task;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.ThreadPool;
Expand All @@ -61,6 +62,8 @@ public class TransportCreateConnectorActionTests extends OpenSearchTestCase {
@Mock
private Client client;
@Mock
private SdkClient sdkClient;
@Mock
private MLEngine mlEngine;
@Mock
private ConnectorAccessControlHelper connectorAccessControlHelper;
Expand Down Expand Up @@ -113,6 +116,7 @@ public void setup() {
actionFilters,
mlIndicesHandler,
client,
sdkClient,
mlEngine,
connectorAccessControlHelper,
settings,
Expand Down Expand Up @@ -316,6 +320,7 @@ public void test_execute_connectorAccessControlEnabled_userNoBackendRoles_except
actionFilters,
mlIndicesHandler,
client,
sdkClient,
mlEngine,
connectorAccessControlHelper,
settings,
Expand Down Expand Up @@ -357,6 +362,7 @@ public void test_execute_connectorAccessControlEnabled_parameterConflict_excepti
actionFilters,
mlIndicesHandler,
client,
sdkClient,
mlEngine,
connectorAccessControlHelper,
settings,
Expand Down Expand Up @@ -401,6 +407,7 @@ public void test_execute_connectorAccessControlEnabled_specifyNotBelongedRole_ex
actionFilters,
mlIndicesHandler,
client,
sdkClient,
mlEngine,
connectorAccessControlHelper,
settings,
Expand Down Expand Up @@ -467,6 +474,7 @@ public void test_execute_URL_notMatchingExpression_exception() {
actionFilters,
mlIndicesHandler,
client,
sdkClient,
mlEngine,
connectorAccessControlHelper,
settings,
Expand Down

0 comments on commit b5d0e2a

Please sign in to comment.