コード例 #1
0
  @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);
  }
コード例 #2
0
  /** custom 0 default 1 */
  @Test
  public void testGet01() {
    Map<String, String> customParams = new LinkedHashMap<>();
    String url = "http://www.baidu.com?user_id=123";
    Map<String, String> defaultParams = UrlUtil.getParams(url);

    String sb =
        HttpCodeSnippetUtil.createGetSnippet(
            "testGet01",
            "http://www.baidu.com",
            customParams,
            defaultParams,
            Object.class.getName());
    assertEquals(
        "    public Observable testGet01() {\n"
            + "        return (Observable) mHttpRequest.doGet(\"http://www.baidu.com?\"\n"
            + "                + \"&user_id=123\"                , java.lang.Object.class);\n"
            + "    }\n\n",
        sb);
  }
コード例 #3
0
  /** 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);
  }
コード例 #4
0
  /** custom 1 default 0 */
  @Test
  public void testGet10() throws Exception {
    String url = "http://www.baidu.com";

    Map<String, String> customParams = new LinkedHashMap<>();
    putCustomParam(customParams, "user_id");
    Map<String, String> defaultParams = UrlUtil.getParams(url);

    String sb =
        HttpCodeSnippetUtil.createGetSnippet(
            "testGet10",
            "http://www.baidu.com",
            customParams,
            defaultParams,
            Object.class.getName());
    assertEquals(
        "    public Observable testGet10(String user_id) {\n"
            + "        return (Observable) mHttpRequest.doGet(\"http://www.baidu.com?\"\n"
            + "                + \"&user_id=\" + user_id                , java.lang.Object.class);\n"
            + "    }\n\n",
        sb);
  }
コード例 #5
0
  @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);
  }