{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/comments/37624316","id":37624316,"diff_hunk":"@@ -0,0 +1,172 @@\n+package com.wikia.services.dcfilesync;\n+\n+import static org.mockito.Matchers.any;\n+import static org.mockito.Mockito.doThrow;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.times;\n+import static org.mockito.Mockito.verify;\n+import static org.mockito.Mockito.when;\n+\n+import com.wikia.model.asset.cassandra.Asset;\n+import com.wikia.model.asset.cassandra.AssetInDc;\n+import com.wikia.model.asset.rabbit.AssetCreated;\n+import com.wikia.model.asset.rabbit.AssetDeleted;\n+import com.wikia.model.asset.rabbit.Dc;\n+import com.wikia.model.asset.util.RabbitModelSerializer;\n+import com.wikia.rabbit.RabbitConnection;\n+import com.wikia.rabbit.RabbitRouting;\n+import com.wikia.services.dcfilesync.service.FileService;\n+import com.wikia.services.dcfilesync.worker.DcFileSync;\n+\n+import com.datastax.driver.mapping.Mapper;\n+import com.datastax.driver.mapping.MappingManager;\n+import com.rabbitmq.client.Channel;\n+import com.rabbitmq.client.Envelope;\n+import com.rabbitmq.client.QueueingConsumer;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+import java.io.FileNotFoundException;\n+import java.io.IOException;\n+import java.util.UUID;\n+\n+\n+public class DcFileSyncTest {\n+\n+  private static final String TEST_BUCKET_NAME = \"test-bucket\";\n+\n+  private static final String TEST_UUID = \"12345678-1234-1234-1234-123456789012\";\n+\n+  private static final String TEST_QUEUE_NAME = \"test-queue\";\n+\n+  private Mapper<Asset> assetMapperMock;\n+\n+  private Mapper<AssetInDc> assetInDcMapperMock;\n+\n+  private FileService fileServiceMock;\n+\n+  private MappingManager mappingManagerMock;\n+\n+  private QueueingConsumer.Delivery deliveryMock;\n+\n+  private Envelope envelopeMock;\n+\n+  private DcFileSync dcFileSync;\n+\n+  private QueueingConsumer queueingConsumerMock;\n+\n+  private Channel channelMock;\n+\n+  private RabbitConnection rabbitConnectionMock;\n+\n+  private RabbitRouting rabbitRoutingMock;\n+\n+  private RabbitModelSerializer serializer = new RabbitModelSerializer();\n+\n+  private static class TestDcFileSync extends DcFileSync {\n+\n+    public TestDcFileSync(MappingManager mappingManager,\n+                      FileService fileService,\n+                      Dc destDc,\n+                      String queueName) {\n+      super(mappingManager, fileService, destDc, queueName);\n+    }\n+\n+    @Override\n+    protected void route(QueueingConsumer.Delivery delivery) throws IOException {\n+      super.route(delivery);\n+      stop();\n+    }\n+  }\n+\n+  @Before\n+  public void setUp() throws IOException {\n+    assetMapperMock = mock(Mapper.class);\n+    assetInDcMapperMock = mock(Mapper.class);\n+    mappingManagerMock = mock(MappingManager.class);\n+    fileServiceMock = mock(FileService.class);\n+    deliveryMock = mock(QueueingConsumer.Delivery.class);\n+    envelopeMock = mock(Envelope.class);\n+    queueingConsumerMock = mock(QueueingConsumer.class);\n+    channelMock = mock(Channel.class);\n+    rabbitConnectionMock = mock(RabbitConnection.class);\n+    rabbitRoutingMock = mock(RabbitRouting.class);\n+    when(deliveryMock.getEnvelope()).thenReturn(envelopeMock);\n+    when(mappingManagerMock.mapper(Asset.class)).thenReturn(assetMapperMock);\n+    when(mappingManagerMock.mapper(AssetInDc.class)).thenReturn(assetInDcMapperMock);\n+    when(queueingConsumerMock.getChannel()).thenReturn(channelMock);\n+    when(rabbitConnectionMock.getQueuingConsumer(any(), any())).thenReturn(queueingConsumerMock);\n+    when(rabbitConnectionMock.getHost()).thenReturn(\"test-host\");\n+    dcFileSync = new TestDcFileSync(\n+        mappingManagerMock,\n+        fileServiceMock,\n+        Dc.Reston,\n+        TEST_QUEUE_NAME);\n+    dcFileSync.setRabbitRouting(rabbitRoutingMock);\n+    dcFileSync.setRabbitConnection(rabbitConnectionMock);\n+  }\n+\n+  @Test\n+  public void assetCreatedTest() throws IOException, InterruptedException {\n+    when(envelopeMock.getRoutingKey()).thenReturn(AssetCreated.ROUTING_KEY);\n+    AssetCreated assetCreated = new AssetCreated(\n+        Dc.SJC, TEST_BUCKET_NAME, UUID.fromString(TEST_UUID));\n+    when(deliveryMock.getBody()).thenReturn(serializer.serializeAssetCreated(assetCreated).getBytes());\n+    when(queueingConsumerMock.nextDelivery()).thenReturn(deliveryMock);\n+\n+    dcFileSync.run();\n+\n+    verify(fileServiceMock, times(1)).copyFile(Dc.SJC, TEST_BUCKET_NAME, TEST_UUID, Dc.Reston);\n+    verify(channelMock, times(1)).basicAck(0, false);\n+  }\n+\n+  @Test\n+  public void assetCreatedFileNotFoundExceptionTest() throws IOException, InterruptedException {","path":"service/dc-file-sync/src/test/java/com/wikia/services/dcfilesync/DcFileSyncTest.java","position":124,"original_position":124,"commit_id":"0c744891377b349a93be443511162770feb34cea","original_commit_id":"0c744891377b349a93be443511162770feb34cea","user":{"login":"jcellary","id":7473307,"avatar_url":"https://avatars.githubusercontent.com/u/7473307?v=3","gravatar_id":"","url":"https://api.github.com/users/jcellary","html_url":"https://github.com/jcellary","followers_url":"https://api.github.com/users/jcellary/followers","following_url":"https://api.github.com/users/jcellary/following{/other_user}","gists_url":"https://api.github.com/users/jcellary/gists{/gist_id}","starred_url":"https://api.github.com/users/jcellary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcellary/subscriptions","organizations_url":"https://api.github.com/users/jcellary/orgs","repos_url":"https://api.github.com/users/jcellary/repos","events_url":"https://api.github.com/users/jcellary/events{/privacy}","received_events_url":"https://api.github.com/users/jcellary/received_events","type":"User","site_admin":false},"body":"This really makes no sense in this contentxt... It's a unit test and I want to throw all possible exceptions instead of dealing with them in this method","created_at":"2015-08-21T10:55:15Z","updated_at":"2015-08-21T10:55:15Z","html_url":"https://github.com/Wikia/pandora/pull/399#discussion_r37624316","pull_request_url":"https://api.github.com/repos/Wikia/pandora/pulls/399","_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments/37624316"},"html":{"href":"https://github.com/Wikia/pandora/pull/399#discussion_r37624316"},"pull_request":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/pandora/pulls/399","id":42810071,"html_url":"https://github.com/Wikia/pandora/pull/399","diff_url":"https://github.com/Wikia/pandora/pull/399.diff","patch_url":"https://github.com/Wikia/pandora/pull/399.patch","issue_url":"https://api.github.com/repos/Wikia/pandora/issues/399","number":399,"state":"open","locked":false,"title":"[Platform-1371] Added Dc file sync worker for Sjc - Reston image synchronization","user":{"login":"jcellary","id":7473307,"avatar_url":"https://avatars.githubusercontent.com/u/7473307?v=3","gravatar_id":"","url":"https://api.github.com/users/jcellary","html_url":"https://github.com/jcellary","followers_url":"https://api.github.com/users/jcellary/followers","following_url":"https://api.github.com/users/jcellary/following{/other_user}","gists_url":"https://api.github.com/users/jcellary/gists{/gist_id}","starred_url":"https://api.github.com/users/jcellary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcellary/subscriptions","organizations_url":"https://api.github.com/users/jcellary/orgs","repos_url":"https://api.github.com/users/jcellary/repos","events_url":"https://api.github.com/users/jcellary/events{/privacy}","received_events_url":"https://api.github.com/users/jcellary/received_events","type":"User","site_admin":false},"body":"A few additions:\r\n- Dc file sync worker for Sjc - Reston image synchronization. Also made changes to the Rabbit Abstract Worker to enable greater customization. \r\n- Extended Static Assets Service to push events to the rabbit queue and store information about images in the assets_in_dc table","created_at":"2015-08-19T12:49:17Z","updated_at":"2015-08-21T10:55:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b635d4b20e8e5935d191cae86b60b0e2d3cce6f9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/pandora/pulls/399/commits","review_comments_url":"https://api.github.com/repos/Wikia/pandora/pulls/399/comments","review_comment_url":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/pandora/issues/399/comments","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/0c744891377b349a93be443511162770feb34cea","head":{"label":"Wikia:dc-file-sync","ref":"dc-file-sync","sha":"0c744891377b349a93be443511162770feb34cea","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-08-18T21:15:19Z","pushed_at":"2015-08-21T04:37:12Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":25497,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":3,"default_branch":"master"}},"base":{"label":"Wikia:master","ref":"master","sha":"e7ac641b4913b97d97b530ce8fdb30517181ab7d","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":26663749,"name":"pandora","full_name":"Wikia/pandora","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/pandora","description":"API Service","fork":false,"url":"https://api.github.com/repos/Wikia/pandora","forks_url":"https://api.github.com/repos/Wikia/pandora/forks","keys_url":"https://api.github.com/repos/Wikia/pandora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/pandora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/pandora/teams","hooks_url":"https://api.github.com/repos/Wikia/pandora/hooks","issue_events_url":"https://api.github.com/repos/Wikia/pandora/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/pandora/events","assignees_url":"https://api.github.com/repos/Wikia/pandora/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/pandora/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/pandora/tags","blobs_url":"https://api.github.com/repos/Wikia/pandora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/pandora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/pandora/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/pandora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/pandora/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/pandora/languages","stargazers_url":"https://api.github.com/repos/Wikia/pandora/stargazers","contributors_url":"https://api.github.com/repos/Wikia/pandora/contributors","subscribers_url":"https://api.github.com/repos/Wikia/pandora/subscribers","subscription_url":"https://api.github.com/repos/Wikia/pandora/subscription","commits_url":"https://api.github.com/repos/Wikia/pandora/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/pandora/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/pandora/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/pandora/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/pandora/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/pandora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/pandora/merges","archive_url":"https://api.github.com/repos/Wikia/pandora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/pandora/downloads","issues_url":"https://api.github.com/repos/Wikia/pandora/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/pandora/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/pandora/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/pandora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/pandora/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/pandora/releases{/id}","created_at":"2014-11-15T00:29:06Z","updated_at":"2015-08-18T21:15:19Z","pushed_at":"2015-08-21T04:37:12Z","git_url":"git://github.com/Wikia/pandora.git","ssh_url":"git@github.com:Wikia/pandora.git","clone_url":"https://github.com/Wikia/pandora.git","svn_url":"https://github.com/Wikia/pandora","homepage":null,"size":25497,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399"},"html":{"href":"https://github.com/Wikia/pandora/pull/399"},"issue":{"href":"https://api.github.com/repos/Wikia/pandora/issues/399"},"comments":{"href":"https://api.github.com/repos/Wikia/pandora/issues/399/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/pandora/pulls/399/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/pandora/statuses/0c744891377b349a93be443511162770feb34cea"}}}}