{"action":"created","comment":{"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments/47466830","id":47466830,"diff_hunk":"@@ -0,0 +1,48 @@\n+package com.clouway.downloadagent;\n+\n+\n+import com.google.common.io.ByteStreams;\n+import org.junit.Test;\n+\n+import java.io.*;\n+import java.net.URI;\n+import java.net.URL;\n+import java.net.URLConnection;\n+\n+import static org.hamcrest.CoreMatchers.equalTo;\n+import static org.hamcrest.MatcherAssert.assertThat;\n+import static org.hamcrest.core.Is.is;\n+import static org.junit.Assert.assertArrayEquals;\n+\n+\n+/**\n+ * Created by clouway on 15-12-1.\n+ */\n+public class DownloadAgentTest {\n+\n+    public class DownloadProgressSpectator implements ProgressSpectator {\n+        long testPercent = 0;\n+\n+        @Override\n+        public void progressUpdate(long percent) {\n+            testPercent=percent;\n+        }\n+\n+        public void assertLastProgressUpdateIs(long finalPercent){\n+            assertThat(finalPercent,is(equalTo(testPercent)));\n+        }\n+    }\n+\n+    @Test\n+    public void happyPath() throws Exception {\n+        DownloadProgressSpectator downloadProgressSpectator = new DownloadProgressSpectator();\n+        DownloadAgent downloadAgent = new DownloadAgent(downloadProgressSpectator);\n+        URI uri1 = this.getClass().getResource(\"abv.jpeg\").toURI();\n+        ByteArrayOutputStream imageOutputStream = new ByteArrayOutputStream();\n+        downloadAgent.downloadFile(uri1, imageOutputStream);\n+        byte[] expectedContent = ByteStreams.toByteArray(getClass().getResourceAsStream(\"abv.jpeg\"));\n+        assertArrayEquals(expectedContent, imageOutputStream.toByteArray());\n+        downloadProgressSpectator.assertLastProgressUpdateIs(100);","path":"test/com/clouway/downloadagent/DownloadAgentTest.java","position":50,"original_position":45,"commit_id":"85991702199dd7fdc1b655afe9283d2dadfeb883","original_commit_id":"d5cc0bf3d1089d6a65ea4fe52bc42facd02974b9","user":{"login":"kristiyanpetkov","id":12229738,"avatar_url":"https://avatars.githubusercontent.com/u/12229738?v=3","gravatar_id":"","url":"https://api.github.com/users/kristiyanpetkov","html_url":"https://github.com/kristiyanpetkov","followers_url":"https://api.github.com/users/kristiyanpetkov/followers","following_url":"https://api.github.com/users/kristiyanpetkov/following{/other_user}","gists_url":"https://api.github.com/users/kristiyanpetkov/gists{/gist_id}","starred_url":"https://api.github.com/users/kristiyanpetkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kristiyanpetkov/subscriptions","organizations_url":"https://api.github.com/users/kristiyanpetkov/orgs","repos_url":"https://api.github.com/users/kristiyanpetkov/repos","events_url":"https://api.github.com/users/kristiyanpetkov/events{/privacy}","received_events_url":"https://api.github.com/users/kristiyanpetkov/received_events","type":"User","site_admin":false},"body":"I just added this check. It checks from 0% to 100%.","created_at":"2015-12-14T07:17:38Z","updated_at":"2015-12-14T07:17:38Z","html_url":"https://github.com/clouway-incubator/networking-and-gui/pull/5#discussion_r47466830","pull_request_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments/47466830"},"html":{"href":"https://github.com/clouway-incubator/networking-and-gui/pull/5#discussion_r47466830"},"pull_request":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5","id":52226583,"html_url":"https://github.com/clouway-incubator/networking-and-gui/pull/5","diff_url":"https://github.com/clouway-incubator/networking-and-gui/pull/5.diff","patch_url":"https://github.com/clouway-incubator/networking-and-gui/pull/5.patch","issue_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/5","number":5,"state":"open","locked":false,"title":"Networking: Download agent","user":{"login":"kristiyanpetkov","id":12229738,"avatar_url":"https://avatars.githubusercontent.com/u/12229738?v=3","gravatar_id":"","url":"https://api.github.com/users/kristiyanpetkov","html_url":"https://github.com/kristiyanpetkov","followers_url":"https://api.github.com/users/kristiyanpetkov/followers","following_url":"https://api.github.com/users/kristiyanpetkov/following{/other_user}","gists_url":"https://api.github.com/users/kristiyanpetkov/gists{/gist_id}","starred_url":"https://api.github.com/users/kristiyanpetkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kristiyanpetkov/subscriptions","organizations_url":"https://api.github.com/users/kristiyanpetkov/orgs","repos_url":"https://api.github.com/users/kristiyanpetkov/repos","events_url":"https://api.github.com/users/kristiyanpetkov/events{/privacy}","received_events_url":"https://api.github.com/users/kristiyanpetkov/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-01T07:59:54Z","updated_at":"2015-12-14T07:17:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4f68c14effc961b10a18f52e595fe91d2102195","assignee":{"login":"mgenov","id":209223,"avatar_url":"https://avatars.githubusercontent.com/u/209223?v=3","gravatar_id":"","url":"https://api.github.com/users/mgenov","html_url":"https://github.com/mgenov","followers_url":"https://api.github.com/users/mgenov/followers","following_url":"https://api.github.com/users/mgenov/following{/other_user}","gists_url":"https://api.github.com/users/mgenov/gists{/gist_id}","starred_url":"https://api.github.com/users/mgenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgenov/subscriptions","organizations_url":"https://api.github.com/users/mgenov/orgs","repos_url":"https://api.github.com/users/mgenov/repos","events_url":"https://api.github.com/users/mgenov/events{/privacy}","received_events_url":"https://api.github.com/users/mgenov/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5/commits","review_comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5/comments","review_comment_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/5/comments","statuses_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/85991702199dd7fdc1b655afe9283d2dadfeb883","head":{"label":"kristiyanpetkov:task1","ref":"task1","sha":"85991702199dd7fdc1b655afe9283d2dadfeb883","user":{"login":"kristiyanpetkov","id":12229738,"avatar_url":"https://avatars.githubusercontent.com/u/12229738?v=3","gravatar_id":"","url":"https://api.github.com/users/kristiyanpetkov","html_url":"https://github.com/kristiyanpetkov","followers_url":"https://api.github.com/users/kristiyanpetkov/followers","following_url":"https://api.github.com/users/kristiyanpetkov/following{/other_user}","gists_url":"https://api.github.com/users/kristiyanpetkov/gists{/gist_id}","starred_url":"https://api.github.com/users/kristiyanpetkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kristiyanpetkov/subscriptions","organizations_url":"https://api.github.com/users/kristiyanpetkov/orgs","repos_url":"https://api.github.com/users/kristiyanpetkov/repos","events_url":"https://api.github.com/users/kristiyanpetkov/events{/privacy}","received_events_url":"https://api.github.com/users/kristiyanpetkov/received_events","type":"User","site_admin":false},"repo":{"id":47118997,"name":"networking-and-gui","full_name":"kristiyanpetkov/networking-and-gui","owner":{"login":"kristiyanpetkov","id":12229738,"avatar_url":"https://avatars.githubusercontent.com/u/12229738?v=3","gravatar_id":"","url":"https://api.github.com/users/kristiyanpetkov","html_url":"https://github.com/kristiyanpetkov","followers_url":"https://api.github.com/users/kristiyanpetkov/followers","following_url":"https://api.github.com/users/kristiyanpetkov/following{/other_user}","gists_url":"https://api.github.com/users/kristiyanpetkov/gists{/gist_id}","starred_url":"https://api.github.com/users/kristiyanpetkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kristiyanpetkov/subscriptions","organizations_url":"https://api.github.com/users/kristiyanpetkov/orgs","repos_url":"https://api.github.com/users/kristiyanpetkov/repos","events_url":"https://api.github.com/users/kristiyanpetkov/events{/privacy}","received_events_url":"https://api.github.com/users/kristiyanpetkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kristiyanpetkov/networking-and-gui","description":"Networking and GUI","fork":true,"url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui","forks_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/forks","keys_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/teams","hooks_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/hooks","issue_events_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/issues/events{/number}","events_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/events","assignees_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/assignees{/user}","branches_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/branches{/branch}","tags_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/tags","blobs_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/languages","stargazers_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/stargazers","contributors_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/contributors","subscribers_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/subscribers","subscription_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/subscription","commits_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/contents/{+path}","compare_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/merges","archive_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/downloads","issues_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/issues{/number}","pulls_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/labels{/name}","releases_url":"https://api.github.com/repos/kristiyanpetkov/networking-and-gui/releases{/id}","created_at":"2015-11-30T13:06:58Z","updated_at":"2015-12-03T08:57:00Z","pushed_at":"2015-12-14T07:14:45Z","git_url":"git://github.com/kristiyanpetkov/networking-and-gui.git","ssh_url":"git@github.com:kristiyanpetkov/networking-and-gui.git","clone_url":"https://github.com/kristiyanpetkov/networking-and-gui.git","svn_url":"https://github.com/kristiyanpetkov/networking-and-gui","homepage":null,"size":1493,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"clouway-incubator:kristiyan","ref":"kristiyan","sha":"6604dc3fc61595d134abd2756dc8001f59ba2f94","user":{"login":"clouway-incubator","id":10173098,"avatar_url":"https://avatars.githubusercontent.com/u/10173098?v=3","gravatar_id":"","url":"https://api.github.com/users/clouway-incubator","html_url":"https://github.com/clouway-incubator","followers_url":"https://api.github.com/users/clouway-incubator/followers","following_url":"https://api.github.com/users/clouway-incubator/following{/other_user}","gists_url":"https://api.github.com/users/clouway-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway-incubator/subscriptions","organizations_url":"https://api.github.com/users/clouway-incubator/orgs","repos_url":"https://api.github.com/users/clouway-incubator/repos","events_url":"https://api.github.com/users/clouway-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/clouway-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":43062597,"name":"networking-and-gui","full_name":"clouway-incubator/networking-and-gui","owner":{"login":"clouway-incubator","id":10173098,"avatar_url":"https://avatars.githubusercontent.com/u/10173098?v=3","gravatar_id":"","url":"https://api.github.com/users/clouway-incubator","html_url":"https://github.com/clouway-incubator","followers_url":"https://api.github.com/users/clouway-incubator/followers","following_url":"https://api.github.com/users/clouway-incubator/following{/other_user}","gists_url":"https://api.github.com/users/clouway-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/clouway-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clouway-incubator/subscriptions","organizations_url":"https://api.github.com/users/clouway-incubator/orgs","repos_url":"https://api.github.com/users/clouway-incubator/repos","events_url":"https://api.github.com/users/clouway-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/clouway-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clouway-incubator/networking-and-gui","description":"Networking and GUI","fork":false,"url":"https://api.github.com/repos/clouway-incubator/networking-and-gui","forks_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/forks","keys_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/teams","hooks_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/hooks","issue_events_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/events{/number}","events_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/events","assignees_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/assignees{/user}","branches_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/branches{/branch}","tags_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/tags","blobs_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/languages","stargazers_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/stargazers","contributors_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/contributors","subscribers_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/subscribers","subscription_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/subscription","commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/contents/{+path}","compare_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/merges","archive_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/downloads","issues_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues{/number}","pulls_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/labels{/name}","releases_url":"https://api.github.com/repos/clouway-incubator/networking-and-gui/releases{/id}","created_at":"2015-09-24T11:23:01Z","updated_at":"2015-09-24T11:23:01Z","pushed_at":"2015-12-14T07:14:45Z","git_url":"git://github.com/clouway-incubator/networking-and-gui.git","ssh_url":"git@github.com:clouway-incubator/networking-and-gui.git","clone_url":"https://github.com/clouway-incubator/networking-and-gui.git","svn_url":"https://github.com/clouway-incubator/networking-and-gui","homepage":null,"size":48,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5"},"html":{"href":"https://github.com/clouway-incubator/networking-and-gui/pull/5"},"issue":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/5"},"comments":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/clouway-incubator/networking-and-gui/statuses/85991702199dd7fdc1b655afe9283d2dadfeb883"}}}}