use of org.opensearch.action.support.TransportAction in project OpenSearch by opensearch-project.
the class RestValidateQueryActionTests method stubValidateQueryAction.
/**
* Configures {@link NodeClient} to stub {@link ValidateQueryAction} transport action.
* <p>
* This lower level of validation is out of the scope of this test.
*/
@BeforeClass
public static void stubValidateQueryAction() {
final TaskManager taskManager = new TaskManager(Settings.EMPTY, threadPool, Collections.emptySet());
final TransportAction transportAction = new TransportAction(ValidateQueryAction.NAME, new ActionFilters(Collections.emptySet()), taskManager) {
@Override
protected void doExecute(Task task, ActionRequest request, ActionListener listener) {
}
};
final Map<ActionType, TransportAction> actions = new HashMap<>();
actions.put(ValidateQueryAction.INSTANCE, transportAction);
client.initialize(actions, () -> "local", null, new NamedWriteableRegistry(Collections.emptyList()));
controller.registerHandler(action);
}
use of org.opensearch.action.support.TransportAction in project OpenSearch by opensearch-project.
the class ActionModuleTests method testPluginCanRegisterAction.
public void testPluginCanRegisterAction() {
class FakeRequest extends ActionRequest {
@Override
public ActionRequestValidationException validate() {
return null;
}
}
class FakeTransportAction extends TransportAction<FakeRequest, ActionResponse> {
protected FakeTransportAction(String actionName, ActionFilters actionFilters, TaskManager taskManager) {
super(actionName, actionFilters, taskManager);
}
@Override
protected void doExecute(Task task, FakeRequest request, ActionListener<ActionResponse> listener) {
}
}
class FakeAction extends ActionType<ActionResponse> {
protected FakeAction() {
super("fake", null);
}
}
FakeAction action = new FakeAction();
ActionPlugin registersFakeAction = new ActionPlugin() {
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return singletonList(new ActionHandler<>(action, FakeTransportAction.class));
}
};
assertThat(ActionModule.setupActions(singletonList(registersFakeAction)), hasEntry("fake", new ActionHandler<>(action, FakeTransportAction.class)));
}
Aggregations