{"action":"created","comment":{"url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/comments/27151838","id":27151838,"diff_hunk":"@@ -0,0 +1,118 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.apache.streams.mongo.test;\n+\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import com.github.fakemongo.Fongo;\n+import com.mongodb.DB;\n+import com.mongodb.DBAddress;\n+import com.mongodb.MongoClient;\n+import org.apache.commons.io.Charsets;\n+import org.apache.commons.io.IOUtils;\n+import org.apache.streams.core.StreamsDatum;\n+import org.apache.streams.core.StreamsResultSet;\n+import org.apache.streams.jackson.StreamsJacksonMapper;\n+import org.apache.streams.mongo.MongoConfiguration;\n+import org.apache.streams.mongo.MongoPersistReader;\n+import org.apache.streams.mongo.MongoPersistWriter;\n+import org.apache.streams.pojo.json.Activity;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.mockito.Mockito;\n+import org.powermock.api.mockito.PowerMockito;\n+import org.powermock.core.classloader.annotations.PrepareForTest;\n+import org.powermock.modules.junit4.PowerMockRunner;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.io.InputStream;\n+import java.util.List;\n+\n+/**\n+ * Test copying documents between two indexes on same cluster\n+ */\n+@RunWith(PowerMockRunner.class)\n+@PrepareForTest({MongoPersistReader.class, MongoPersistWriter.class, MongoClient.class, DB.class})\n+public class TestMongoPersist {\n+\n+    private final static Logger LOGGER = LoggerFactory.getLogger(TestMongoPersist.class);\n+\n+    ObjectMapper MAPPER = StreamsJacksonMapper.getInstance();\n+\n+    MongoClient mockClient;\n+\n+    Fongo fongo;\n+    DB mockDB;\n+\n+    int count = 0;\n+\n+    @Before\n+    public void setup() {\n+        fongo = new Fongo(\"testmongo\");\n+        mockDB = fongo.getDB(\"test\");\n+\n+        this.mockClient = PowerMockito.mock(MongoClient.class);\n+\n+        PowerMockito.when(mockClient.getDB(Mockito.anyString()))\n+                .thenReturn(mockDB);\n+\n+        try {\n+            PowerMockito.whenNew(MongoClient.class).withAnyArguments().thenReturn(mockClient);\n+        } catch (Exception e) {}\n+\n+    }\n+\n+    @Test\n+    public void testMongoPersist() throws Exception {\n+\n+        MongoConfiguration mongoConfiguration = new MongoConfiguration().withHost(\"localhost\").withDb(\"test\").withPort(37017l).withCollection(\"activities\");\n+\n+        MongoPersistWriter writer = new MongoPersistWriter(mongoConfiguration);\n+\n+        writer.prepare(null);\n+\n+        InputStream testActivityFolderStream = TestMongoPersist.class.getClassLoader()\n+                .getResourceAsStream(\"activities\");\n+        List<String> files = IOUtils.readLines(testActivityFolderStream, Charsets.UTF_8);\n+\n+        for( String file : files) {\n+            LOGGER.info(\"File: \" + file );\n+            InputStream testActivityFileStream = TestMongoPersist.class.getClassLoader()\n+                    .getResourceAsStream(\"activities/\" + file);\n+            Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);\n+            activity.getAdditionalProperties().remove(\"$license\");\n+            StreamsDatum datum = new StreamsDatum(activity, activity.getVerb());\n+            writer.write( datum );\n+            LOGGER.info(\"Wrote: \" + activity.getVerb() );\n+            count++;\n+        }\n+\n+        writer.cleanUp();\n+\n+        MongoPersistReader reader = new MongoPersistReader(mongoConfiguration);\n+\n+        reader.prepare(null);\n+\n+        StreamsResultSet resultSet = reader.readAll();\n+\n+        assert( resultSet.size() == count);","path":"streams-contrib/streams-persist-mongo/src/test/java/org/apache/streams/mongo/test/TestMongoPersist.java","position":115,"original_position":115,"commit_id":"3d4d2e71cd2405aa6a90551d6c3ff484e692b90e","original_commit_id":"3d4d2e71cd2405aa6a90551d6c3ff484e692b90e","user":{"login":"sieverssj","id":1036815,"avatar_url":"https://avatars.githubusercontent.com/u/1036815?v=3","gravatar_id":"","url":"https://api.github.com/users/sieverssj","html_url":"https://github.com/sieverssj","followers_url":"https://api.github.com/users/sieverssj/followers","following_url":"https://api.github.com/users/sieverssj/following{/other_user}","gists_url":"https://api.github.com/users/sieverssj/gists{/gist_id}","starred_url":"https://api.github.com/users/sieverssj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sieverssj/subscriptions","organizations_url":"https://api.github.com/users/sieverssj/orgs","repos_url":"https://api.github.com/users/sieverssj/repos","events_url":"https://api.github.com/users/sieverssj/events{/privacy}","received_events_url":"https://api.github.com/users/sieverssj/received_events","type":"User","site_admin":false},"body":"Is this a native assert()?  You should use assertThat() instead or at least assertEquals() in this case.","created_at":"2015-03-25T18:35:48Z","updated_at":"2015-03-25T18:35:48Z","html_url":"https://github.com/w2ogroup/incubator-streams/pull/109#discussion_r27151838","pull_request_url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109","_links":{"self":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/comments/27151838"},"html":{"href":"https://github.com/w2ogroup/incubator-streams/pull/109#discussion_r27151838"},"pull_request":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109"}}},"pull_request":{"url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109","id":31554775,"html_url":"https://github.com/w2ogroup/incubator-streams/pull/109","diff_url":"https://github.com/w2ogroup/incubator-streams/pull/109.diff","patch_url":"https://github.com/w2ogroup/incubator-streams/pull/109.patch","issue_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/109","number":109,"state":"open","locked":false,"title":"Moreover w2o","user":{"login":"rbnks","id":877649,"avatar_url":"https://avatars.githubusercontent.com/u/877649?v=3","gravatar_id":"","url":"https://api.github.com/users/rbnks","html_url":"https://github.com/rbnks","followers_url":"https://api.github.com/users/rbnks/followers","following_url":"https://api.github.com/users/rbnks/following{/other_user}","gists_url":"https://api.github.com/users/rbnks/gists{/gist_id}","starred_url":"https://api.github.com/users/rbnks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbnks/subscriptions","organizations_url":"https://api.github.com/users/rbnks/orgs","repos_url":"https://api.github.com/users/rbnks/repos","events_url":"https://api.github.com/users/rbnks/events{/privacy}","received_events_url":"https://api.github.com/users/rbnks/received_events","type":"User","site_admin":false},"body":"Changes for moreover to run in batch mode.\r\n\r\nAccidentally included some commits from apache master.","created_at":"2015-03-19T18:58:48Z","updated_at":"2015-03-25T18:35:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e07b76e3686fd0c853302bfe778d3e1cb3f61ef3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109/commits","review_comments_url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109/comments","review_comment_url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/comments{/number}","comments_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/109/comments","statuses_url":"https://api.github.com/repos/w2ogroup/incubator-streams/statuses/3d4d2e71cd2405aa6a90551d6c3ff484e692b90e","head":{"label":"w2ogroup:moreover-w2o","ref":"moreover-w2o","sha":"3d4d2e71cd2405aa6a90551d6c3ff484e692b90e","user":{"login":"w2ogroup","id":1746888,"avatar_url":"https://avatars.githubusercontent.com/u/1746888?v=3","gravatar_id":"","url":"https://api.github.com/users/w2ogroup","html_url":"https://github.com/w2ogroup","followers_url":"https://api.github.com/users/w2ogroup/followers","following_url":"https://api.github.com/users/w2ogroup/following{/other_user}","gists_url":"https://api.github.com/users/w2ogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/w2ogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w2ogroup/subscriptions","organizations_url":"https://api.github.com/users/w2ogroup/orgs","repos_url":"https://api.github.com/users/w2ogroup/repos","events_url":"https://api.github.com/users/w2ogroup/events{/privacy}","received_events_url":"https://api.github.com/users/w2ogroup/received_events","type":"Organization","site_admin":false},"repo":{"id":19159644,"name":"incubator-streams","full_name":"w2ogroup/incubator-streams","owner":{"login":"w2ogroup","id":1746888,"avatar_url":"https://avatars.githubusercontent.com/u/1746888?v=3","gravatar_id":"","url":"https://api.github.com/users/w2ogroup","html_url":"https://github.com/w2ogroup","followers_url":"https://api.github.com/users/w2ogroup/followers","following_url":"https://api.github.com/users/w2ogroup/following{/other_user}","gists_url":"https://api.github.com/users/w2ogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/w2ogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w2ogroup/subscriptions","organizations_url":"https://api.github.com/users/w2ogroup/orgs","repos_url":"https://api.github.com/users/w2ogroup/repos","events_url":"https://api.github.com/users/w2ogroup/events{/privacy}","received_events_url":"https://api.github.com/users/w2ogroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/w2ogroup/incubator-streams","description":"Mirror of Apache Streams","fork":true,"url":"https://api.github.com/repos/w2ogroup/incubator-streams","forks_url":"https://api.github.com/repos/w2ogroup/incubator-streams/forks","keys_url":"https://api.github.com/repos/w2ogroup/incubator-streams/keys{/key_id}","collaborators_url":"https://api.github.com/repos/w2ogroup/incubator-streams/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/w2ogroup/incubator-streams/teams","hooks_url":"https://api.github.com/repos/w2ogroup/incubator-streams/hooks","issue_events_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/events{/number}","events_url":"https://api.github.com/repos/w2ogroup/incubator-streams/events","assignees_url":"https://api.github.com/repos/w2ogroup/incubator-streams/assignees{/user}","branches_url":"https://api.github.com/repos/w2ogroup/incubator-streams/branches{/branch}","tags_url":"https://api.github.com/repos/w2ogroup/incubator-streams/tags","blobs_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/refs{/sha}","trees_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/trees{/sha}","statuses_url":"https://api.github.com/repos/w2ogroup/incubator-streams/statuses/{sha}","languages_url":"https://api.github.com/repos/w2ogroup/incubator-streams/languages","stargazers_url":"https://api.github.com/repos/w2ogroup/incubator-streams/stargazers","contributors_url":"https://api.github.com/repos/w2ogroup/incubator-streams/contributors","subscribers_url":"https://api.github.com/repos/w2ogroup/incubator-streams/subscribers","subscription_url":"https://api.github.com/repos/w2ogroup/incubator-streams/subscription","commits_url":"https://api.github.com/repos/w2ogroup/incubator-streams/commits{/sha}","git_commits_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/commits{/sha}","comments_url":"https://api.github.com/repos/w2ogroup/incubator-streams/comments{/number}","issue_comment_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/comments{/number}","contents_url":"https://api.github.com/repos/w2ogroup/incubator-streams/contents/{+path}","compare_url":"https://api.github.com/repos/w2ogroup/incubator-streams/compare/{base}...{head}","merges_url":"https://api.github.com/repos/w2ogroup/incubator-streams/merges","archive_url":"https://api.github.com/repos/w2ogroup/incubator-streams/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/w2ogroup/incubator-streams/downloads","issues_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues{/number}","pulls_url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls{/number}","milestones_url":"https://api.github.com/repos/w2ogroup/incubator-streams/milestones{/number}","notifications_url":"https://api.github.com/repos/w2ogroup/incubator-streams/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/w2ogroup/incubator-streams/labels{/name}","releases_url":"https://api.github.com/repos/w2ogroup/incubator-streams/releases{/id}","created_at":"2014-04-25T20:26:15Z","updated_at":"2015-03-23T19:00:57Z","pushed_at":"2015-03-24T14:53:21Z","git_url":"git://github.com/w2ogroup/incubator-streams.git","ssh_url":"git@github.com:w2ogroup/incubator-streams.git","clone_url":"https://github.com/w2ogroup/incubator-streams.git","svn_url":"https://github.com/w2ogroup/incubator-streams","homepage":null,"size":73013,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"w2ogroup:master","ref":"master","sha":"c142f5b009b2a4e4bc9f12e2ce5bffaf1cb8284a","user":{"login":"w2ogroup","id":1746888,"avatar_url":"https://avatars.githubusercontent.com/u/1746888?v=3","gravatar_id":"","url":"https://api.github.com/users/w2ogroup","html_url":"https://github.com/w2ogroup","followers_url":"https://api.github.com/users/w2ogroup/followers","following_url":"https://api.github.com/users/w2ogroup/following{/other_user}","gists_url":"https://api.github.com/users/w2ogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/w2ogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w2ogroup/subscriptions","organizations_url":"https://api.github.com/users/w2ogroup/orgs","repos_url":"https://api.github.com/users/w2ogroup/repos","events_url":"https://api.github.com/users/w2ogroup/events{/privacy}","received_events_url":"https://api.github.com/users/w2ogroup/received_events","type":"Organization","site_admin":false},"repo":{"id":19159644,"name":"incubator-streams","full_name":"w2ogroup/incubator-streams","owner":{"login":"w2ogroup","id":1746888,"avatar_url":"https://avatars.githubusercontent.com/u/1746888?v=3","gravatar_id":"","url":"https://api.github.com/users/w2ogroup","html_url":"https://github.com/w2ogroup","followers_url":"https://api.github.com/users/w2ogroup/followers","following_url":"https://api.github.com/users/w2ogroup/following{/other_user}","gists_url":"https://api.github.com/users/w2ogroup/gists{/gist_id}","starred_url":"https://api.github.com/users/w2ogroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w2ogroup/subscriptions","organizations_url":"https://api.github.com/users/w2ogroup/orgs","repos_url":"https://api.github.com/users/w2ogroup/repos","events_url":"https://api.github.com/users/w2ogroup/events{/privacy}","received_events_url":"https://api.github.com/users/w2ogroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/w2ogroup/incubator-streams","description":"Mirror of Apache Streams","fork":true,"url":"https://api.github.com/repos/w2ogroup/incubator-streams","forks_url":"https://api.github.com/repos/w2ogroup/incubator-streams/forks","keys_url":"https://api.github.com/repos/w2ogroup/incubator-streams/keys{/key_id}","collaborators_url":"https://api.github.com/repos/w2ogroup/incubator-streams/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/w2ogroup/incubator-streams/teams","hooks_url":"https://api.github.com/repos/w2ogroup/incubator-streams/hooks","issue_events_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/events{/number}","events_url":"https://api.github.com/repos/w2ogroup/incubator-streams/events","assignees_url":"https://api.github.com/repos/w2ogroup/incubator-streams/assignees{/user}","branches_url":"https://api.github.com/repos/w2ogroup/incubator-streams/branches{/branch}","tags_url":"https://api.github.com/repos/w2ogroup/incubator-streams/tags","blobs_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/refs{/sha}","trees_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/trees{/sha}","statuses_url":"https://api.github.com/repos/w2ogroup/incubator-streams/statuses/{sha}","languages_url":"https://api.github.com/repos/w2ogroup/incubator-streams/languages","stargazers_url":"https://api.github.com/repos/w2ogroup/incubator-streams/stargazers","contributors_url":"https://api.github.com/repos/w2ogroup/incubator-streams/contributors","subscribers_url":"https://api.github.com/repos/w2ogroup/incubator-streams/subscribers","subscription_url":"https://api.github.com/repos/w2ogroup/incubator-streams/subscription","commits_url":"https://api.github.com/repos/w2ogroup/incubator-streams/commits{/sha}","git_commits_url":"https://api.github.com/repos/w2ogroup/incubator-streams/git/commits{/sha}","comments_url":"https://api.github.com/repos/w2ogroup/incubator-streams/comments{/number}","issue_comment_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/comments{/number}","contents_url":"https://api.github.com/repos/w2ogroup/incubator-streams/contents/{+path}","compare_url":"https://api.github.com/repos/w2ogroup/incubator-streams/compare/{base}...{head}","merges_url":"https://api.github.com/repos/w2ogroup/incubator-streams/merges","archive_url":"https://api.github.com/repos/w2ogroup/incubator-streams/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/w2ogroup/incubator-streams/downloads","issues_url":"https://api.github.com/repos/w2ogroup/incubator-streams/issues{/number}","pulls_url":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls{/number}","milestones_url":"https://api.github.com/repos/w2ogroup/incubator-streams/milestones{/number}","notifications_url":"https://api.github.com/repos/w2ogroup/incubator-streams/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/w2ogroup/incubator-streams/labels{/name}","releases_url":"https://api.github.com/repos/w2ogroup/incubator-streams/releases{/id}","created_at":"2014-04-25T20:26:15Z","updated_at":"2015-03-23T19:00:57Z","pushed_at":"2015-03-24T14:53:21Z","git_url":"git://github.com/w2ogroup/incubator-streams.git","ssh_url":"git@github.com:w2ogroup/incubator-streams.git","clone_url":"https://github.com/w2ogroup/incubator-streams.git","svn_url":"https://github.com/w2ogroup/incubator-streams","homepage":null,"size":73013,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109"},"html":{"href":"https://github.com/w2ogroup/incubator-streams/pull/109"},"issue":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/109"},"comments":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/issues/109/comments"},"review_comments":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109/comments"},"review_comment":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/pulls/109/commits"},"statuses":{"href":"https://api.github.com/repos/w2ogroup/incubator-streams/statuses/3d4d2e71cd2405aa6a90551d6c3ff484e692b90e"}}}}