GitHub PullRequestReviewCommentEvent at 2014-10-20 18:41:44
Repository: fullcontact4j
Actor: McManCSU
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/comments/19104372","id":19104372,"diff_hunk":"@@ -1,12 +1,123 @@\n package com.fullcontact.api.libs.fullcontact4j;\n-import org.junit.Assert;\n+\n+import com.fullcontact.api.libs.fullcontact4j.config.Constants;\n+import com.fullcontact.api.libs.fullcontact4j.enums.RateLimiterPolicy;\n+import com.fullcontact.api.libs.fullcontact4j.request.FCCallback;\n+import com.fullcontact.api.libs.fullcontact4j.request.FCRequest;\n+import com.fullcontact.api.libs.fullcontact4j.request.PersonRequest;\n+import com.fullcontact.api.libs.fullcontact4j.request.RequestExecutorHandler;\n+import com.fullcontact.api.libs.fullcontact4j.response.FCResponse;\n+import com.fullcontact.api.libs.fullcontact4j.response.PersonResponse;\n+import com.squareup.okhttp.OkHttpClient;\n+import org.easymock.EasyMockSupport;\n import org.junit.Test;\n+import retrofit.client.OkClient;\n+\n+import java.util.UUID;\n+import java.util.concurrent.atomic.AtomicInteger;\n+\n+import static org.easymock.EasyMock.expect;\n+import static org.easymock.EasyMock.replay;\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.fail;\n+\n+public class FullContactClientTests extends EasyMockSupport {\n \n-public class FullContactClientTests {\n \n     @Test\n-    public void basicConfigurationTest() {\n-        FullContact client = FullContact.withApiKey(\"example-key\").build();\n-        Assert.assertTrue(client.httpInterface.apiKey.equals(\"example-key\"));\n+    //Assure the builder is returning the corresponding client\n+    public void clientBuilderTest() {\n+        String apiKey = \"example-key\";\n+        String baseUrl = \"not.fullcontact.com\";\n+        int maxThreads = 5;\n+\n+        FullContact client1 = new FullContact(new OkClient(new OkHttpClient()), apiKey, null, baseUrl, maxThreads);\n+        FullContact client2 = FullContact.withApiKey(apiKey)\n+                .baseUrl(baseUrl).threadCount(maxThreads).build();\n+        assertEquals(client1.httpInterface.apiKey, client2.httpInterface.apiKey);\n+        assertEquals(client1.httpInterface.getBaseUrl(), client2.httpInterface.getBaseUrl());\n+    }\n+\n+\n+    @Test\n+    //Tests to make sure that there aren't any funny async / race stuff that would mismatch requests from their response\n+    //counterparts\n+    public void asyncTest() throws Exception {\n+        FullContact client = FullContact.withApiKey(\"bad-api-key\").build();\n+        client.httpInterface.setRequestExecutorHandler(new MockRequestHandler(RateLimiterPolicy.SMOOTH, 1));\n+        //this is not a good method but will properly test\n+        final AtomicInteger replies = new AtomicInteger(0);\n+\n+        //async\n+        for(int i = 0; i != 75; i++) {\n+            final PersonRequest req = client.buildPersonRequest().email(UUID.randomUUID().toString()).build();\n+            client.sendRequest(req, new FCCallback<PersonResponse>() {\n+                @Override\n+                public void success(PersonResponse response) {\n+                    replies.addAndGet(1);\n+                    String reqID = response.getRequestId();\n+                    if(!reqID.equals(req.getParam(Constants.PARAM_PERSON_EMAIL))) {\n+                        replies.set(-1);\n+                    }\n+                }\n+\n+                @Override\n+                public void failure(FullContactException exception) {\n+                    fail(exception.getMessage());\n+                }\n+            });\n+        }\n+\n+        //sync\n+        for(int i = 0; i != 75; i++) {\n+            final PersonRequest req = client.buildPersonRequest().email(UUID.randomUUID().toString()).build();\n+            String reqID = client.sendRequest(req).getRequestId();\n+            if(!reqID.equals(req.getParam(Constants.PARAM_PERSON_EMAIL))) {\n+                replies.set(-1);\n+            } else {\n+                replies.addAndGet(1);\n+            }\n+        }\n+\n+        while(replies.get() != 150) {\n+            if(replies.get() == -1) {\n+                fail(\"Not all email responses matched their request counterparts\");\n+            }\n+            Thread.sleep(50);","path":"src/test/java/com/fullcontact/api/libs/fullcontact4j/FullContactClientTests.java","position":91,"original_position":91,"commit_id":"df4cdfec13e501593e7b8e4ea4bab80fe1d20324","original_commit_id":"df4cdfec13e501593e7b8e4ea4bab80fe1d20324","user":{"login":"McManCSU","id":2625035,"avatar_url":"https://avatars.githubusercontent.com/u/2625035?v=2","gravatar_id":"","url":"https://api.github.com/users/McManCSU","html_url":"https://github.com/McManCSU","followers_url":"https://api.github.com/users/McManCSU/followers","following_url":"https://api.github.com/users/McManCSU/following{/other_user}","gists_url":"https://api.github.com/users/McManCSU/gists{/gist_id}","starred_url":"https://api.github.com/users/McManCSU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/McManCSU/subscriptions","organizations_url":"https://api.github.com/users/McManCSU/orgs","repos_url":"https://api.github.com/users/McManCSU/repos","events_url":"https://api.github.com/users/McManCSU/events{/privacy}","received_events_url":"https://api.github.com/users/McManCSU/received_events","type":"User","site_admin":false},"body":"In general, Thread.sleep should never used in unit tests since it adds a lot of variability to the pass/fail rate of tests. Even if we are simply waiting between counts.  Further, let's brainstorm a different way to handle the aggregation of the results vs. while loop polling.","created_at":"2014-10-20T18:41:44Z","updated_at":"2014-10-20T18:41:44Z","html_url":"https://github.com/fullcontact/fullcontact4j/pull/10#discussion_r19104372","pull_request_url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/comments/19104372"},"html":{"href":"https://github.com/fullcontact/fullcontact4j/pull/10#discussion_r19104372"},"pull_request":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10","id":23032376,"html_url":"https://github.com/fullcontact/fullcontact4j/pull/10","diff_url":"https://github.com/fullcontact/fullcontact4j/pull/10.diff","patch_url":"https://github.com/fullcontact/fullcontact4j/pull/10.patch","issue_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/10","number":10,"state":"open","locked":false,"title":"Version2 working","user":{"login":"ParisMi","id":8468718,"avatar_url":"https://avatars.githubusercontent.com/u/8468718?v=2","gravatar_id":"","url":"https://api.github.com/users/ParisMi","html_url":"https://github.com/ParisMi","followers_url":"https://api.github.com/users/ParisMi/followers","following_url":"https://api.github.com/users/ParisMi/following{/other_user}","gists_url":"https://api.github.com/users/ParisMi/gists{/gist_id}","starred_url":"https://api.github.com/users/ParisMi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ParisMi/subscriptions","organizations_url":"https://api.github.com/users/ParisMi/orgs","repos_url":"https://api.github.com/users/ParisMi/repos","events_url":"https://api.github.com/users/ParisMi/events{/privacy}","received_events_url":"https://api.github.com/users/ParisMi/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-10-20T17:54:12Z","updated_at":"2014-10-20T18:41:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77a7543d8899c24b728317f82338f1f3b38a5807","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10/commits","review_comments_url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10/comments","review_comment_url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/comments/{number}","comments_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/10/comments","statuses_url":"https://api.github.com/repos/fullcontact/fullcontact4j/statuses/df4cdfec13e501593e7b8e4ea4bab80fe1d20324","head":{"label":"fullcontact:version2-working","ref":"version2-working","sha":"df4cdfec13e501593e7b8e4ea4bab80fe1d20324","user":{"login":"fullcontact","id":792175,"avatar_url":"https://avatars.githubusercontent.com/u/792175?v=2","gravatar_id":"","url":"https://api.github.com/users/fullcontact","html_url":"https://github.com/fullcontact","followers_url":"https://api.github.com/users/fullcontact/followers","following_url":"https://api.github.com/users/fullcontact/following{/other_user}","gists_url":"https://api.github.com/users/fullcontact/gists{/gist_id}","starred_url":"https://api.github.com/users/fullcontact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullcontact/subscriptions","organizations_url":"https://api.github.com/users/fullcontact/orgs","repos_url":"https://api.github.com/users/fullcontact/repos","events_url":"https://api.github.com/users/fullcontact/events{/privacy}","received_events_url":"https://api.github.com/users/fullcontact/received_events","type":"Organization","site_admin":false},"repo":{"id":3382859,"name":"fullcontact4j","full_name":"fullcontact/fullcontact4j","owner":{"login":"fullcontact","id":792175,"avatar_url":"https://avatars.githubusercontent.com/u/792175?v=2","gravatar_id":"","url":"https://api.github.com/users/fullcontact","html_url":"https://github.com/fullcontact","followers_url":"https://api.github.com/users/fullcontact/followers","following_url":"https://api.github.com/users/fullcontact/following{/other_user}","gists_url":"https://api.github.com/users/fullcontact/gists{/gist_id}","starred_url":"https://api.github.com/users/fullcontact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullcontact/subscriptions","organizations_url":"https://api.github.com/users/fullcontact/orgs","repos_url":"https://api.github.com/users/fullcontact/repos","events_url":"https://api.github.com/users/fullcontact/events{/privacy}","received_events_url":"https://api.github.com/users/fullcontact/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fullcontact/fullcontact4j","description":"A Java client for the FullContact API","fork":false,"url":"https://api.github.com/repos/fullcontact/fullcontact4j","forks_url":"https://api.github.com/repos/fullcontact/fullcontact4j/forks","keys_url":"https://api.github.com/repos/fullcontact/fullcontact4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fullcontact/fullcontact4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fullcontact/fullcontact4j/teams","hooks_url":"https://api.github.com/repos/fullcontact/fullcontact4j/hooks","issue_events_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/events{/number}","events_url":"https://api.github.com/repos/fullcontact/fullcontact4j/events","assignees_url":"https://api.github.com/repos/fullcontact/fullcontact4j/assignees{/user}","branches_url":"https://api.github.com/repos/fullcontact/fullcontact4j/branches{/branch}","tags_url":"https://api.github.com/repos/fullcontact/fullcontact4j/tags","blobs_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fullcontact/fullcontact4j/statuses/{sha}","languages_url":"https://api.github.com/repos/fullcontact/fullcontact4j/languages","stargazers_url":"https://api.github.com/repos/fullcontact/fullcontact4j/stargazers","contributors_url":"https://api.github.com/repos/fullcontact/fullcontact4j/contributors","subscribers_url":"https://api.github.com/repos/fullcontact/fullcontact4j/subscribers","subscription_url":"https://api.github.com/repos/fullcontact/fullcontact4j/subscription","commits_url":"https://api.github.com/repos/fullcontact/fullcontact4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/fullcontact/fullcontact4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/comments/{number}","contents_url":"https://api.github.com/repos/fullcontact/fullcontact4j/contents/{+path}","compare_url":"https://api.github.com/repos/fullcontact/fullcontact4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fullcontact/fullcontact4j/merges","archive_url":"https://api.github.com/repos/fullcontact/fullcontact4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fullcontact/fullcontact4j/downloads","issues_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues{/number}","pulls_url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls{/number}","milestones_url":"https://api.github.com/repos/fullcontact/fullcontact4j/milestones{/number}","notifications_url":"https://api.github.com/repos/fullcontact/fullcontact4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fullcontact/fullcontact4j/labels{/name}","releases_url":"https://api.github.com/repos/fullcontact/fullcontact4j/releases{/id}","created_at":"2012-02-08T00:27:57Z","updated_at":"2014-08-01T20:39:54Z","pushed_at":"2014-10-20T17:51:10Z","git_url":"git://github.com/fullcontact/fullcontact4j.git","ssh_url":"git@github.com:fullcontact/fullcontact4j.git","clone_url":"https://github.com/fullcontact/fullcontact4j.git","svn_url":"https://github.com/fullcontact/fullcontact4j","homepage":"","size":1043,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"fullcontact:version2","ref":"version2","sha":"49b567ec0d30e8ed7ef03ec930451055e475385d","user":{"login":"fullcontact","id":792175,"avatar_url":"https://avatars.githubusercontent.com/u/792175?v=2","gravatar_id":"","url":"https://api.github.com/users/fullcontact","html_url":"https://github.com/fullcontact","followers_url":"https://api.github.com/users/fullcontact/followers","following_url":"https://api.github.com/users/fullcontact/following{/other_user}","gists_url":"https://api.github.com/users/fullcontact/gists{/gist_id}","starred_url":"https://api.github.com/users/fullcontact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullcontact/subscriptions","organizations_url":"https://api.github.com/users/fullcontact/orgs","repos_url":"https://api.github.com/users/fullcontact/repos","events_url":"https://api.github.com/users/fullcontact/events{/privacy}","received_events_url":"https://api.github.com/users/fullcontact/received_events","type":"Organization","site_admin":false},"repo":{"id":3382859,"name":"fullcontact4j","full_name":"fullcontact/fullcontact4j","owner":{"login":"fullcontact","id":792175,"avatar_url":"https://avatars.githubusercontent.com/u/792175?v=2","gravatar_id":"","url":"https://api.github.com/users/fullcontact","html_url":"https://github.com/fullcontact","followers_url":"https://api.github.com/users/fullcontact/followers","following_url":"https://api.github.com/users/fullcontact/following{/other_user}","gists_url":"https://api.github.com/users/fullcontact/gists{/gist_id}","starred_url":"https://api.github.com/users/fullcontact/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullcontact/subscriptions","organizations_url":"https://api.github.com/users/fullcontact/orgs","repos_url":"https://api.github.com/users/fullcontact/repos","events_url":"https://api.github.com/users/fullcontact/events{/privacy}","received_events_url":"https://api.github.com/users/fullcontact/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fullcontact/fullcontact4j","description":"A Java client for the FullContact API","fork":false,"url":"https://api.github.com/repos/fullcontact/fullcontact4j","forks_url":"https://api.github.com/repos/fullcontact/fullcontact4j/forks","keys_url":"https://api.github.com/repos/fullcontact/fullcontact4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fullcontact/fullcontact4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fullcontact/fullcontact4j/teams","hooks_url":"https://api.github.com/repos/fullcontact/fullcontact4j/hooks","issue_events_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/events{/number}","events_url":"https://api.github.com/repos/fullcontact/fullcontact4j/events","assignees_url":"https://api.github.com/repos/fullcontact/fullcontact4j/assignees{/user}","branches_url":"https://api.github.com/repos/fullcontact/fullcontact4j/branches{/branch}","tags_url":"https://api.github.com/repos/fullcontact/fullcontact4j/tags","blobs_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fullcontact/fullcontact4j/statuses/{sha}","languages_url":"https://api.github.com/repos/fullcontact/fullcontact4j/languages","stargazers_url":"https://api.github.com/repos/fullcontact/fullcontact4j/stargazers","contributors_url":"https://api.github.com/repos/fullcontact/fullcontact4j/contributors","subscribers_url":"https://api.github.com/repos/fullcontact/fullcontact4j/subscribers","subscription_url":"https://api.github.com/repos/fullcontact/fullcontact4j/subscription","commits_url":"https://api.github.com/repos/fullcontact/fullcontact4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/fullcontact/fullcontact4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/fullcontact/fullcontact4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/comments/{number}","contents_url":"https://api.github.com/repos/fullcontact/fullcontact4j/contents/{+path}","compare_url":"https://api.github.com/repos/fullcontact/fullcontact4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fullcontact/fullcontact4j/merges","archive_url":"https://api.github.com/repos/fullcontact/fullcontact4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fullcontact/fullcontact4j/downloads","issues_url":"https://api.github.com/repos/fullcontact/fullcontact4j/issues{/number}","pulls_url":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls{/number}","milestones_url":"https://api.github.com/repos/fullcontact/fullcontact4j/milestones{/number}","notifications_url":"https://api.github.com/repos/fullcontact/fullcontact4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fullcontact/fullcontact4j/labels{/name}","releases_url":"https://api.github.com/repos/fullcontact/fullcontact4j/releases{/id}","created_at":"2012-02-08T00:27:57Z","updated_at":"2014-08-01T20:39:54Z","pushed_at":"2014-10-20T17:51:10Z","git_url":"git://github.com/fullcontact/fullcontact4j.git","ssh_url":"git@github.com:fullcontact/fullcontact4j.git","clone_url":"https://github.com/fullcontact/fullcontact4j.git","svn_url":"https://github.com/fullcontact/fullcontact4j","homepage":"","size":1043,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":2,"forks":7,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10"},"html":{"href":"https://github.com/fullcontact/fullcontact4j/pull/10"},"issue":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/10"},"comments":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/fullcontact/fullcontact4j/statuses/df4cdfec13e501593e7b8e4ea4bab80fe1d20324"}}}}