{"action":"created","issue":{"url":"https://api.github.com/repos/Codearte/accurest/issues/123","labels_url":"https://api.github.com/repos/Codearte/accurest/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/Codearte/accurest/issues/123/comments","events_url":"https://api.github.com/repos/Codearte/accurest/issues/123/events","html_url":"https://github.com/Codearte/accurest/issues/123","id":102364923,"number":123,"title":"Generated Stub and Spec should be easier to read","user":{"login":"mariuszs","id":1623393,"avatar_url":"https://avatars.githubusercontent.com/u/1623393?v=3","gravatar_id":"","url":"https://api.github.com/users/mariuszs","html_url":"https://github.com/mariuszs","followers_url":"https://api.github.com/users/mariuszs/followers","following_url":"https://api.github.com/users/mariuszs/following{/other_user}","gists_url":"https://api.github.com/users/mariuszs/gists{/gist_id}","starred_url":"https://api.github.com/users/mariuszs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariuszs/subscriptions","organizations_url":"https://api.github.com/users/mariuszs/orgs","repos_url":"https://api.github.com/users/mariuszs/repos","events_url":"https://api.github.com/users/mariuszs/events{/privacy}","received_events_url":"https://api.github.com/users/mariuszs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-21T12:09:46Z","updated_at":"2015-08-25T20:13:39Z","closed_at":null,"body":"I propose to use assertions with multiple matches instead of one global match:\r\n\r\n```json\r\n{\r\n  \"request\": {\r\n    \"method\": \"POST\",\r\n    \"urlPattern\": \"/ws/communication/notification\",\r\n    \"bodyPatterns\": [\r\n      {\r\n        \"matchesJsonPath\": \"$.parameters[?(@.partner_name == 'Super Kredyt Inc.')]\",\r\n        \"matchesJsonPath\": \"$.parameters.token\",\r\n        \"matchesJsonPath\": \"$.parameters[?(@.invitation_url =~ /.*http:/')]\",\r\n        \"matchesJsonPath\": \"$.parameters[?(@.email == 'jan.kowalski@email.com')]\",\r\n        \"matchesJsonPath\": \"$.messages[?(@.to == 'jan.kowalski@email.com')]\"\r\n      }\r\n    ]\r\n  },\r\n  \"response\": {\r\n    \"status\": 200\r\n  }\r\n}\r\n```\r\n\r\ninstead of code like:\r\n\r\n```java\r\nPattern pattern = Pattern.compile(\"\\\\s*x\\\\{\\\\s*\\\"email\\\"\\\\s*:\\\\s*\\\"?[_]*([a-z0-9]+(\\\\.|_*)?)+@([a-z][a-z0-9-]+(\\\\.|-*\\\\.))+[a-z]{2,6}\\\"?\\\\s*,\\\\s*\\\"first_name\\\"\\\\s*:\\\\s*\\\"?.+\\\"?\\\\s*,\\\\s*\\\"last_name\\\"\\\\s*:\\\\s*\\\"?.+\\\"?\\\\s*,\\\\s*\\\"personal_id\\\"\\\\s*:\\\\s*\\\"?.+\\\"?\\\\s*,\\\\s*\\\"phone_number\\\"\\\\s*:\\\\s*\\\"?.+\\\"?\\\\s*,\\\\s*\\\"invitation_token\\\"\\\\s*:\\\\s*\\\"?mismatched.token\\\"?\\\\s*,\\\\s*\\\"password\\\"\\\\s*:\\\\s*\\\"?.+\\\"?\\\\s*\\\\}\\\\s*\")\r\n```\r\n\r\nThis code is too slow to execute on my laptop."},"comment":{"url":"https://api.github.com/repos/Codearte/accurest/issues/comments/134724332","html_url":"https://github.com/Codearte/accurest/issues/123#issuecomment-134724332","issue_url":"https://api.github.com/repos/Codearte/accurest/issues/123","id":134724332,"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},"created_at":"2015-08-25T20:13:39Z","updated_at":"2015-08-25T20:13:39Z","body":"Example of the generated test:\r\n\r\n```\r\npackage io.codearte.accurest.tests\r\n\r\nimport com.blogspot.toomuchcoding.MvcSpec\r\nimport com.jayway.jsonpath.Configuration\r\nimport com.jayway.jsonpath.DocumentContext\r\nimport com.jayway.jsonpath.JsonPath\r\nimport groovy.json.JsonSlurper\r\nimport net.minidev.json.JSONArray\r\n\r\nimport static com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*\r\n\r\nclass FraudDetectionServiceSpec extends MvcSpec {\r\n\r\n\tdef shouldMarkClientAsNotFraud() {\r\n\t\tgiven:\r\n\t\t\tdef request = given()\r\n\t\t\t\t\t.header('Content-Type', 'application/vnd.fraud.v1+json')\r\n\t\t\t\t\t.body('{\"clientPesel\":\"1234567890\",\"loanAmount\":123.123}')\r\n\r\n\t\twhen:\r\n\t\t\tdef response = given().spec(request)\r\n\t\t\t\t\t.put(\"/fraudcheck\")\r\n\r\n\t\tthen:\r\n\t\t\tresponse.statusCode == 200\r\n\t\t\tresponse.header('Content-Type')  == 'application/vnd.fraud.v1+json'\r\n\t\tand:\r\n\t\t\tDocumentContext parsedJson = JsonPath.parse(response.body.asString())\r\n\t\t\tparsedJson.read('$.fraudCheckStatus') == 'OK'\r\n\t\t\tassertThatRejectionReasonIsNull(parsedJson.read('$.rejectionReason'))\r\n\t}\r\n\r\n\tdef shouldMarkClientAsFraud() {\r\n\t\tgiven:\r\n\t\t\tdef request = given()\r\n\t\t\t\t\t.header('Content-Type', 'application/vnd.fraud.v1+json')\r\n\t\t\t\t\t.body('{\"clientPesel\":\"1234567890\",\"loanAmount\":99999}')\r\n\r\n\t\twhen:\r\n\t\t\tdef response = given().spec(request)\r\n\t\t\t\t\t.put(\"/fraudcheck\")\r\n\r\n\t\tthen:\r\n\t\t\tresponse.statusCode == 200\r\n\t\t\tresponse.header('Content-Type')  == 'application/vnd.fraud.v1+json'\r\n\t\tand:\r\n\t\t\tDocumentContext parsedJson = JsonPath.parse(response.body.asString())\r\n\t\t\tparsedJson.read('$.rejectionReason') == 'Amount too high'\r\n\t\t\tparsedJson.read('$.fraudCheckStatus') ==~ '[A-Z]{5}'\r\n\t}\r\n\r\n}\r\n\r\n```"}}