@Test public void getApiInfoTest() throws InterruptedException, ExecutionException { var apiInfo = List.of( 1, Map.of( "error_types", Map.of("Exception", Map.of("id", 0)), "functions", List.of( Map.of( "method", true, "name", "method_name", "parameters", List.of(List.of("String", "param1"), List.of("Integer", "param2")), "return_type", "Integer", "since", 4 ), Map.of( "method", false, "name", "old_method_name", "parameters", List.of(), "return_type", "String", "since", 0, "deprecated_since", 1 ) ), "types", Map.of("Buffer", Map.of("id", 0, "prefix", "nvim_buf_")), "ui_events", List.of( Map.of( "name", "event_name", "parameters", List.of(List.of("String", "param1")), "since", 4 ) ), "ui_options", List.of("opt1", "opt2"), "version", Map.of( "api_compatible", 0, "api_level", 4, "api_prerelease", false, "major", 0, "minor", 3, "patch", 1 ) ) ); assertNormalBehavior( () -> CompletableFuture.completedFuture(new ResponseMessage(1, null, apiInfo)), () -> neovimStreamApi.getApiInfo(), request -> assertMethodAndArguments(request, NeovimApi.GET_API_INFO), result -> { assertEquals(1, (int) result.getChannelId()); assertEquals(2, result.getFunctions().size()); FunctionInfo newFunctionInfo = result.getFunctions().get(0); assertTrue(newFunctionInfo.isMethod()); assertEquals("method_name", newFunctionInfo.getName()); assertEquals("Integer", newFunctionInfo.getReturnType()); assertEquals(2, newFunctionInfo.getParameters().size()); assertEquals(4, newFunctionInfo.getSince()); assertEquals(0, newFunctionInfo.getDeprecatedSince()); ParamInfo firstParam = newFunctionInfo.getParameters().get(0); ParamInfo secondParam = newFunctionInfo.getParameters().get(1); assertEquals("String", firstParam.getType()); assertEquals("param1", firstParam.getName()); assertEquals("Integer", secondParam.getType()); assertEquals("param2", secondParam.getName()); firstParam.toString(); secondParam.toString(); FunctionInfo oldFunctionInfo = result.getFunctions().get(1); assertFalse(oldFunctionInfo.isMethod()); assertEquals("old_method_name", oldFunctionInfo.getName()); assertEquals("String", oldFunctionInfo.getReturnType()); assertTrue(oldFunctionInfo.getParameters().isEmpty()); assertEquals(0, oldFunctionInfo.getSince()); assertEquals(1, oldFunctionInfo.getDeprecatedSince()); newFunctionInfo.toString(); oldFunctionInfo.toString(); assertEquals(1, result.getTypes().size()); TypeInfo typeInfo = result.getTypes().get(0); assertEquals("Buffer", typeInfo.getName()); assertEquals("nvim_buf_", typeInfo.getPrefix()); assertEquals(0, typeInfo.getId()); typeInfo.toString(); assertEquals(1, result.getUiEvents().size()); UiEventInfo uiEventInfo = result.getUiEvents().get(0); assertEquals("event_name", uiEventInfo.getName()); assertEquals(4, uiEventInfo.getSince()); assertEquals(1, uiEventInfo.getParameters().size()); ParamInfo paramInfo = uiEventInfo.getParameters().get(0); assertEquals("String", paramInfo.getType()); assertEquals("param1", paramInfo.getName()); uiEventInfo.toString(); assertEquals(2, result.getUiOptions().size()); assertEquals("opt1", result.getUiOptions().get(0)); assertEquals("opt2", result.getUiOptions().get(1)); assertEquals(0, result.getVersion().getCompatible()); assertEquals(4, result.getVersion().getLevel()); assertEquals(0, result.getVersion().getMajor()); assertEquals(3, result.getVersion().getMinor()); assertEquals(1, result.getVersion().getPatch()); assertFalse(result.getVersion().isPreRelease()); assertEquals("0.3.1", result.getVersion().getVersionString()); result.getVersion().toString(); result.toString(); } ); assertErrorBehavior( () -> neovimStreamApi.getApiInfo(), request -> assertMethodAndArguments(request, NeovimApi.GET_API_INFO) ); }
@Override public CompletableFuture<ApiInfo> getApiInfo() { return sendWithResponseOfType(new RequestMessage.Builder(GET_API_INFO), ApiInfo.class); }
NeovimStreamApi extends BaseStreamApi implements NeovimApi { @Override public CompletableFuture<ApiInfo> getApiInfo() { return sendWithResponseOfType(new RequestMessage.Builder(GET_API_INFO), ApiInfo.class); } }
NeovimStreamApi extends BaseStreamApi implements NeovimApi { @Override public CompletableFuture<ApiInfo> getApiInfo() { return sendWithResponseOfType(new RequestMessage.Builder(GET_API_INFO), ApiInfo.class); } NeovimStreamApi(ReactiveRpcStreamer reactiveRpcStreamer); }
NeovimStreamApi extends BaseStreamApi implements NeovimApi { @Override public CompletableFuture<ApiInfo> getApiInfo() { return sendWithResponseOfType(new RequestMessage.Builder(GET_API_INFO), ApiInfo.class); } NeovimStreamApi(ReactiveRpcStreamer reactiveRpcStreamer); @Override CompletableFuture<List> sendAtomic(AtomicCallBuilder atomicCallBuilder); @Override AtomicCallBuilder prepareAtomic(); @Override CompletableFuture<Map> getHighlightById(int id, boolean rgb); @Override CompletableFuture<Map> getHighlightByName(String name, boolean rgb); @Override CompletableFuture<Void> attachUi(int width, int height, UiOptions options); @Override CompletableFuture<Void> detachUi(); @Override CompletableFuture<Void> resizeUi(int width, int height); @Override CompletableFuture<Void> resizeUiGrid(int width, int height); @Override CompletableFuture<Void> setPopupmenuHeight(int height); @Override CompletableFuture<Void> inputMouse(Mouse.Button button, Mouse.Action action, String modifier, int grid, int row, int col); @Override CompletableFuture<Object> executeLua(String luaCode, List<String> args); @Override CompletableFuture<Void> executeCommand(String command); @Override CompletableFuture<Void> setCurrentDir(String directoryPath); @Override CompletableFuture<Void> subscribeToEvent(String event); @Override CompletableFuture<Void> unsubscribeFromEvent(String event); @Override CompletableFuture<Object> eval(String expression); @Override CompletableFuture<Object> callFunction(String name, List<Object> args); @Override CompletableFuture<Void> feedKeys(String keys, String mode, boolean escape); @Override CompletableFuture<Integer> input(String keys); @Override CompletableFuture<List<VimKeyMap>> getKeymap(String mode); @Override CompletableFuture<Void> setKeymap(String mode, String lhs, String rhs, Map<String, Boolean> options); @Override CompletableFuture<Void> deleteKeymap(String mode, String lhs); @Override CompletableFuture<Void> setUiOption(String name, Object value); @Override CompletableFuture<Void> setVariable(String name, Object value); @Override CompletableFuture<Object> getVariable(String name); @Override CompletableFuture<Void> deleteVariable(String name); @Override CompletableFuture<Object> getVimVariable(String name); @Override CompletableFuture<Void> setVimVariable(String name, Object value); @Override CompletableFuture<Void> setOption(String name, Object value); @Override CompletableFuture<Object> getOption(String name); @Override CompletableFuture<Integer> getColorByName(String name); @Override CompletableFuture<String> replaceTermcodes(String strToReplace, boolean fromPart, boolean doLt, boolean special); @Override CompletableFuture<String> commandOutput(String command); @Override CompletableFuture<Void> writeToOutput(String text); @Override CompletableFuture<Void> writeToError(String text); @Override CompletableFuture<Void> writelnToError(String text); @Override CompletableFuture<Integer> stringWidth(String string); @Override CompletableFuture<List<String>> listRuntimePaths(); @Override CompletableFuture<String> getCurrentLine(); @Override CompletableFuture<Void> setCurrentLine(String lineContent); @Override CompletableFuture<Void> deleteCurrentLine(); @Override CompletableFuture<List<NeovimBufferApi>> getBuffers(); @Override CompletableFuture<NeovimBufferApi> createBuffer(boolean listed, boolean scratch); @Override CompletableFuture<NeovimBufferApi> getCurrentBuffer(); @Override CompletableFuture<Void> setCurrentBuffer(Buffer buffer); @Override CompletableFuture<Void> setCurrentWindow(Window window); @Override CompletableFuture<Void> setCurrentTabpage(Tabpage tabpage); @Override CompletableFuture<List<NeovimWindowApi>> getWindows(); @Override CompletableFuture<NeovimWindowApi> openWindow(Buffer buffer, boolean enter, Map<String, Object> config); @Override CompletableFuture<NeovimWindowApi> getCurrentWindow(); @Override CompletableFuture<List<NeovimTabpageApi>> getTabpages(); @Override CompletableFuture<NeovimTabpageApi> getCurrentTabpage(); @Override CompletableFuture<VimColorMap> getColorMap(); @Override CompletableFuture<VimMode> getMode(); @Override CompletableFuture<ApiInfo> getApiInfo(); @Override CompletableFuture<Object> callDictFunction(Map map, String function, List args); @Override CompletableFuture<Map<String, CommandInfo>> getCommands(GetCommandsOptions getCommandsOptions); @Override CompletableFuture<Void> setClientInfo(String name, ClientVersionInfo clientVersionInfo, ClientType clientType, Map<String, MethodInfo> methods, ClientAttributes clientAttributes); @Override CompletableFuture<ChannelInfo> getChannelInfo(int channel); @Override CompletableFuture<List<ChannelInfo>> getChannels(); @Override CompletableFuture<Map> parseExpression(String expression, String flags, boolean highlight); @Override CompletableFuture<List<UiInfo>> getUis(); @Override CompletableFuture<List<Integer>> getProcessChildren(); @Override CompletableFuture<Object> getProcess(); @Override CompletableFuture<Map<String, Integer>> getNamespaces(); @Override CompletableFuture<Integer> createNamespace(String name); @Override CompletableFuture<Boolean> paste(String data, boolean crlf, int phase); @Override CompletableFuture<Void> put(List<String> lines, String type, boolean after, boolean follow); @Override CompletableFuture<Map<String, Object>> getContext(Map<String, Object> options); @Override CompletableFuture<Void> loadContext(Map<String, Object> contextMap); @Override CompletableFuture<Void> selectPopupmenuItem(int item, boolean insert, boolean finish, Map<String, Object> options); }
NeovimStreamApi extends BaseStreamApi implements NeovimApi { @Override public CompletableFuture<ApiInfo> getApiInfo() { return sendWithResponseOfType(new RequestMessage.Builder(GET_API_INFO), ApiInfo.class); } NeovimStreamApi(ReactiveRpcStreamer reactiveRpcStreamer); @Override CompletableFuture<List> sendAtomic(AtomicCallBuilder atomicCallBuilder); @Override AtomicCallBuilder prepareAtomic(); @Override CompletableFuture<Map> getHighlightById(int id, boolean rgb); @Override CompletableFuture<Map> getHighlightByName(String name, boolean rgb); @Override CompletableFuture<Void> attachUi(int width, int height, UiOptions options); @Override CompletableFuture<Void> detachUi(); @Override CompletableFuture<Void> resizeUi(int width, int height); @Override CompletableFuture<Void> resizeUiGrid(int width, int height); @Override CompletableFuture<Void> setPopupmenuHeight(int height); @Override CompletableFuture<Void> inputMouse(Mouse.Button button, Mouse.Action action, String modifier, int grid, int row, int col); @Override CompletableFuture<Object> executeLua(String luaCode, List<String> args); @Override CompletableFuture<Void> executeCommand(String command); @Override CompletableFuture<Void> setCurrentDir(String directoryPath); @Override CompletableFuture<Void> subscribeToEvent(String event); @Override CompletableFuture<Void> unsubscribeFromEvent(String event); @Override CompletableFuture<Object> eval(String expression); @Override CompletableFuture<Object> callFunction(String name, List<Object> args); @Override CompletableFuture<Void> feedKeys(String keys, String mode, boolean escape); @Override CompletableFuture<Integer> input(String keys); @Override CompletableFuture<List<VimKeyMap>> getKeymap(String mode); @Override CompletableFuture<Void> setKeymap(String mode, String lhs, String rhs, Map<String, Boolean> options); @Override CompletableFuture<Void> deleteKeymap(String mode, String lhs); @Override CompletableFuture<Void> setUiOption(String name, Object value); @Override CompletableFuture<Void> setVariable(String name, Object value); @Override CompletableFuture<Object> getVariable(String name); @Override CompletableFuture<Void> deleteVariable(String name); @Override CompletableFuture<Object> getVimVariable(String name); @Override CompletableFuture<Void> setVimVariable(String name, Object value); @Override CompletableFuture<Void> setOption(String name, Object value); @Override CompletableFuture<Object> getOption(String name); @Override CompletableFuture<Integer> getColorByName(String name); @Override CompletableFuture<String> replaceTermcodes(String strToReplace, boolean fromPart, boolean doLt, boolean special); @Override CompletableFuture<String> commandOutput(String command); @Override CompletableFuture<Void> writeToOutput(String text); @Override CompletableFuture<Void> writeToError(String text); @Override CompletableFuture<Void> writelnToError(String text); @Override CompletableFuture<Integer> stringWidth(String string); @Override CompletableFuture<List<String>> listRuntimePaths(); @Override CompletableFuture<String> getCurrentLine(); @Override CompletableFuture<Void> setCurrentLine(String lineContent); @Override CompletableFuture<Void> deleteCurrentLine(); @Override CompletableFuture<List<NeovimBufferApi>> getBuffers(); @Override CompletableFuture<NeovimBufferApi> createBuffer(boolean listed, boolean scratch); @Override CompletableFuture<NeovimBufferApi> getCurrentBuffer(); @Override CompletableFuture<Void> setCurrentBuffer(Buffer buffer); @Override CompletableFuture<Void> setCurrentWindow(Window window); @Override CompletableFuture<Void> setCurrentTabpage(Tabpage tabpage); @Override CompletableFuture<List<NeovimWindowApi>> getWindows(); @Override CompletableFuture<NeovimWindowApi> openWindow(Buffer buffer, boolean enter, Map<String, Object> config); @Override CompletableFuture<NeovimWindowApi> getCurrentWindow(); @Override CompletableFuture<List<NeovimTabpageApi>> getTabpages(); @Override CompletableFuture<NeovimTabpageApi> getCurrentTabpage(); @Override CompletableFuture<VimColorMap> getColorMap(); @Override CompletableFuture<VimMode> getMode(); @Override CompletableFuture<ApiInfo> getApiInfo(); @Override CompletableFuture<Object> callDictFunction(Map map, String function, List args); @Override CompletableFuture<Map<String, CommandInfo>> getCommands(GetCommandsOptions getCommandsOptions); @Override CompletableFuture<Void> setClientInfo(String name, ClientVersionInfo clientVersionInfo, ClientType clientType, Map<String, MethodInfo> methods, ClientAttributes clientAttributes); @Override CompletableFuture<ChannelInfo> getChannelInfo(int channel); @Override CompletableFuture<List<ChannelInfo>> getChannels(); @Override CompletableFuture<Map> parseExpression(String expression, String flags, boolean highlight); @Override CompletableFuture<List<UiInfo>> getUis(); @Override CompletableFuture<List<Integer>> getProcessChildren(); @Override CompletableFuture<Object> getProcess(); @Override CompletableFuture<Map<String, Integer>> getNamespaces(); @Override CompletableFuture<Integer> createNamespace(String name); @Override CompletableFuture<Boolean> paste(String data, boolean crlf, int phase); @Override CompletableFuture<Void> put(List<String> lines, String type, boolean after, boolean follow); @Override CompletableFuture<Map<String, Object>> getContext(Map<String, Object> options); @Override CompletableFuture<Void> loadContext(Map<String, Object> contextMap); @Override CompletableFuture<Void> selectPopupmenuItem(int item, boolean insert, boolean finish, Map<String, Object> options);  }