{"action":"created","comment":{"url":"https://api.github.com/repos/osmlab/atlas-checks/pulls/comments/165763519","pull_request_review_id":93760003,"id":165763519,"diff_hunk":"@@ -0,0 +1,98 @@\n+# Writing Unit Tests for Altas Checks\n+\n+It is important to make sure your code works as expected as well as making sure that any changes you make don't break existing changes. A good approach to developing integrity checks is using a [Test Driven Development](https://en.wikipedia.org/wiki/Test-driven_development) based approach. In a nutshell design your unit tests first and then build your check making sure that the tests that you originally built succeeds. \n+\n+### Example Unit Test\n+\n+For real examples you can look a couple that have already been built for the currently implemented checks:\n+\n+- [SinkIslandCheckTest](../src/test/java/org/openstreetmap/atlas/checks/validation/linear/edges/SinkIslandCheckTest.java) and [SinkIslandCheckTestRule](../src/test/java/org/openstreetmap/atlas/checks/validation/linear/edges/SinkIslandCheckTestRule.java)\n+- [AbbreviatedNameCheckTest](../src/test/java/org/openstreetmap/atlas/checks/validation/tag/AbbreviatedNameCheckTest.java) and [AbbreviatedNameCheckTestRule](../src/test/java/org/openstreetmap/atlas/checks/validation/tag/AbbreviatedNameCheckTestRule.java)\n+\n+As you see in the above their are two files associated with the unit tests. The first file are the unit tests themselves, the second file is, for lack of a better term, test Atlas files. Below we will first describe the structure of a unit test to be used to validate your Atlas Check and then describe how the data file is built and how to generate test atlas'.\n+\n+### Our First Unit Test\n+\n+```java\n+public class MyUnitTest {\n+    // For now we will assume that there is a class called MyUnitTestRule with a test atlas inside called \"testAtlas\"\n+    @Rule\n+    public MyUnitTestRule setup = new MyUnitTestRule();\n+\n+    @Rule\n+    public ConsumerBasedExpectedCheckVerifier verifier = new ConsumerBasedExpectedCheckVerifier();\n+\n+    @Test\n+    public void testMyUnitTest()\n+    {\n+        // MyCheck would be replaced with the name of the check that you are testing\n+        // The configuration is optional, and only required if you have specific configuration for the check that you want to test or is required for the check itself\n+        this.verifier.actual(this.setup.testAtlas(),\n+                new MyCheck(ConfigurationResolver.inlineConfiguration(\"{\\\"key\\\":\\\"value\\\"}\")));\n+        // There are various helper functions described below, this one simply checks if the result of the check on the test atlas produces at least 1 flag.\n+        this.verifier.verifyNotEmpty();\n+        \n+        // Another common scenario would be to loop through the results and check something on it.\n+        this.verifier.verify(flag -> {\n+            // Check the flag object for some expected values\n+        });\n+    }   \n+}\n+```\n+\n+A basic Atlas-Checks unit test contains 3 things:\n+1. A TestRule class that is essentially and atlas or multiple atlas to test against.\n+2. A `ConsumerBasedExpectedCheckVerifier` instance that will execute the check you are testing against the test atlas.\n+3. A series of units test using the JUnit framework.\n+\n+### The `ConsumerBasedExpectedCheckVerifier`\n+\n+The ConsumerBasedExpectedCheckVerifier is a class that will run your check against a test atlas. The test atlas are often very small atlas objects that contain specific data to test against. This verifier has too main types of functions\n+\n+1. `actual(Atlas, BaseCheck)` - The actual method establishes what data to run against (ie. what atlas file) and what check to run against the provided test atlas.\n+2. verify functions - The verify functions will be used to verify the results of the running the check over the test atlas file. Below are some useful functions\n+    \n+    - `verifyNotEmpty()` - Verifies that at least 1 flag was produced by the check\n+    - `verifyEmpty()` - Verifies that no flags were produced by the check\n+    - `verifyExpectedSize(int)` - Verifies that a specific number of flags were produced by the check\n+    - `verify(Consumer<List<CheckFlag>>)` - A custom verifier allowing the developer to loop through each individual flag that is produced and verify it in any way that the developer wishes.\n+    \n+ ### The `TestRule`\n+ \n+ As mentioned previously the TestRule is a class that is associated with the Unit test class and contains all the test data, which would essentially be an Atlas in some form or another. An Atlas can be created in 2 primary ways:","path":"docs/unit_tests.md","position":62,"original_position":62,"commit_id":"2c9fed5b91dd56d5dbd62a33b52c7311f46bae58","original_commit_id":"2c9fed5b91dd56d5dbd62a33b52c7311f46bae58","user":{"login":"MikeGost","id":18317260,"avatar_url":"https://avatars3.githubusercontent.com/u/18317260?v=4","gravatar_id":"","url":"https://api.github.com/users/MikeGost","html_url":"https://github.com/MikeGost","followers_url":"https://api.github.com/users/MikeGost/followers","following_url":"https://api.github.com/users/MikeGost/following{/other_user}","gists_url":"https://api.github.com/users/MikeGost/gists{/gist_id}","starred_url":"https://api.github.com/users/MikeGost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikeGost/subscriptions","organizations_url":"https://api.github.com/users/MikeGost/orgs","repos_url":"https://api.github.com/users/MikeGost/repos","events_url":"https://api.github.com/users/MikeGost/events{/privacy}","received_events_url":"https://api.github.com/users/MikeGost/received_events","type":"User","site_admin":false},"body":"There is a task to revamp the atlas documentation around testing, once that's done, we can link it here.","created_at":"2018-02-02T21:22:56Z","updated_at":"2018-02-02T21:24:46Z","html_url":"https://github.com/osmlab/atlas-checks/pull/19#discussion_r165763519","pull_request_url":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/osmlab/atlas-checks/pulls/comments/165763519"},"html":{"href":"https://github.com/osmlab/atlas-checks/pull/19#discussion_r165763519"},"pull_request":{"href":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19"}},"in_reply_to_id":165763382},"pull_request":{"url":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19","id":166890798,"html_url":"https://github.com/osmlab/atlas-checks/pull/19","diff_url":"https://github.com/osmlab/atlas-checks/pull/19.diff","patch_url":"https://github.com/osmlab/atlas-checks/pull/19.patch","issue_url":"https://api.github.com/repos/osmlab/atlas-checks/issues/19","number":19,"state":"open","locked":false,"title":"Adding new SignPostCheck and IntersectingBuildingsCheck. Also updatin…","user":{"login":"mgcuthbert","id":558045,"avatar_url":"https://avatars3.githubusercontent.com/u/558045?v=4","gravatar_id":"","url":"https://api.github.com/users/mgcuthbert","html_url":"https://github.com/mgcuthbert","followers_url":"https://api.github.com/users/mgcuthbert/followers","following_url":"https://api.github.com/users/mgcuthbert/following{/other_user}","gists_url":"https://api.github.com/users/mgcuthbert/gists{/gist_id}","starred_url":"https://api.github.com/users/mgcuthbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgcuthbert/subscriptions","organizations_url":"https://api.github.com/users/mgcuthbert/orgs","repos_url":"https://api.github.com/users/mgcuthbert/repos","events_url":"https://api.github.com/users/mgcuthbert/events{/privacy}","received_events_url":"https://api.github.com/users/mgcuthbert/received_events","type":"User","site_admin":false},"body":"…g MapRoulette functions to allow the use of tags when creating challenges. Updating documents to describe how to develop and debug Atlas-Checks.\r\n\r\nSignPostCheck will check is to help identify segments that are missing the proper tagging for sign posts. \r\n\r\nIntersectingBuildingsCheck will, much as the name indicates, flag buildings that intersect with each other.\r\n\r\nThe documentation includes how to debug Checks that you create, as well has help for writing unit tests for you your newly created Checks.","created_at":"2018-02-02T20:00:21Z","updated_at":"2018-02-02T21:24:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"445ce3707d8c905a2a5ca53b5f2d057cb5cfc4df","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19/commits","review_comments_url":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19/comments","review_comment_url":"https://api.github.com/repos/osmlab/atlas-checks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/osmlab/atlas-checks/issues/19/comments","statuses_url":"https://api.github.com/repos/osmlab/atlas-checks/statuses/2c9fed5b91dd56d5dbd62a33b52c7311f46bae58","head":{"label":"mgcuthbert:dev","ref":"dev","sha":"2c9fed5b91dd56d5dbd62a33b52c7311f46bae58","user":{"login":"mgcuthbert","id":558045,"avatar_url":"https://avatars3.githubusercontent.com/u/558045?v=4","gravatar_id":"","url":"https://api.github.com/users/mgcuthbert","html_url":"https://github.com/mgcuthbert","followers_url":"https://api.github.com/users/mgcuthbert/followers","following_url":"https://api.github.com/users/mgcuthbert/following{/other_user}","gists_url":"https://api.github.com/users/mgcuthbert/gists{/gist_id}","starred_url":"https://api.github.com/users/mgcuthbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgcuthbert/subscriptions","organizations_url":"https://api.github.com/users/mgcuthbert/orgs","repos_url":"https://api.github.com/users/mgcuthbert/repos","events_url":"https://api.github.com/users/mgcuthbert/events{/privacy}","received_events_url":"https://api.github.com/users/mgcuthbert/received_events","type":"User","site_admin":false},"repo":{"id":99823141,"name":"atlas-checks","full_name":"mgcuthbert/atlas-checks","owner":{"login":"mgcuthbert","id":558045,"avatar_url":"https://avatars3.githubusercontent.com/u/558045?v=4","gravatar_id":"","url":"https://api.github.com/users/mgcuthbert","html_url":"https://github.com/mgcuthbert","followers_url":"https://api.github.com/users/mgcuthbert/followers","following_url":"https://api.github.com/users/mgcuthbert/following{/other_user}","gists_url":"https://api.github.com/users/mgcuthbert/gists{/gist_id}","starred_url":"https://api.github.com/users/mgcuthbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgcuthbert/subscriptions","organizations_url":"https://api.github.com/users/mgcuthbert/orgs","repos_url":"https://api.github.com/users/mgcuthbert/repos","events_url":"https://api.github.com/users/mgcuthbert/events{/privacy}","received_events_url":"https://api.github.com/users/mgcuthbert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mgcuthbert/atlas-checks","description":"OSM data integrity checks with Atlas","fork":true,"url":"https://api.github.com/repos/mgcuthbert/atlas-checks","forks_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/forks","keys_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/teams","hooks_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/hooks","issue_events_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/issues/events{/number}","events_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/events","assignees_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/assignees{/user}","branches_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/branches{/branch}","tags_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/tags","blobs_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/git/refs{/sha}","trees_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/statuses/{sha}","languages_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/languages","stargazers_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/stargazers","contributors_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/contributors","subscribers_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/subscribers","subscription_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/subscription","commits_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/commits{/sha}","git_commits_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/git/commits{/sha}","comments_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/comments{/number}","issue_comment_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/issues/comments{/number}","contents_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/contents/{+path}","compare_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/merges","archive_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/downloads","issues_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/issues{/number}","pulls_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/pulls{/number}","milestones_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/milestones{/number}","notifications_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/labels{/name}","releases_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/releases{/id}","deployments_url":"https://api.github.com/repos/mgcuthbert/atlas-checks/deployments","created_at":"2017-08-09T15:22:21Z","updated_at":"2017-08-09T15:22:23Z","pushed_at":"2018-02-02T19:57:20Z","git_url":"git://github.com/mgcuthbert/atlas-checks.git","ssh_url":"git@github.com:mgcuthbert/atlas-checks.git","clone_url":"https://github.com/mgcuthbert/atlas-checks.git","svn_url":"https://github.com/mgcuthbert/atlas-checks","homepage":null,"size":12684,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"osmlab:dev","ref":"dev","sha":"0bcb65cb37def84a1278c8ce5c36daff120fd969","user":{"login":"osmlab","id":3856374,"avatar_url":"https://avatars3.githubusercontent.com/u/3856374?v=4","gravatar_id":"","url":"https://api.github.com/users/osmlab","html_url":"https://github.com/osmlab","followers_url":"https://api.github.com/users/osmlab/followers","following_url":"https://api.github.com/users/osmlab/following{/other_user}","gists_url":"https://api.github.com/users/osmlab/gists{/gist_id}","starred_url":"https://api.github.com/users/osmlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osmlab/subscriptions","organizations_url":"https://api.github.com/users/osmlab/orgs","repos_url":"https://api.github.com/users/osmlab/repos","events_url":"https://api.github.com/users/osmlab/events{/privacy}","received_events_url":"https://api.github.com/users/osmlab/received_events","type":"Organization","site_admin":false},"repo":{"id":99742504,"name":"atlas-checks","full_name":"osmlab/atlas-checks","owner":{"login":"osmlab","id":3856374,"avatar_url":"https://avatars3.githubusercontent.com/u/3856374?v=4","gravatar_id":"","url":"https://api.github.com/users/osmlab","html_url":"https://github.com/osmlab","followers_url":"https://api.github.com/users/osmlab/followers","following_url":"https://api.github.com/users/osmlab/following{/other_user}","gists_url":"https://api.github.com/users/osmlab/gists{/gist_id}","starred_url":"https://api.github.com/users/osmlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osmlab/subscriptions","organizations_url":"https://api.github.com/users/osmlab/orgs","repos_url":"https://api.github.com/users/osmlab/repos","events_url":"https://api.github.com/users/osmlab/events{/privacy}","received_events_url":"https://api.github.com/users/osmlab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/osmlab/atlas-checks","description":"OSM data integrity checks with Atlas","fork":false,"url":"https://api.github.com/repos/osmlab/atlas-checks","forks_url":"https://api.github.com/repos/osmlab/atlas-checks/forks","keys_url":"https://api.github.com/repos/osmlab/atlas-checks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/osmlab/atlas-checks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/osmlab/atlas-checks/teams","hooks_url":"https://api.github.com/repos/osmlab/atlas-checks/hooks","issue_events_url":"https://api.github.com/repos/osmlab/atlas-checks/issues/events{/number}","events_url":"https://api.github.com/repos/osmlab/atlas-checks/events","assignees_url":"https://api.github.com/repos/osmlab/atlas-checks/assignees{/user}","branches_url":"https://api.github.com/repos/osmlab/atlas-checks/branches{/branch}","tags_url":"https://api.github.com/repos/osmlab/atlas-checks/tags","blobs_url":"https://api.github.com/repos/osmlab/atlas-checks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/osmlab/atlas-checks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/osmlab/atlas-checks/git/refs{/sha}","trees_url":"https://api.github.com/repos/osmlab/atlas-checks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/osmlab/atlas-checks/statuses/{sha}","languages_url":"https://api.github.com/repos/osmlab/atlas-checks/languages","stargazers_url":"https://api.github.com/repos/osmlab/atlas-checks/stargazers","contributors_url":"https://api.github.com/repos/osmlab/atlas-checks/contributors","subscribers_url":"https://api.github.com/repos/osmlab/atlas-checks/subscribers","subscription_url":"https://api.github.com/repos/osmlab/atlas-checks/subscription","commits_url":"https://api.github.com/repos/osmlab/atlas-checks/commits{/sha}","git_commits_url":"https://api.github.com/repos/osmlab/atlas-checks/git/commits{/sha}","comments_url":"https://api.github.com/repos/osmlab/atlas-checks/comments{/number}","issue_comment_url":"https://api.github.com/repos/osmlab/atlas-checks/issues/comments{/number}","contents_url":"https://api.github.com/repos/osmlab/atlas-checks/contents/{+path}","compare_url":"https://api.github.com/repos/osmlab/atlas-checks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/osmlab/atlas-checks/merges","archive_url":"https://api.github.com/repos/osmlab/atlas-checks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/osmlab/atlas-checks/downloads","issues_url":"https://api.github.com/repos/osmlab/atlas-checks/issues{/number}","pulls_url":"https://api.github.com/repos/osmlab/atlas-checks/pulls{/number}","milestones_url":"https://api.github.com/repos/osmlab/atlas-checks/milestones{/number}","notifications_url":"https://api.github.com/repos/osmlab/atlas-checks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/osmlab/atlas-checks/labels{/name}","releases_url":"https://api.github.com/repos/osmlab/atlas-checks/releases{/id}","deployments_url":"https://api.github.com/repos/osmlab/atlas-checks/deployments","created_at":"2017-08-08T22:46:46Z","updated_at":"2018-02-01T23:27:56Z","pushed_at":"2018-02-02T20:00:23Z","git_url":"git://github.com/osmlab/atlas-checks.git","ssh_url":"git@github.com:osmlab/atlas-checks.git","clone_url":"https://github.com/osmlab/atlas-checks.git","svn_url":"https://github.com/osmlab/atlas-checks","homepage":null,"size":12667,"stargazers_count":18,"watchers_count":18,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":8,"open_issues":1,"watchers":18,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19"},"html":{"href":"https://github.com/osmlab/atlas-checks/pull/19"},"issue":{"href":"https://api.github.com/repos/osmlab/atlas-checks/issues/19"},"comments":{"href":"https://api.github.com/repos/osmlab/atlas-checks/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/osmlab/atlas-checks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/osmlab/atlas-checks/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/osmlab/atlas-checks/statuses/2c9fed5b91dd56d5dbd62a33b52c7311f46bae58"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"MikeGost"}}