{"action":"created","comment":{"url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/comments/226230199","pull_request_review_id":165998621,"id":226230199,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjIzMDE5OQ==","diff_hunk":"@@ -48,19 +51,36 @@ public void allDecoratorsFireWithinASingleDecorateMethod() throws Exception {\n         validator.validate();\n         \n         assertTrue(validator instanceof DissolvedCompanyValidator);\n-        verify(validator).validate();\n+        verify(validator).mapValidationResult(ArgumentMatchers.any(ValidationResults.class));\n         \n-        ValidationProcessor<CorporateBody> companyExistsValidator = \n+        Optional<ValidationProcessor<CorporateBody>> companyExistsValidator = \n                 getInternalDecorator(validator);\n-        assertTrue(companyExistsValidator instanceof CompanyExistsValidator);\n-        verify(companyExistsValidator).validate();\n+        assertTrue(companyExistsValidator instanceof Optional);\n+        assertTrue(companyExistsValidator.get() instanceof CompanyExistsValidator);\n+        verify(companyExistsValidator.get()).mapValidationResult(ArgumentMatchers.any(ValidationResults.class));\n+    }\n+    \n+    @Test\n+    public void anEarlyFailedValidationWillBreakTheChain() {\n+\n+        ValidationResults validationResult = ValidationProcessor.<CorporateBody>of(null)\n+                 .addValidator(CompanyExistsValidator::new)\n+                 .addValidator(CompanyExistsValidator::new)\n+                 .addValidator(CompanyExistsValidator::new)\n+                 .validate()\n+                 .get();\n+\n+        assertEquals(false, validationResult.isPassedValidation());\n+        assertEquals(\"Company does not exist in the database\",","path":"src/test/java/uk/gov/companieshouse/restoration/common/ValidationProcessorTest.java","position":74,"original_position":74,"commit_id":"8d882ed94e030eb577c5fd20e4871d31ba55297f","original_commit_id":"8d882ed94e030eb577c5fd20e4871d31ba55297f","user":{"login":"markpit","id":11330756,"node_id":"MDQ6VXNlcjExMzMwNzU2","avatar_url":"https://avatars0.githubusercontent.com/u/11330756?v=4","gravatar_id":"","url":"https://api.github.com/users/markpit","html_url":"https://github.com/markpit","followers_url":"https://api.github.com/users/markpit/followers","following_url":"https://api.github.com/users/markpit/following{/other_user}","gists_url":"https://api.github.com/users/markpit/gists{/gist_id}","starred_url":"https://api.github.com/users/markpit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markpit/subscriptions","organizations_url":"https://api.github.com/users/markpit/orgs","repos_url":"https://api.github.com/users/markpit/repos","events_url":"https://api.github.com/users/markpit/events{/privacy}","received_events_url":"https://api.github.com/users/markpit/received_events","type":"User","site_admin":false},"body":"```suggestion\r\n        assertEquals(ValidationMessageEnum.COMPANY_DOES_NOT_EXIST.getMessage(),\r\n```","created_at":"2018-10-18T09:18:07Z","updated_at":"2018-10-18T09:18:07Z","html_url":"https://github.com/companieshouse/restoration-calculator-service/pull/11#discussion_r226230199","pull_request_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/comments/226230199"},"html":{"href":"https://github.com/companieshouse/restoration-calculator-service/pull/11#discussion_r226230199"},"pull_request":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11","id":223711083,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNzExMDgz","html_url":"https://github.com/companieshouse/restoration-calculator-service/pull/11","diff_url":"https://github.com/companieshouse/restoration-calculator-service/pull/11.diff","patch_url":"https://github.com/companieshouse/restoration-calculator-service/pull/11.patch","issue_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/11","number":11,"state":"open","locked":false,"title":"Feature/validation improvements","user":{"login":"jterrych","id":29060322,"node_id":"MDQ6VXNlcjI5MDYwMzIy","avatar_url":"https://avatars2.githubusercontent.com/u/29060322?v=4","gravatar_id":"","url":"https://api.github.com/users/jterrych","html_url":"https://github.com/jterrych","followers_url":"https://api.github.com/users/jterrych/followers","following_url":"https://api.github.com/users/jterrych/following{/other_user}","gists_url":"https://api.github.com/users/jterrych/gists{/gist_id}","starred_url":"https://api.github.com/users/jterrych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jterrych/subscriptions","organizations_url":"https://api.github.com/users/jterrych/orgs","repos_url":"https://api.github.com/users/jterrych/repos","events_url":"https://api.github.com/users/jterrych/events{/privacy}","received_events_url":"https://api.github.com/users/jterrych/received_events","type":"User","site_admin":false},"body":"Validators throwing Exceptions gives responsibility to the calling service to figure out what information should be gathered further and whether to continue buisness logic for validation warning messages.\r\nInstead I have modified the validation classes to populate and return an immutable ValidationResults object. This way the validators themselves can decide if busness logic should return early with error or continue with warning.\r\n\r\nThe ValidationResults object will contain a list of validation messages and whether the validation chain is a pass or fail.\r\n\r\nEach ValidationResult object will be reconstructed within their result function (in the event of a failure) to guarantee immutability.","created_at":"2018-10-17T18:36:10Z","updated_at":"2018-10-18T09:18:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3a1701134c435303a3a553aac69ee5e133e0c7f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11/commits","review_comments_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11/comments","review_comment_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/comments{/number}","comments_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/11/comments","statuses_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/statuses/8d882ed94e030eb577c5fd20e4871d31ba55297f","head":{"label":"companieshouse:feature/validation-improvements","ref":"feature/validation-improvements","sha":"8d882ed94e030eb577c5fd20e4871d31ba55297f","user":{"login":"companieshouse","id":4947323,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NDczMjM=","avatar_url":"https://avatars0.githubusercontent.com/u/4947323?v=4","gravatar_id":"","url":"https://api.github.com/users/companieshouse","html_url":"https://github.com/companieshouse","followers_url":"https://api.github.com/users/companieshouse/followers","following_url":"https://api.github.com/users/companieshouse/following{/other_user}","gists_url":"https://api.github.com/users/companieshouse/gists{/gist_id}","starred_url":"https://api.github.com/users/companieshouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/companieshouse/subscriptions","organizations_url":"https://api.github.com/users/companieshouse/orgs","repos_url":"https://api.github.com/users/companieshouse/repos","events_url":"https://api.github.com/users/companieshouse/events{/privacy}","received_events_url":"https://api.github.com/users/companieshouse/received_events","type":"Organization","site_admin":false},"repo":{"id":152053036,"node_id":"MDEwOlJlcG9zaXRvcnkxNTIwNTMwMzY=","name":"restoration-calculator-service","full_name":"companieshouse/restoration-calculator-service","private":false,"owner":{"login":"companieshouse","id":4947323,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NDczMjM=","avatar_url":"https://avatars0.githubusercontent.com/u/4947323?v=4","gravatar_id":"","url":"https://api.github.com/users/companieshouse","html_url":"https://github.com/companieshouse","followers_url":"https://api.github.com/users/companieshouse/followers","following_url":"https://api.github.com/users/companieshouse/following{/other_user}","gists_url":"https://api.github.com/users/companieshouse/gists{/gist_id}","starred_url":"https://api.github.com/users/companieshouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/companieshouse/subscriptions","organizations_url":"https://api.github.com/users/companieshouse/orgs","repos_url":"https://api.github.com/users/companieshouse/repos","events_url":"https://api.github.com/users/companieshouse/events{/privacy}","received_events_url":"https://api.github.com/users/companieshouse/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/companieshouse/restoration-calculator-service","description":"The calculator used for the costs of restorations","fork":false,"url":"https://api.github.com/repos/companieshouse/restoration-calculator-service","forks_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/forks","keys_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/teams","hooks_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/hooks","issue_events_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/events{/number}","events_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/events","assignees_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/assignees{/user}","branches_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/branches{/branch}","tags_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/tags","blobs_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/statuses/{sha}","languages_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/languages","stargazers_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/stargazers","contributors_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/contributors","subscribers_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/subscribers","subscription_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/subscription","commits_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/contents/{+path}","compare_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/merges","archive_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/downloads","issues_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues{/number}","pulls_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls{/number}","milestones_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/milestones{/number}","notifications_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/labels{/name}","releases_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/releases{/id}","deployments_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/deployments","created_at":"2018-10-08T09:27:24Z","updated_at":"2018-10-17T10:57:32Z","pushed_at":"2018-10-18T08:01:24Z","git_url":"git://github.com/companieshouse/restoration-calculator-service.git","ssh_url":"git@github.com:companieshouse/restoration-calculator-service.git","clone_url":"https://github.com/companieshouse/restoration-calculator-service.git","svn_url":"https://github.com/companieshouse/restoration-calculator-service","homepage":null,"size":63,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"companieshouse:develop","ref":"develop","sha":"a8e893efccb001ed9f7fb76bdea6c7dfb52c11e5","user":{"login":"companieshouse","id":4947323,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NDczMjM=","avatar_url":"https://avatars0.githubusercontent.com/u/4947323?v=4","gravatar_id":"","url":"https://api.github.com/users/companieshouse","html_url":"https://github.com/companieshouse","followers_url":"https://api.github.com/users/companieshouse/followers","following_url":"https://api.github.com/users/companieshouse/following{/other_user}","gists_url":"https://api.github.com/users/companieshouse/gists{/gist_id}","starred_url":"https://api.github.com/users/companieshouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/companieshouse/subscriptions","organizations_url":"https://api.github.com/users/companieshouse/orgs","repos_url":"https://api.github.com/users/companieshouse/repos","events_url":"https://api.github.com/users/companieshouse/events{/privacy}","received_events_url":"https://api.github.com/users/companieshouse/received_events","type":"Organization","site_admin":false},"repo":{"id":152053036,"node_id":"MDEwOlJlcG9zaXRvcnkxNTIwNTMwMzY=","name":"restoration-calculator-service","full_name":"companieshouse/restoration-calculator-service","private":false,"owner":{"login":"companieshouse","id":4947323,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ5NDczMjM=","avatar_url":"https://avatars0.githubusercontent.com/u/4947323?v=4","gravatar_id":"","url":"https://api.github.com/users/companieshouse","html_url":"https://github.com/companieshouse","followers_url":"https://api.github.com/users/companieshouse/followers","following_url":"https://api.github.com/users/companieshouse/following{/other_user}","gists_url":"https://api.github.com/users/companieshouse/gists{/gist_id}","starred_url":"https://api.github.com/users/companieshouse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/companieshouse/subscriptions","organizations_url":"https://api.github.com/users/companieshouse/orgs","repos_url":"https://api.github.com/users/companieshouse/repos","events_url":"https://api.github.com/users/companieshouse/events{/privacy}","received_events_url":"https://api.github.com/users/companieshouse/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/companieshouse/restoration-calculator-service","description":"The calculator used for the costs of restorations","fork":false,"url":"https://api.github.com/repos/companieshouse/restoration-calculator-service","forks_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/forks","keys_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/keys{/key_id}","collaborators_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/teams","hooks_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/hooks","issue_events_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/events{/number}","events_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/events","assignees_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/assignees{/user}","branches_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/branches{/branch}","tags_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/tags","blobs_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/refs{/sha}","trees_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/trees{/sha}","statuses_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/statuses/{sha}","languages_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/languages","stargazers_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/stargazers","contributors_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/contributors","subscribers_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/subscribers","subscription_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/subscription","commits_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/commits{/sha}","git_commits_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/git/commits{/sha}","comments_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/comments{/number}","issue_comment_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/comments{/number}","contents_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/contents/{+path}","compare_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/compare/{base}...{head}","merges_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/merges","archive_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/downloads","issues_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues{/number}","pulls_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls{/number}","milestones_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/milestones{/number}","notifications_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/labels{/name}","releases_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/releases{/id}","deployments_url":"https://api.github.com/repos/companieshouse/restoration-calculator-service/deployments","created_at":"2018-10-08T09:27:24Z","updated_at":"2018-10-17T10:57:32Z","pushed_at":"2018-10-18T08:01:24Z","git_url":"git://github.com/companieshouse/restoration-calculator-service.git","ssh_url":"git@github.com:companieshouse/restoration-calculator-service.git","clone_url":"https://github.com/companieshouse/restoration-calculator-service.git","svn_url":"https://github.com/companieshouse/restoration-calculator-service","homepage":null,"size":63,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11"},"html":{"href":"https://github.com/companieshouse/restoration-calculator-service/pull/11"},"issue":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/11"},"comments":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/companieshouse/restoration-calculator-service/statuses/8d882ed94e030eb577c5fd20e4871d31ba55297f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"markpit"}}