{"action":"created","comment":{"url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/comments/63843210","id":63843210,"diff_hunk":"@@ -0,0 +1,146 @@\n+/**\n+ * Copyright (C) 2016 Bonitasoft S.A.\n+ * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble\n+ * This library is free software; you can redistribute it and/or modify it under the terms\n+ * of the GNU Lesser General Public License as published by the Free Software Foundation\n+ * version 2.1 of the License.\n+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n+ * See the GNU Lesser General Public License for more details.\n+ * You should have received a copy of the GNU Lesser General Public License along with this\n+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n+ * Floor, Boston, MA 02110-1301, USA.\n+ **/\n+\n+package org.bonitasoft.console.common.server.servlet;\n+\n+import static org.mockito.Mockito.*;\n+\n+import javax.servlet.ServletOutputStream;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+import org.bonitasoft.engine.api.IdentityAPI;\n+import org.bonitasoft.engine.exception.NotFoundException;\n+import org.bonitasoft.engine.identity.impl.IconImpl;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.mockito.InjectMocks;\n+import org.mockito.Mock;\n+import org.mockito.Spy;\n+import org.mockito.runners.MockitoJUnitRunner;\n+\n+/**\n+ * @author Baptiste Mesta\n+ */\n+@RunWith(MockitoJUnitRunner.class)\n+public class IconServletTest {\n+\n+    private static final long ICON_ID = 1238970432L;\n+    private static final String ICON_ID_STRING = \"1238970432\";\n+    private static final byte[] ICON_CONTENT = \"content\".getBytes();\n+    @InjectMocks\n+    @Spy\n+    private IconServlet iconServlet;\n+    @Mock\n+    private HttpServletRequest httpServletRequest;\n+    @Mock\n+    private HttpServletResponse httpServletResponse;\n+    @Mock\n+    private IdentityAPI identityAPI;\n+    @Mock\n+    private ServletOutputStream outputStream;\n+\n+    @Before\n+    public void before() throws Exception {\n+        doReturn(identityAPI).when(iconServlet).getIdentityApi(httpServletRequest);\n+        doReturn(outputStream).when(httpServletResponse).getOutputStream();\n+    }\n+\n+    private void havingIcon(String mimeType, long iconId) throws NotFoundException {\n+        doReturn(new IconImpl(iconId, mimeType, ICON_CONTENT)).when(identityAPI).getIcon(iconId);\n+    }\n+\n+    private HttpServletRequest request(String contextUrl) {\n+        doReturn(contextUrl).when(httpServletRequest).getPathInfo();\n+        return httpServletRequest;\n+    }\n+\n+    @Test\n+    public void should_get_return_user_icon_from_engine() throws Exception {","path":"server/src/test/java/org/bonitasoft/console/common/server/servlet/IconServletTest.java","position":71,"original_position":71,"commit_id":"67d5c6c9f9cb479f5f6177c6d6ab6b54f4e8d411","original_commit_id":"67d5c6c9f9cb479f5f6177c6d6ab6b54f4e8d411","user":{"login":"cpuy","id":1671164,"avatar_url":"https://avatars.githubusercontent.com/u/1671164?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuy","html_url":"https://github.com/cpuy","followers_url":"https://api.github.com/users/cpuy/followers","following_url":"https://api.github.com/users/cpuy/following{/other_user}","gists_url":"https://api.github.com/users/cpuy/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuy/subscriptions","organizations_url":"https://api.github.com/users/cpuy/orgs","repos_url":"https://api.github.com/users/cpuy/repos","events_url":"https://api.github.com/users/cpuy/events{/privacy}","received_events_url":"https://api.github.com/users/cpuy/received_events","type":"User","site_admin":false},"body":":+1: `should return user icon from engine when valid id is given in url`\r\nSubject must always be the object under test even if there are multiple entry points.\r\nAs an example let's say we want to test a UserRepository, we should have kind of these tests\r\n`should_get_a_user_by_id`, `should_save_a_user`, `should_get_users_by_first_name`, etc...","created_at":"2016-05-19T08:55:08Z","updated_at":"2016-05-19T08:55:08Z","html_url":"https://github.com/bonitasoft/bonita-web/pull/274#discussion_r63843210","pull_request_url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274","_links":{"self":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/comments/63843210"},"html":{"href":"https://github.com/bonitasoft/bonita-web/pull/274#discussion_r63843210"},"pull_request":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274"}}},"pull_request":{"url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274","id":69866848,"html_url":"https://github.com/bonitasoft/bonita-web/pull/274","diff_url":"https://github.com/bonitasoft/bonita-web/pull/274.diff","patch_url":"https://github.com/bonitasoft/bonita-web/pull/274.patch","issue_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues/274","number":274,"state":"open","locked":false,"title":"feat(user_icon): retrieve icon from the engine instead of FS","user":{"login":"baptistemesta","id":2739234,"avatar_url":"https://avatars.githubusercontent.com/u/2739234?v=3","gravatar_id":"","url":"https://api.github.com/users/baptistemesta","html_url":"https://github.com/baptistemesta","followers_url":"https://api.github.com/users/baptistemesta/followers","following_url":"https://api.github.com/users/baptistemesta/following{/other_user}","gists_url":"https://api.github.com/users/baptistemesta/gists{/gist_id}","starred_url":"https://api.github.com/users/baptistemesta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baptistemesta/subscriptions","organizations_url":"https://api.github.com/users/baptistemesta/orgs","repos_url":"https://api.github.com/users/baptistemesta/repos","events_url":"https://api.github.com/users/baptistemesta/events{/privacy}","received_events_url":"https://api.github.com/users/baptistemesta/received_events","type":"User","site_admin":false},"body":"now the icon are in the engine and not in the bonita home\n\nurl of the servlet is now avatars/<icon_id>","created_at":"2016-05-12T16:25:58Z","updated_at":"2016-05-19T08:55:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ece379e9c56f169cfcff8b2caa3e456aeac17725","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274/commits","review_comments_url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274/comments","review_comment_url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues/274/comments","statuses_url":"https://api.github.com/repos/bonitasoft/bonita-web/statuses/67d5c6c9f9cb479f5f6177c6d6ab6b54f4e8d411","head":{"label":"bonitasoft:feat/update_icon_download_servlet","ref":"feat/update_icon_download_servlet","sha":"67d5c6c9f9cb479f5f6177c6d6ab6b54f4e8d411","user":{"login":"bonitasoft","id":4619712,"avatar_url":"https://avatars.githubusercontent.com/u/4619712?v=3","gravatar_id":"","url":"https://api.github.com/users/bonitasoft","html_url":"https://github.com/bonitasoft","followers_url":"https://api.github.com/users/bonitasoft/followers","following_url":"https://api.github.com/users/bonitasoft/following{/other_user}","gists_url":"https://api.github.com/users/bonitasoft/gists{/gist_id}","starred_url":"https://api.github.com/users/bonitasoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonitasoft/subscriptions","organizations_url":"https://api.github.com/users/bonitasoft/orgs","repos_url":"https://api.github.com/users/bonitasoft/repos","events_url":"https://api.github.com/users/bonitasoft/events{/privacy}","received_events_url":"https://api.github.com/users/bonitasoft/received_events","type":"Organization","site_admin":false},"repo":{"id":11337147,"name":"bonita-web","full_name":"bonitasoft/bonita-web","owner":{"login":"bonitasoft","id":4619712,"avatar_url":"https://avatars.githubusercontent.com/u/4619712?v=3","gravatar_id":"","url":"https://api.github.com/users/bonitasoft","html_url":"https://github.com/bonitasoft","followers_url":"https://api.github.com/users/bonitasoft/followers","following_url":"https://api.github.com/users/bonitasoft/following{/other_user}","gists_url":"https://api.github.com/users/bonitasoft/gists{/gist_id}","starred_url":"https://api.github.com/users/bonitasoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonitasoft/subscriptions","organizations_url":"https://api.github.com/users/bonitasoft/orgs","repos_url":"https://api.github.com/users/bonitasoft/repos","events_url":"https://api.github.com/users/bonitasoft/events{/privacy}","received_events_url":"https://api.github.com/users/bonitasoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonitasoft/bonita-web","description":"","fork":false,"url":"https://api.github.com/repos/bonitasoft/bonita-web","forks_url":"https://api.github.com/repos/bonitasoft/bonita-web/forks","keys_url":"https://api.github.com/repos/bonitasoft/bonita-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonitasoft/bonita-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonitasoft/bonita-web/teams","hooks_url":"https://api.github.com/repos/bonitasoft/bonita-web/hooks","issue_events_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues/events{/number}","events_url":"https://api.github.com/repos/bonitasoft/bonita-web/events","assignees_url":"https://api.github.com/repos/bonitasoft/bonita-web/assignees{/user}","branches_url":"https://api.github.com/repos/bonitasoft/bonita-web/branches{/branch}","tags_url":"https://api.github.com/repos/bonitasoft/bonita-web/tags","blobs_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonitasoft/bonita-web/statuses/{sha}","languages_url":"https://api.github.com/repos/bonitasoft/bonita-web/languages","stargazers_url":"https://api.github.com/repos/bonitasoft/bonita-web/stargazers","contributors_url":"https://api.github.com/repos/bonitasoft/bonita-web/contributors","subscribers_url":"https://api.github.com/repos/bonitasoft/bonita-web/subscribers","subscription_url":"https://api.github.com/repos/bonitasoft/bonita-web/subscription","commits_url":"https://api.github.com/repos/bonitasoft/bonita-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonitasoft/bonita-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/bonitasoft/bonita-web/contents/{+path}","compare_url":"https://api.github.com/repos/bonitasoft/bonita-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonitasoft/bonita-web/merges","archive_url":"https://api.github.com/repos/bonitasoft/bonita-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonitasoft/bonita-web/downloads","issues_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues{/number}","pulls_url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls{/number}","milestones_url":"https://api.github.com/repos/bonitasoft/bonita-web/milestones{/number}","notifications_url":"https://api.github.com/repos/bonitasoft/bonita-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonitasoft/bonita-web/labels{/name}","releases_url":"https://api.github.com/repos/bonitasoft/bonita-web/releases{/id}","deployments_url":"https://api.github.com/repos/bonitasoft/bonita-web/deployments","created_at":"2013-07-11T08:39:00Z","updated_at":"2016-05-10T09:50:20Z","pushed_at":"2016-05-18T09:08:23Z","git_url":"git://github.com/bonitasoft/bonita-web.git","ssh_url":"git@github.com:bonitasoft/bonita-web.git","clone_url":"https://github.com/bonitasoft/bonita-web.git","svn_url":"https://github.com/bonitasoft/bonita-web","homepage":"http://community.bonitasoft.com/","size":141215,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":4,"forks":30,"open_issues":4,"watchers":12,"default_branch":"master"}},"base":{"label":"bonitasoft:PaaS_ready","ref":"PaaS_ready","sha":"6c9cb40ac4829ce92ddb5d0562564da62a12302a","user":{"login":"bonitasoft","id":4619712,"avatar_url":"https://avatars.githubusercontent.com/u/4619712?v=3","gravatar_id":"","url":"https://api.github.com/users/bonitasoft","html_url":"https://github.com/bonitasoft","followers_url":"https://api.github.com/users/bonitasoft/followers","following_url":"https://api.github.com/users/bonitasoft/following{/other_user}","gists_url":"https://api.github.com/users/bonitasoft/gists{/gist_id}","starred_url":"https://api.github.com/users/bonitasoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonitasoft/subscriptions","organizations_url":"https://api.github.com/users/bonitasoft/orgs","repos_url":"https://api.github.com/users/bonitasoft/repos","events_url":"https://api.github.com/users/bonitasoft/events{/privacy}","received_events_url":"https://api.github.com/users/bonitasoft/received_events","type":"Organization","site_admin":false},"repo":{"id":11337147,"name":"bonita-web","full_name":"bonitasoft/bonita-web","owner":{"login":"bonitasoft","id":4619712,"avatar_url":"https://avatars.githubusercontent.com/u/4619712?v=3","gravatar_id":"","url":"https://api.github.com/users/bonitasoft","html_url":"https://github.com/bonitasoft","followers_url":"https://api.github.com/users/bonitasoft/followers","following_url":"https://api.github.com/users/bonitasoft/following{/other_user}","gists_url":"https://api.github.com/users/bonitasoft/gists{/gist_id}","starred_url":"https://api.github.com/users/bonitasoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonitasoft/subscriptions","organizations_url":"https://api.github.com/users/bonitasoft/orgs","repos_url":"https://api.github.com/users/bonitasoft/repos","events_url":"https://api.github.com/users/bonitasoft/events{/privacy}","received_events_url":"https://api.github.com/users/bonitasoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonitasoft/bonita-web","description":"","fork":false,"url":"https://api.github.com/repos/bonitasoft/bonita-web","forks_url":"https://api.github.com/repos/bonitasoft/bonita-web/forks","keys_url":"https://api.github.com/repos/bonitasoft/bonita-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonitasoft/bonita-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonitasoft/bonita-web/teams","hooks_url":"https://api.github.com/repos/bonitasoft/bonita-web/hooks","issue_events_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues/events{/number}","events_url":"https://api.github.com/repos/bonitasoft/bonita-web/events","assignees_url":"https://api.github.com/repos/bonitasoft/bonita-web/assignees{/user}","branches_url":"https://api.github.com/repos/bonitasoft/bonita-web/branches{/branch}","tags_url":"https://api.github.com/repos/bonitasoft/bonita-web/tags","blobs_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonitasoft/bonita-web/statuses/{sha}","languages_url":"https://api.github.com/repos/bonitasoft/bonita-web/languages","stargazers_url":"https://api.github.com/repos/bonitasoft/bonita-web/stargazers","contributors_url":"https://api.github.com/repos/bonitasoft/bonita-web/contributors","subscribers_url":"https://api.github.com/repos/bonitasoft/bonita-web/subscribers","subscription_url":"https://api.github.com/repos/bonitasoft/bonita-web/subscription","commits_url":"https://api.github.com/repos/bonitasoft/bonita-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonitasoft/bonita-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonitasoft/bonita-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/bonitasoft/bonita-web/contents/{+path}","compare_url":"https://api.github.com/repos/bonitasoft/bonita-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonitasoft/bonita-web/merges","archive_url":"https://api.github.com/repos/bonitasoft/bonita-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonitasoft/bonita-web/downloads","issues_url":"https://api.github.com/repos/bonitasoft/bonita-web/issues{/number}","pulls_url":"https://api.github.com/repos/bonitasoft/bonita-web/pulls{/number}","milestones_url":"https://api.github.com/repos/bonitasoft/bonita-web/milestones{/number}","notifications_url":"https://api.github.com/repos/bonitasoft/bonita-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonitasoft/bonita-web/labels{/name}","releases_url":"https://api.github.com/repos/bonitasoft/bonita-web/releases{/id}","deployments_url":"https://api.github.com/repos/bonitasoft/bonita-web/deployments","created_at":"2013-07-11T08:39:00Z","updated_at":"2016-05-10T09:50:20Z","pushed_at":"2016-05-18T09:08:23Z","git_url":"git://github.com/bonitasoft/bonita-web.git","ssh_url":"git@github.com:bonitasoft/bonita-web.git","clone_url":"https://github.com/bonitasoft/bonita-web.git","svn_url":"https://github.com/bonitasoft/bonita-web","homepage":"http://community.bonitasoft.com/","size":141215,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":30,"mirror_url":null,"open_issues_count":4,"forks":30,"open_issues":4,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274"},"html":{"href":"https://github.com/bonitasoft/bonita-web/pull/274"},"issue":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/issues/274"},"comments":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/issues/274/comments"},"review_comments":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274/comments"},"review_comment":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/pulls/274/commits"},"statuses":{"href":"https://api.github.com/repos/bonitasoft/bonita-web/statuses/67d5c6c9f9cb479f5f6177c6d6ab6b54f4e8d411"}}}}