use of org.elasticsearch.plugins.ActionPlugin.ActionHandler in project elasticsearch by elastic.
the class ActionModuleTests method testPluginCantOverwriteBuiltinAction.
public void testPluginCantOverwriteBuiltinAction() {
ActionPlugin dupsMainAction = new ActionPlugin() {
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return singletonList(new ActionHandler<>(MainAction.INSTANCE, TransportMainAction.class));
}
};
Exception e = expectThrows(IllegalArgumentException.class, () -> ActionModule.setupActions(singletonList(dupsMainAction)));
assertEquals("action for name [" + MainAction.NAME + "] already registered", e.getMessage());
}
use of org.elasticsearch.plugins.ActionPlugin.ActionHandler in project elasticsearch by elastic.
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(Settings settings, String actionName, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, TaskManager taskManager) {
super(settings, actionName, threadPool, actionFilters, indexNameExpressionResolver, taskManager);
}
@Override
protected void doExecute(FakeRequest request, ActionListener<ActionResponse> listener) {
}
}
class FakeAction extends GenericAction<FakeRequest, ActionResponse> {
protected FakeAction() {
super("fake");
}
@Override
public ActionResponse newResponse() {
return 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