@Test public void testPost11() { String url = "http://www.baidu.com/?site=1"; Map<String, String> customParams = new HashMap<>(); putCustomParam(customParams, "user_name"); Map<String, String> defaultParams = UrlUtil.getParams(url); String sb = HttpCodeSnippetUtil.createPostSnippet( "testPost11", "http://www.baidu.com", customParams, defaultParams, Object.class.getName()); assertEquals( " public Observable testPost11(String user_name) {\n" + " HashMap<String, String> map = new HashMap<>();\n" + " map.put(\"user_name\", user_name);\n" + " map.put(\"site\", \"1\");\n" + "\n" + " return (Observable) mHttpRequest.doPost(\"http://www.baidu.com\", map, java.lang.Object.class);\n" + " }\n\n", sb); }
/** custom 0 default 0 */ @Test public void testPost00() { String url = "http://www.baidu.com/"; Map<String, String> customParams = new HashMap<>(); Map<String, String> defaultParams = UrlUtil.getParams(url); String block = HttpCodeSnippetUtil.createPostSnippet( "testPost00", "http://www.baidu.com", customParams, defaultParams, Object.class.getName()); assertEquals( " public Observable testPost00() {\n" + " HashMap<String, String> map = new HashMap<>();\n" + "\n" + " return (Observable) mHttpRequest.doPost(\"http://www.baidu.com\", map, java.lang.Object.class);\n" + " }\n\n", block); }
@Test public void testPost02() { String url = "http://www.baidu.com/?id=123&name=jack"; Map<String, String> customParams = new HashMap<>(); Map<String, String> defaultParams = UrlUtil.getParams(url); String sb = HttpCodeSnippetUtil.createPostSnippet( "testPost02", "http://www.baidu.com", customParams, defaultParams, Object.class.getName()); assertEquals( " public Observable testPost02() {\n" + " HashMap<String, String> map = new HashMap<>();\n" + " map.put(\"id\", \"123\");\n" + " map.put(\"name\", \"jack\");\n" + "\n" + " return (Observable) mHttpRequest.doPost(\"http://www.baidu.com\", map, java.lang.Object.class);\n" + " }\n\n", sb); }