Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up various compile warnings #95

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
public class CommonValue {

private CommonValue() {}

/** Default value for no schema version */
public static Integer NO_SCHEMA_VERSION = 0;
/** Index mapping meta field name*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
public class TemplateUtil {

private TemplateUtil() {}

/**
* Converts a JSON string into an XContentParser
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.opensearch.client.AdminClient;
import org.opensearch.client.Client;
import org.opensearch.client.ClusterAdminClient;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.settings.Settings;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.threadpool.TestThreadPool;
Expand All @@ -26,7 +25,6 @@
public class FlowFrameworkPluginTests extends OpenSearchTestCase {

private Client client;
private NodeClient nodeClient;

private AdminClient adminClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void testStoreResponseToGlobalContext() {

public void testUpdateTemplateInGlobalContext() throws IOException {
Template template = mock(Template.class);
ActionListener<IndexResponse> listener = mock(ActionListener.class);
when(template.toDocumentSource(any(XContentBuilder.class), eq(ToXContent.EMPTY_PARAMS))).thenAnswer(invocation -> {
XContentBuilder builder = invocation.getArgument(0);
return builder;
Expand All @@ -129,6 +128,7 @@ public void testUpdateTemplateInGlobalContext() throws IOException {

public void testFailedUpdateTemplateInGlobalContext() throws IOException {
Template template = mock(Template.class);
@SuppressWarnings("unchecked")
ActionListener<IndexResponse> listener = mock(ActionListener.class);
when(createIndexStep.doesIndexExist(any())).thenReturn(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void setUp() throws Exception {

public void testCreateNewWorkflow() {

@SuppressWarnings("unchecked")
ActionListener<WorkflowResponse> listener = mock(ActionListener.class);
WorkflowRequest createNewWorkflow = new WorkflowRequest(null, template);

Expand All @@ -94,6 +95,7 @@ public void testCreateNewWorkflow() {
}

public void testFailedToCreateNewWorkflow() {
@SuppressWarnings("unchecked")
ActionListener<WorkflowResponse> listener = mock(ActionListener.class);
WorkflowRequest createNewWorkflow = new WorkflowRequest(null, template);

Expand All @@ -111,6 +113,7 @@ public void testFailedToCreateNewWorkflow() {

public void testUpdateWorkflow() {

@SuppressWarnings("unchecked")
ActionListener<WorkflowResponse> listener = mock(ActionListener.class);
WorkflowRequest updateWorkflow = new WorkflowRequest("1", template);

Expand All @@ -128,6 +131,7 @@ public void testUpdateWorkflow() {
}

public void testFailedToUpdateWorkflow() {
@SuppressWarnings("unchecked")
ActionListener<WorkflowResponse> listener = mock(ActionListener.class);
WorkflowRequest updateWorkflow = new WorkflowRequest("1", template);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void setUp() throws Exception {
public void testProvisionWorkflow() {

String workflowId = "1";
@SuppressWarnings("unchecked")
ActionListener<WorkflowResponse> listener = mock(ActionListener.class);
WorkflowRequest workflowRequest = new WorkflowRequest(workflowId, null);

Expand All @@ -121,6 +122,7 @@ public void testProvisionWorkflow() {
}

public void testFailedToRetrieveTemplateFromGlobalContext() {
@SuppressWarnings("unchecked")
ActionListener<WorkflowResponse> listener = mock(ActionListener.class);
WorkflowRequest request = new WorkflowRequest("1", null);
doAnswer(invocation -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.opensearch.action.admin.indices.create.CreateIndexRequest;
import org.opensearch.action.admin.indices.create.CreateIndexResponse;
import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.opensearch.action.support.master.AcknowledgedResponse;
import org.opensearch.client.AdminClient;
import org.opensearch.client.Client;
import org.opensearch.client.IndicesAdminClient;
Expand Down Expand Up @@ -46,6 +47,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@SuppressWarnings("deprecation")
public class CreateIndexStepTests extends OpenSearchTestCase {

private static final String META = "_meta";
Expand Down Expand Up @@ -92,7 +94,7 @@ public void setUp() throws Exception {
}

public void testCreateIndexStep() throws ExecutionException, InterruptedException {
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings({ "unchecked" })
ArgumentCaptor<ActionListener<CreateIndexResponse>> actionListenerCaptor = ArgumentCaptor.forClass(ActionListener.class);
CompletableFuture<WorkflowData> future = createIndexStep.execute(List.of(inputData));
assertFalse(future.isDone());
Expand All @@ -107,7 +109,7 @@ public void testCreateIndexStep() throws ExecutionException, InterruptedExceptio
}

public void testCreateIndexStepFailure() throws ExecutionException, InterruptedException {
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings({ "unchecked" })
ArgumentCaptor<ActionListener<CreateIndexResponse>> actionListenerCaptor = ArgumentCaptor.forClass(ActionListener.class);
CompletableFuture<WorkflowData> future = createIndexStep.execute(List.of(inputData));
assertFalse(future.isDone());
Expand Down Expand Up @@ -144,6 +146,7 @@ public void testInitIndexIfAbsent_IndexExist() {
ActionListener<Boolean> listener = mock(ActionListener.class);

IndexMetadata mockIndexMetadata = mock(IndexMetadata.class);
@SuppressWarnings("unchecked")
Map<String, IndexMetadata> mockIndices = mock(Map.class);
when(clusterService.state()).thenReturn(mockClusterState);
when(mockClusterState.getMetadata()).thenReturn(mockMetadata);
Expand All @@ -159,9 +162,9 @@ public void testInitIndexIfAbsent_IndexExist() {

createIndexStep.initIndexIfAbsent(index, listener);

@SuppressWarnings({ "unchecked", "deprecation" })
ArgumentCaptor<PutMappingRequest> putMappingRequestArgumentCaptor = ArgumentCaptor.forClass(PutMappingRequest.class);
ArgumentCaptor<ActionListener> listenerCaptor = ArgumentCaptor.forClass(ActionListener.class);
@SuppressWarnings({ "unchecked" })
ArgumentCaptor<ActionListener<AcknowledgedResponse>> listenerCaptor = ArgumentCaptor.forClass(ActionListener.class);
verify(indicesAdminClient, times(1)).putMapping(putMappingRequestArgumentCaptor.capture(), listenerCaptor.capture());
PutMappingRequest capturedRequest = putMappingRequestArgumentCaptor.getValue();
assertEquals(index.getIndexName(), capturedRequest.indices()[0]);
Expand All @@ -179,6 +182,7 @@ public void testInitIndexIfAbsent_IndexExist_returnFalse() {

@SuppressWarnings("unchecked")
ActionListener<Boolean> listener = mock(ActionListener.class);
@SuppressWarnings("unchecked")
Map<String, IndexMetadata> mockIndices = mock(Map.class);
when(mockClusterState.getMetadata()).thenReturn(mockMetadata);
when(mockMetadata.indices()).thenReturn(mockIndices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void testDeployModel() {

DeployModelStep deployModel = new DeployModelStep(nodeClient);

@SuppressWarnings("unchecked")
ArgumentCaptor<ActionListener<MLDeployModelResponse>> actionListenerCaptor = ArgumentCaptor.forClass(ActionListener.class);

doAnswer(invocation -> {
Expand Down
Loading