{"action":"created","comment":{"url":"https://api.github.com/repos/phenotips/phenotips/pulls/comments/35175099","id":35175099,"diff_hunk":"@@ -0,0 +1,154 @@\n+/*\n+ * See the NOTICE file distributed with this work for additional\n+ * information regarding copyright ownership.\n+ *\n+ * This program is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU Affero General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU Affero General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License\n+ * along with this program.  If not, see http://www.gnu.org/licenses/\n+ */\n+package org.phenotips.data.push.internal;\n+\n+import com.xpn.xwiki.XWikiContext;\n+import com.xpn.xwiki.XWiki;\n+import com.xpn.xwiki.XWikiException;\n+import com.xpn.xwiki.doc.XWikiDocument;\n+import com.xpn.xwiki.objects.BaseObject;\n+import org.apache.http.NameValuePair;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Rule;\n+import org.junit.Test;\n+import org.mockito.Matchers;\n+import org.mockito.Mock;\n+import org.mockito.MockitoAnnotations;\n+import org.phenotips.data.push.PushPatientData;\n+import org.xwiki.component.manager.ComponentLookupException;\n+import org.xwiki.context.Execution;\n+import org.xwiki.context.ExecutionContext;\n+import org.xwiki.model.reference.DocumentReference;\n+import org.xwiki.test.mockito.MockitoComponentMockingRule;\n+\n+import java.lang.reflect.InvocationTargetException;\n+import java.lang.reflect.Method;\n+import java.util.List;\n+\n+import static org.mockito.Mockito.when;\n+import static org.mockito.Mockito.verify;\n+\n+public class DefaultPushPatientDataTest {\n+\n+    @Rule\n+    public final MockitoComponentMockingRule<PushPatientData> mocker =\n+            new MockitoComponentMockingRule<PushPatientData>(DefaultPushPatientData.class);\n+\n+    @Mock\n+    private BaseObject serverConfiguration;\n+\n+    @Mock\n+    private List<NameValuePair> data;\n+\n+    @Mock\n+    private XWiki xWiki;\n+\n+    @Mock\n+    private XWikiContext xWikiContext;\n+\n+    @Mock\n+    private XWikiDocument xWikiDocument;\n+\n+    @Mock\n+    private ExecutionContext executionContext;\n+\n+    private Execution execution;\n+\n+    private DefaultPushPatientData patientData;\n+\n+    @Before\n+    public void setUp() throws ComponentLookupException\n+    {\n+        MockitoAnnotations.initMocks(this);\n+        this.patientData = (DefaultPushPatientData) this.mocker.getComponentUnderTest();\n+        this.execution = this.mocker.getInstance(Execution.class);\n+    }\n+\n+    @Test\n+    public void getBaseUrlReturnsCorrectString() throws ComponentLookupException, NoSuchMethodException, IllegalAccessException,\n+            InvocationTargetException {\n+        // set up access for the private method\n+        Method method = DefaultPushPatientData.class.getDeclaredMethod(\"getBaseURL\", BaseObject.class);\n+        method.setAccessible(true);\n+        // test null case\n+        Assert.assertNull(method.invoke(this.mocker.getComponentUnderTest(), serverConfiguration));\n+\n+        // test case when serverConfiguration gives http string\n+        when(serverConfiguration.getStringValue(\"url\")).thenReturn(\"http://\");\n+        Assert.assertEquals(method.invoke(this.mocker.getComponentUnderTest(), serverConfiguration),\n+                \"http:/bin/receivePatientData\");\n+\n+        when(serverConfiguration.getStringValue((\"url\"))).thenReturn(\"apples\");\n+        Assert.assertEquals(method.invoke(this.mocker.getComponentUnderTest(), serverConfiguration),\n+                \"http://apples/bin/receivePatientData\");\n+    }\n+\n+    @Test\n+    public void generateRequestDataTest() throws ComponentLookupException, NoSuchMethodException, IllegalAccessException,\n+            InvocationTargetException {\n+        // set up access for the private method\n+        Method method = DefaultPushPatientData.class.getDeclaredMethod(\"generateRequestData\",","path":"components/patient-data-sharing/push-api/src/test/java/org/phenotips/data/push/internal/DefaultPushPatientDataTest.java","position":106,"original_position":106,"commit_id":"05ac5f7d3e681ebd7518e2258f279f3d2e173859","original_commit_id":"05ac5f7d3e681ebd7518e2258f279f3d2e173859","user":{"login":"sdumitriu","id":88663,"avatar_url":"https://avatars.githubusercontent.com/u/88663?v=3","gravatar_id":"","url":"https://api.github.com/users/sdumitriu","html_url":"https://github.com/sdumitriu","followers_url":"https://api.github.com/users/sdumitriu/followers","following_url":"https://api.github.com/users/sdumitriu/following{/other_user}","gists_url":"https://api.github.com/users/sdumitriu/gists{/gist_id}","starred_url":"https://api.github.com/users/sdumitriu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdumitriu/subscriptions","organizations_url":"https://api.github.com/users/sdumitriu/orgs","repos_url":"https://api.github.com/users/sdumitriu/repos","events_url":"https://api.github.com/users/sdumitriu/events{/privacy}","received_events_url":"https://api.github.com/users/sdumitriu/received_events","type":"User","site_admin":false},"body":"In general, a component implements a role, which is the contract/specification that must be respected. A test class tests that specification, not the actual internals of the implementation. The mocks setup is all that the test may imply about the implementation.","created_at":"2015-07-22T02:04:56Z","updated_at":"2015-07-22T02:04:56Z","html_url":"https://github.com/phenotips/phenotips/pull/1705#discussion_r35175099","pull_request_url":"https://api.github.com/repos/phenotips/phenotips/pulls/1705","_links":{"self":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/comments/35175099"},"html":{"href":"https://github.com/phenotips/phenotips/pull/1705#discussion_r35175099"},"pull_request":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1705"}}},"pull_request":{"url":"https://api.github.com/repos/phenotips/phenotips/pulls/1705","id":36646135,"html_url":"https://github.com/phenotips/phenotips/pull/1705","diff_url":"https://github.com/phenotips/phenotips/pull/1705.diff","patch_url":"https://github.com/phenotips/phenotips/pull/1705.patch","issue_url":"https://api.github.com/repos/phenotips/phenotips/issues/1705","number":1705,"state":"open","locked":false,"title":"DefaultPushPatientData Tests","user":{"login":"JKereliuk","id":9435736,"avatar_url":"https://avatars.githubusercontent.com/u/9435736?v=3","gravatar_id":"","url":"https://api.github.com/users/JKereliuk","html_url":"https://github.com/JKereliuk","followers_url":"https://api.github.com/users/JKereliuk/followers","following_url":"https://api.github.com/users/JKereliuk/following{/other_user}","gists_url":"https://api.github.com/users/JKereliuk/gists{/gist_id}","starred_url":"https://api.github.com/users/JKereliuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JKereliuk/subscriptions","organizations_url":"https://api.github.com/users/JKereliuk/orgs","repos_url":"https://api.github.com/users/JKereliuk/repos","events_url":"https://api.github.com/users/JKereliuk/events{/privacy}","received_events_url":"https://api.github.com/users/JKereliuk/received_events","type":"User","site_admin":false},"body":"Tests for DefaultPushPatientDataTest","created_at":"2015-06-01T16:31:00Z","updated_at":"2015-07-22T02:04:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff309c06950343d3d7737768aad6492116068da5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/phenotips/phenotips/pulls/1705/commits","review_comments_url":"https://api.github.com/repos/phenotips/phenotips/pulls/1705/comments","review_comment_url":"https://api.github.com/repos/phenotips/phenotips/pulls/comments{/number}","comments_url":"https://api.github.com/repos/phenotips/phenotips/issues/1705/comments","statuses_url":"https://api.github.com/repos/phenotips/phenotips/statuses/05ac5f7d3e681ebd7518e2258f279f3d2e173859","head":{"label":"JKereliuk:push_api_tests","ref":"push_api_tests","sha":"05ac5f7d3e681ebd7518e2258f279f3d2e173859","user":{"login":"JKereliuk","id":9435736,"avatar_url":"https://avatars.githubusercontent.com/u/9435736?v=3","gravatar_id":"","url":"https://api.github.com/users/JKereliuk","html_url":"https://github.com/JKereliuk","followers_url":"https://api.github.com/users/JKereliuk/followers","following_url":"https://api.github.com/users/JKereliuk/following{/other_user}","gists_url":"https://api.github.com/users/JKereliuk/gists{/gist_id}","starred_url":"https://api.github.com/users/JKereliuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JKereliuk/subscriptions","organizations_url":"https://api.github.com/users/JKereliuk/orgs","repos_url":"https://api.github.com/users/JKereliuk/repos","events_url":"https://api.github.com/users/JKereliuk/events{/privacy}","received_events_url":"https://api.github.com/users/JKereliuk/received_events","type":"User","site_admin":false},"repo":{"id":36395377,"name":"phenotips","full_name":"JKereliuk/phenotips","owner":{"login":"JKereliuk","id":9435736,"avatar_url":"https://avatars.githubusercontent.com/u/9435736?v=3","gravatar_id":"","url":"https://api.github.com/users/JKereliuk","html_url":"https://github.com/JKereliuk","followers_url":"https://api.github.com/users/JKereliuk/followers","following_url":"https://api.github.com/users/JKereliuk/following{/other_user}","gists_url":"https://api.github.com/users/JKereliuk/gists{/gist_id}","starred_url":"https://api.github.com/users/JKereliuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JKereliuk/subscriptions","organizations_url":"https://api.github.com/users/JKereliuk/orgs","repos_url":"https://api.github.com/users/JKereliuk/repos","events_url":"https://api.github.com/users/JKereliuk/events{/privacy}","received_events_url":"https://api.github.com/users/JKereliuk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JKereliuk/phenotips","description":"PhenoTips provides an easy-to-use Web interface and standardized database back-end for collecting clinical findings observed in patients with possible genetic disorders.","fork":true,"url":"https://api.github.com/repos/JKereliuk/phenotips","forks_url":"https://api.github.com/repos/JKereliuk/phenotips/forks","keys_url":"https://api.github.com/repos/JKereliuk/phenotips/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JKereliuk/phenotips/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JKereliuk/phenotips/teams","hooks_url":"https://api.github.com/repos/JKereliuk/phenotips/hooks","issue_events_url":"https://api.github.com/repos/JKereliuk/phenotips/issues/events{/number}","events_url":"https://api.github.com/repos/JKereliuk/phenotips/events","assignees_url":"https://api.github.com/repos/JKereliuk/phenotips/assignees{/user}","branches_url":"https://api.github.com/repos/JKereliuk/phenotips/branches{/branch}","tags_url":"https://api.github.com/repos/JKereliuk/phenotips/tags","blobs_url":"https://api.github.com/repos/JKereliuk/phenotips/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JKereliuk/phenotips/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JKereliuk/phenotips/git/refs{/sha}","trees_url":"https://api.github.com/repos/JKereliuk/phenotips/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JKereliuk/phenotips/statuses/{sha}","languages_url":"https://api.github.com/repos/JKereliuk/phenotips/languages","stargazers_url":"https://api.github.com/repos/JKereliuk/phenotips/stargazers","contributors_url":"https://api.github.com/repos/JKereliuk/phenotips/contributors","subscribers_url":"https://api.github.com/repos/JKereliuk/phenotips/subscribers","subscription_url":"https://api.github.com/repos/JKereliuk/phenotips/subscription","commits_url":"https://api.github.com/repos/JKereliuk/phenotips/commits{/sha}","git_commits_url":"https://api.github.com/repos/JKereliuk/phenotips/git/commits{/sha}","comments_url":"https://api.github.com/repos/JKereliuk/phenotips/comments{/number}","issue_comment_url":"https://api.github.com/repos/JKereliuk/phenotips/issues/comments{/number}","contents_url":"https://api.github.com/repos/JKereliuk/phenotips/contents/{+path}","compare_url":"https://api.github.com/repos/JKereliuk/phenotips/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JKereliuk/phenotips/merges","archive_url":"https://api.github.com/repos/JKereliuk/phenotips/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JKereliuk/phenotips/downloads","issues_url":"https://api.github.com/repos/JKereliuk/phenotips/issues{/number}","pulls_url":"https://api.github.com/repos/JKereliuk/phenotips/pulls{/number}","milestones_url":"https://api.github.com/repos/JKereliuk/phenotips/milestones{/number}","notifications_url":"https://api.github.com/repos/JKereliuk/phenotips/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JKereliuk/phenotips/labels{/name}","releases_url":"https://api.github.com/repos/JKereliuk/phenotips/releases{/id}","created_at":"2015-05-27T20:56:39Z","updated_at":"2015-05-27T20:56:43Z","pushed_at":"2015-07-21T15:57:19Z","git_url":"git://github.com/JKereliuk/phenotips.git","ssh_url":"git@github.com:JKereliuk/phenotips.git","clone_url":"https://github.com/JKereliuk/phenotips.git","svn_url":"https://github.com/JKereliuk/phenotips","homepage":"http://phenotips.org/","size":378097,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"phenotips:master","ref":"master","sha":"fde53051de0a0365f2f950d903d42c84db269532","user":{"login":"phenotips","id":4872353,"avatar_url":"https://avatars.githubusercontent.com/u/4872353?v=3","gravatar_id":"","url":"https://api.github.com/users/phenotips","html_url":"https://github.com/phenotips","followers_url":"https://api.github.com/users/phenotips/followers","following_url":"https://api.github.com/users/phenotips/following{/other_user}","gists_url":"https://api.github.com/users/phenotips/gists{/gist_id}","starred_url":"https://api.github.com/users/phenotips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phenotips/subscriptions","organizations_url":"https://api.github.com/users/phenotips/orgs","repos_url":"https://api.github.com/users/phenotips/repos","events_url":"https://api.github.com/users/phenotips/events{/privacy}","received_events_url":"https://api.github.com/users/phenotips/received_events","type":"Organization","site_admin":false},"repo":{"id":2685841,"name":"phenotips","full_name":"phenotips/phenotips","owner":{"login":"phenotips","id":4872353,"avatar_url":"https://avatars.githubusercontent.com/u/4872353?v=3","gravatar_id":"","url":"https://api.github.com/users/phenotips","html_url":"https://github.com/phenotips","followers_url":"https://api.github.com/users/phenotips/followers","following_url":"https://api.github.com/users/phenotips/following{/other_user}","gists_url":"https://api.github.com/users/phenotips/gists{/gist_id}","starred_url":"https://api.github.com/users/phenotips/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phenotips/subscriptions","organizations_url":"https://api.github.com/users/phenotips/orgs","repos_url":"https://api.github.com/users/phenotips/repos","events_url":"https://api.github.com/users/phenotips/events{/privacy}","received_events_url":"https://api.github.com/users/phenotips/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phenotips/phenotips","description":"PhenoTips provides an easy-to-use Web interface and standardized database back-end for collecting clinical findings observed in patients with possible genetic disorders.","fork":false,"url":"https://api.github.com/repos/phenotips/phenotips","forks_url":"https://api.github.com/repos/phenotips/phenotips/forks","keys_url":"https://api.github.com/repos/phenotips/phenotips/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phenotips/phenotips/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phenotips/phenotips/teams","hooks_url":"https://api.github.com/repos/phenotips/phenotips/hooks","issue_events_url":"https://api.github.com/repos/phenotips/phenotips/issues/events{/number}","events_url":"https://api.github.com/repos/phenotips/phenotips/events","assignees_url":"https://api.github.com/repos/phenotips/phenotips/assignees{/user}","branches_url":"https://api.github.com/repos/phenotips/phenotips/branches{/branch}","tags_url":"https://api.github.com/repos/phenotips/phenotips/tags","blobs_url":"https://api.github.com/repos/phenotips/phenotips/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phenotips/phenotips/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phenotips/phenotips/git/refs{/sha}","trees_url":"https://api.github.com/repos/phenotips/phenotips/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phenotips/phenotips/statuses/{sha}","languages_url":"https://api.github.com/repos/phenotips/phenotips/languages","stargazers_url":"https://api.github.com/repos/phenotips/phenotips/stargazers","contributors_url":"https://api.github.com/repos/phenotips/phenotips/contributors","subscribers_url":"https://api.github.com/repos/phenotips/phenotips/subscribers","subscription_url":"https://api.github.com/repos/phenotips/phenotips/subscription","commits_url":"https://api.github.com/repos/phenotips/phenotips/commits{/sha}","git_commits_url":"https://api.github.com/repos/phenotips/phenotips/git/commits{/sha}","comments_url":"https://api.github.com/repos/phenotips/phenotips/comments{/number}","issue_comment_url":"https://api.github.com/repos/phenotips/phenotips/issues/comments{/number}","contents_url":"https://api.github.com/repos/phenotips/phenotips/contents/{+path}","compare_url":"https://api.github.com/repos/phenotips/phenotips/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phenotips/phenotips/merges","archive_url":"https://api.github.com/repos/phenotips/phenotips/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phenotips/phenotips/downloads","issues_url":"https://api.github.com/repos/phenotips/phenotips/issues{/number}","pulls_url":"https://api.github.com/repos/phenotips/phenotips/pulls{/number}","milestones_url":"https://api.github.com/repos/phenotips/phenotips/milestones{/number}","notifications_url":"https://api.github.com/repos/phenotips/phenotips/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phenotips/phenotips/labels{/name}","releases_url":"https://api.github.com/repos/phenotips/phenotips/releases{/id}","created_at":"2011-11-01T05:55:21Z","updated_at":"2015-07-10T08:01:10Z","pushed_at":"2015-07-21T21:08:27Z","git_url":"git://github.com/phenotips/phenotips.git","ssh_url":"git@github.com:phenotips/phenotips.git","clone_url":"https://github.com/phenotips/phenotips.git","svn_url":"https://github.com/phenotips/phenotips","homepage":"http://phenotips.org/","size":443215,"stargazers_count":16,"watchers_count":16,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":316,"forks":12,"open_issues":316,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1705"},"html":{"href":"https://github.com/phenotips/phenotips/pull/1705"},"issue":{"href":"https://api.github.com/repos/phenotips/phenotips/issues/1705"},"comments":{"href":"https://api.github.com/repos/phenotips/phenotips/issues/1705/comments"},"review_comments":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1705/comments"},"review_comment":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/phenotips/phenotips/pulls/1705/commits"},"statuses":{"href":"https://api.github.com/repos/phenotips/phenotips/statuses/05ac5f7d3e681ebd7518e2258f279f3d2e173859"}}}}