{"action":"created","comment":{"url":"https://api.github.com/repos/Codearte/accurest/pulls/comments/23969461","id":23969461,"diff_hunk":"@@ -0,0 +1,172 @@\n+package io.coderate.accurest.dsl\n+\n+import groovy.transform.TypeChecked\n+\n+@TypeChecked\n+class Request {\n+    String method\n+    String url\n+    StringCustomizableProperty urlPattern\n+    String urlPath\n+    Headers headers\n+\n+    void method(String method) {\n+        this.method = method\n+    }\n+\n+    void url(String url) {\n+        this.url = url\n+    }\n+\n+    void urlPattern(@DelegatesTo(StringCustomizableProperty) Closure closure) {\n+        StringCustomizableProperty urlPattern = new StringCustomizableProperty()\n+        this.urlPattern = urlPattern\n+        delegateToClosure(closure, urlPattern)\n+    }\n+\n+    void headers(@DelegatesTo(Headers) Closure closure) {\n+        Headers headers = new Headers()\n+        this.headers = headers\n+        delegateToClosure(closure, headers)\n+    }\n+\n+    void urlPath(String urlPath) {\n+        this.urlPath = urlPath\n+    }\n+\n+    //TODO: Can we have different types for Client/Server (client: pattern(String), server: value(Boolean/Int)) ?\n+    class CustomizableProperty<T, V> {\n+        private T client\n+        private V server\n+\n+        void client(T client) {\n+            this.client = client\n+        }\n+\n+        void server(V server) {\n+            this.server = server\n+        }\n+\n+        T toClientSide() {\n+            return client\n+        }\n+\n+        V toServerSide() {\n+            return server\n+        }\n+    }\n+\n+    private class StringCustomizableProperty extends CustomizableProperty<String, String> {\n+        @Override\n+        String toClientSide() {\n+            return super.toClientSide() as String\n+        }\n+\n+        @Override\n+        String toServerSide() {\n+            return super.toServerSide() as String\n+        }\n+    }\n+\n+    private class NoOpCustomizableProperty<T> extends CustomizableProperty<T, T> {\n+        NoOpCustomizableProperty(T value) {\n+            client(value)\n+            server(value)\n+        }\n+\n+        @Override\n+        public String toString() {\n+            return toClientSide()\n+        }\n+    }\n+\n+    class Headers {\n+        private Map<String, WithValuePattern> headers = [:]\n+\n+        WithValuePattern header(String headerName) {\n+            WithValuePattern withValuePattern = new WithValuePattern()\n+            headers[headerName] = withValuePattern\n+            return withValuePattern\n+        }\n+\n+        Set<Map.Entry<String, WithValuePattern>> entries() {\n+            return headers.entrySet()\n+        }\n+    }\n+\n+/**\n+ *\n+ * From Wiremock\n+ private Map<String, ValuePattern> queryParamPatterns;\n+ private List<ValuePattern> bodyPatterns;\n+\n+ private String equalToJson;\n+ private String equalToXml;\n+ private String matchesXPath;\n+ private JSONCompareMode jsonCompareMode;\n+ private String equalTo;\n+ private String contains;\n+ private String matches;\n+ private String doesNotMatch;\n+ private Boolean absent;\n+ private String matchesJsonPath;\n+\n+ */\n+    class WithValuePattern {\n+        NoOpCustomizableProperty<String> equalToJson\n+        NoOpCustomizableProperty<String> equalToXml\n+        StringCustomizableProperty matchesXPath\n+        NoOpCustomizableProperty<JSONCompareMode> jsonCompareMode\n+        NoOpCustomizableProperty<String> equalTo\n+        StringCustomizableProperty contains\n+        StringCustomizableProperty matches\n+        StringCustomizableProperty doesNotMatch\n+        CustomizableProperty<Boolean, Boolean> absent\n+        StringCustomizableProperty matchesJsonPath\n+\n+//        void equalToJson(String equalToJson) {\n+//            this.equalToJson = equalToJson\n+//        }\n+//\n+        void equalTo(String equalTo) {\n+            this.equalTo = new NoOpCustomizableProperty(equalTo)\n+        }\n+\n+//        void equalToXml(String equalToXml) {\n+//            this.equalToXml = equalToXml\n+//        }\n+\n+        void matches(@DelegatesTo(StringCustomizableProperty) Closure closure) {\n+            StringCustomizableProperty placeholderHaving = new StringCustomizableProperty()\n+            this.matches = placeholderHaving\n+            delegateToClosure(closure, placeholderHaving)\n+        }\n+\n+        void doesNotMatch(@DelegatesTo(StringCustomizableProperty) Closure closure) {\n+            StringCustomizableProperty placeholderHaving = new StringCustomizableProperty()\n+            this.doesNotMatch = placeholderHaving\n+            delegateToClosure(closure, placeholderHaving)\n+        }\n+\n+        void contains(@DelegatesTo(StringCustomizableProperty) Closure closure) {\n+            StringCustomizableProperty placeholderHaving = new StringCustomizableProperty()\n+            this.contains = placeholderHaving\n+            delegateToClosure(closure, placeholderHaving)\n+        }\n+\n+//        void jsonCompareMode(JSONCompareMode jsonCompareMode) {\n+//            this.jsonCompareMode = jsonCompareMode\n+//        }\n+\n+    }\n+\n+    enum JSONCompareMode {\n+        STRICT, LENIENT, NON_EXTENSIBLE, STRICT_ORDER;\n+    }\n+\n+    private static <T> void delegateToClosure(@DelegatesTo(T) Closure closure, T delegate) {","path":"accurest-core/src/main/groovy/io/coderate/accurest/dsl/Request.groovy","position":167,"original_position":167,"commit_id":"2df1dd57aad55833e7f36eb80bb5c0733d9b4482","original_commit_id":"2df1dd57aad55833e7f36eb80bb5c0733d9b4482","user":{"login":"szpak","id":148013,"avatar_url":"https://avatars.githubusercontent.com/u/148013?v=3","gravatar_id":"","url":"https://api.github.com/users/szpak","html_url":"https://github.com/szpak","followers_url":"https://api.github.com/users/szpak/followers","following_url":"https://api.github.com/users/szpak/following{/other_user}","gists_url":"https://api.github.com/users/szpak/gists{/gist_id}","starred_url":"https://api.github.com/users/szpak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szpak/subscriptions","organizations_url":"https://api.github.com/users/szpak/orgs","repos_url":"https://api.github.com/users/szpak/repos","events_url":"https://api.github.com/users/szpak/events{/privacy}","received_events_url":"https://api.github.com/users/szpak/received_events","type":"User","site_admin":false},"body":"Maybe it could be moved to a separate trait to share with other classes?","created_at":"2015-02-02T23:30:58Z","updated_at":"2015-02-02T23:30:58Z","html_url":"https://github.com/Codearte/accurest/pull/9#discussion_r23969461","pull_request_url":"https://api.github.com/repos/Codearte/accurest/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/Codearte/accurest/pulls/comments/23969461"},"html":{"href":"https://github.com/Codearte/accurest/pull/9#discussion_r23969461"},"pull_request":{"href":"https://api.github.com/repos/Codearte/accurest/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/Codearte/accurest/pulls/9","id":28508022,"html_url":"https://github.com/Codearte/accurest/pull/9","diff_url":"https://github.com/Codearte/accurest/pull/9.diff","patch_url":"https://github.com/Codearte/accurest/pull/9.patch","issue_url":"https://api.github.com/repos/Codearte/accurest/issues/9","number":9,"state":"open","locked":false,"title":"Groovy dsl","user":{"login":"marcingrzejszczak","id":3297437,"avatar_url":"https://avatars.githubusercontent.com/u/3297437?v=3","gravatar_id":"","url":"https://api.github.com/users/marcingrzejszczak","html_url":"https://github.com/marcingrzejszczak","followers_url":"https://api.github.com/users/marcingrzejszczak/followers","following_url":"https://api.github.com/users/marcingrzejszczak/following{/other_user}","gists_url":"https://api.github.com/users/marcingrzejszczak/gists{/gist_id}","starred_url":"https://api.github.com/users/marcingrzejszczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcingrzejszczak/subscriptions","organizations_url":"https://api.github.com/users/marcingrzejszczak/orgs","repos_url":"https://api.github.com/users/marcingrzejszczak/repos","events_url":"https://api.github.com/users/marcingrzejszczak/events{/privacy}","received_events_url":"https://api.github.com/users/marcingrzejszczak/received_events","type":"User","site_admin":false},"body":"Partially done Request section of conversion of DSL to Wiremock + introduction of Wiremock strategy","created_at":"2015-02-02T22:17:16Z","updated_at":"2015-02-02T23:30:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1722389811c1a960b4a33ecbe9c928ed0e73fffc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Codearte/accurest/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Codearte/accurest/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Codearte/accurest/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Codearte/accurest/issues/9/comments","statuses_url":"https://api.github.com/repos/Codearte/accurest/statuses/2df1dd57aad55833e7f36eb80bb5c0733d9b4482","head":{"label":"Codearte:groovyDsl","ref":"groovyDsl","sha":"2df1dd57aad55833e7f36eb80bb5c0733d9b4482","user":{"login":"Codearte","id":5014314,"avatar_url":"https://avatars.githubusercontent.com/u/5014314?v=3","gravatar_id":"","url":"https://api.github.com/users/Codearte","html_url":"https://github.com/Codearte","followers_url":"https://api.github.com/users/Codearte/followers","following_url":"https://api.github.com/users/Codearte/following{/other_user}","gists_url":"https://api.github.com/users/Codearte/gists{/gist_id}","starred_url":"https://api.github.com/users/Codearte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Codearte/subscriptions","organizations_url":"https://api.github.com/users/Codearte/orgs","repos_url":"https://api.github.com/users/Codearte/repos","events_url":"https://api.github.com/users/Codearte/events{/privacy}","received_events_url":"https://api.github.com/users/Codearte/received_events","type":"Organization","site_admin":false},"repo":{"id":27642283,"name":"accurest","full_name":"Codearte/accurest","owner":{"login":"Codearte","id":5014314,"avatar_url":"https://avatars.githubusercontent.com/u/5014314?v=3","gravatar_id":"","url":"https://api.github.com/users/Codearte","html_url":"https://github.com/Codearte","followers_url":"https://api.github.com/users/Codearte/followers","following_url":"https://api.github.com/users/Codearte/following{/other_user}","gists_url":"https://api.github.com/users/Codearte/gists{/gist_id}","starred_url":"https://api.github.com/users/Codearte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Codearte/subscriptions","organizations_url":"https://api.github.com/users/Codearte/orgs","repos_url":"https://api.github.com/users/Codearte/repos","events_url":"https://api.github.com/users/Codearte/events{/privacy}","received_events_url":"https://api.github.com/users/Codearte/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Codearte/accurest","description":"","fork":false,"url":"https://api.github.com/repos/Codearte/accurest","forks_url":"https://api.github.com/repos/Codearte/accurest/forks","keys_url":"https://api.github.com/repos/Codearte/accurest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Codearte/accurest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Codearte/accurest/teams","hooks_url":"https://api.github.com/repos/Codearte/accurest/hooks","issue_events_url":"https://api.github.com/repos/Codearte/accurest/issues/events{/number}","events_url":"https://api.github.com/repos/Codearte/accurest/events","assignees_url":"https://api.github.com/repos/Codearte/accurest/assignees{/user}","branches_url":"https://api.github.com/repos/Codearte/accurest/branches{/branch}","tags_url":"https://api.github.com/repos/Codearte/accurest/tags","blobs_url":"https://api.github.com/repos/Codearte/accurest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Codearte/accurest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Codearte/accurest/git/refs{/sha}","trees_url":"https://api.github.com/repos/Codearte/accurest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Codearte/accurest/statuses/{sha}","languages_url":"https://api.github.com/repos/Codearte/accurest/languages","stargazers_url":"https://api.github.com/repos/Codearte/accurest/stargazers","contributors_url":"https://api.github.com/repos/Codearte/accurest/contributors","subscribers_url":"https://api.github.com/repos/Codearte/accurest/subscribers","subscription_url":"https://api.github.com/repos/Codearte/accurest/subscription","commits_url":"https://api.github.com/repos/Codearte/accurest/commits{/sha}","git_commits_url":"https://api.github.com/repos/Codearte/accurest/git/commits{/sha}","comments_url":"https://api.github.com/repos/Codearte/accurest/comments{/number}","issue_comment_url":"https://api.github.com/repos/Codearte/accurest/issues/comments/{number}","contents_url":"https://api.github.com/repos/Codearte/accurest/contents/{+path}","compare_url":"https://api.github.com/repos/Codearte/accurest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Codearte/accurest/merges","archive_url":"https://api.github.com/repos/Codearte/accurest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Codearte/accurest/downloads","issues_url":"https://api.github.com/repos/Codearte/accurest/issues{/number}","pulls_url":"https://api.github.com/repos/Codearte/accurest/pulls{/number}","milestones_url":"https://api.github.com/repos/Codearte/accurest/milestones{/number}","notifications_url":"https://api.github.com/repos/Codearte/accurest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Codearte/accurest/labels{/name}","releases_url":"https://api.github.com/repos/Codearte/accurest/releases{/id}","created_at":"2014-12-06T17:20:29Z","updated_at":"2015-02-01T22:02:01Z","pushed_at":"2015-02-02T23:28:28Z","git_url":"git://github.com/Codearte/accurest.git","ssh_url":"git@github.com:Codearte/accurest.git","clone_url":"https://github.com/Codearte/accurest.git","svn_url":"https://github.com/Codearte/accurest","homepage":null,"size":403,"stargazers_count":2,"watchers_count":2,"language":"Groovy","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":2,"default_branch":"master"}},"base":{"label":"Codearte:master","ref":"master","sha":"9bda30e107be5d9156d3092095eeb3cb7d36a0e3","user":{"login":"Codearte","id":5014314,"avatar_url":"https://avatars.githubusercontent.com/u/5014314?v=3","gravatar_id":"","url":"https://api.github.com/users/Codearte","html_url":"https://github.com/Codearte","followers_url":"https://api.github.com/users/Codearte/followers","following_url":"https://api.github.com/users/Codearte/following{/other_user}","gists_url":"https://api.github.com/users/Codearte/gists{/gist_id}","starred_url":"https://api.github.com/users/Codearte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Codearte/subscriptions","organizations_url":"https://api.github.com/users/Codearte/orgs","repos_url":"https://api.github.com/users/Codearte/repos","events_url":"https://api.github.com/users/Codearte/events{/privacy}","received_events_url":"https://api.github.com/users/Codearte/received_events","type":"Organization","site_admin":false},"repo":{"id":27642283,"name":"accurest","full_name":"Codearte/accurest","owner":{"login":"Codearte","id":5014314,"avatar_url":"https://avatars.githubusercontent.com/u/5014314?v=3","gravatar_id":"","url":"https://api.github.com/users/Codearte","html_url":"https://github.com/Codearte","followers_url":"https://api.github.com/users/Codearte/followers","following_url":"https://api.github.com/users/Codearte/following{/other_user}","gists_url":"https://api.github.com/users/Codearte/gists{/gist_id}","starred_url":"https://api.github.com/users/Codearte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Codearte/subscriptions","organizations_url":"https://api.github.com/users/Codearte/orgs","repos_url":"https://api.github.com/users/Codearte/repos","events_url":"https://api.github.com/users/Codearte/events{/privacy}","received_events_url":"https://api.github.com/users/Codearte/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Codearte/accurest","description":"","fork":false,"url":"https://api.github.com/repos/Codearte/accurest","forks_url":"https://api.github.com/repos/Codearte/accurest/forks","keys_url":"https://api.github.com/repos/Codearte/accurest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Codearte/accurest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Codearte/accurest/teams","hooks_url":"https://api.github.com/repos/Codearte/accurest/hooks","issue_events_url":"https://api.github.com/repos/Codearte/accurest/issues/events{/number}","events_url":"https://api.github.com/repos/Codearte/accurest/events","assignees_url":"https://api.github.com/repos/Codearte/accurest/assignees{/user}","branches_url":"https://api.github.com/repos/Codearte/accurest/branches{/branch}","tags_url":"https://api.github.com/repos/Codearte/accurest/tags","blobs_url":"https://api.github.com/repos/Codearte/accurest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Codearte/accurest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Codearte/accurest/git/refs{/sha}","trees_url":"https://api.github.com/repos/Codearte/accurest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Codearte/accurest/statuses/{sha}","languages_url":"https://api.github.com/repos/Codearte/accurest/languages","stargazers_url":"https://api.github.com/repos/Codearte/accurest/stargazers","contributors_url":"https://api.github.com/repos/Codearte/accurest/contributors","subscribers_url":"https://api.github.com/repos/Codearte/accurest/subscribers","subscription_url":"https://api.github.com/repos/Codearte/accurest/subscription","commits_url":"https://api.github.com/repos/Codearte/accurest/commits{/sha}","git_commits_url":"https://api.github.com/repos/Codearte/accurest/git/commits{/sha}","comments_url":"https://api.github.com/repos/Codearte/accurest/comments{/number}","issue_comment_url":"https://api.github.com/repos/Codearte/accurest/issues/comments/{number}","contents_url":"https://api.github.com/repos/Codearte/accurest/contents/{+path}","compare_url":"https://api.github.com/repos/Codearte/accurest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Codearte/accurest/merges","archive_url":"https://api.github.com/repos/Codearte/accurest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Codearte/accurest/downloads","issues_url":"https://api.github.com/repos/Codearte/accurest/issues{/number}","pulls_url":"https://api.github.com/repos/Codearte/accurest/pulls{/number}","milestones_url":"https://api.github.com/repos/Codearte/accurest/milestones{/number}","notifications_url":"https://api.github.com/repos/Codearte/accurest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Codearte/accurest/labels{/name}","releases_url":"https://api.github.com/repos/Codearte/accurest/releases{/id}","created_at":"2014-12-06T17:20:29Z","updated_at":"2015-02-01T22:02:01Z","pushed_at":"2015-02-02T23:28:28Z","git_url":"git://github.com/Codearte/accurest.git","ssh_url":"git@github.com:Codearte/accurest.git","clone_url":"https://github.com/Codearte/accurest.git","svn_url":"https://github.com/Codearte/accurest","homepage":null,"size":403,"stargazers_count":2,"watchers_count":2,"language":"Groovy","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":6,"forks":1,"open_issues":6,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Codearte/accurest/pulls/9"},"html":{"href":"https://github.com/Codearte/accurest/pull/9"},"issue":{"href":"https://api.github.com/repos/Codearte/accurest/issues/9"},"comments":{"href":"https://api.github.com/repos/Codearte/accurest/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Codearte/accurest/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Codearte/accurest/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Codearte/accurest/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Codearte/accurest/statuses/2df1dd57aad55833e7f36eb80bb5c0733d9b4482"}}}}