{"action":"created","comment":{"url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/comments/41921943","id":41921943,"diff_hunk":"@@ -0,0 +1,124 @@\n+package org.sonar.plugins.stash;\r\n+\r\n+import static org.mockito.Matchers.eq;\r\n+import static org.mockito.Mockito.mock;\r\n+import static org.mockito.Mockito.times;\r\n+import static org.mockito.Mockito.verify;\r\n+import static org.mockito.Mockito.when;\r\n+\r\n+import org.junit.Before;\r\n+import org.junit.Test;\r\n+import org.mockito.Mock;\r\n+import org.mockito.Mockito;\r\n+import org.sonar.api.batch.SensorContext;\r\n+import org.sonar.api.issue.ProjectIssues;\r\n+import org.sonar.api.resources.Project;\r\n+import org.sonar.plugins.stash.client.StashClient;\r\n+import org.sonar.plugins.stash.client.StashCredentials;\r\n+import org.sonar.plugins.stash.issue.SonarQubeIssuesReport;\r\n+\r\n+\r\n+public class StashIssueReportingPostJobTest {\r\n+  \r\n+  @Mock\r\n+  StashRequestFacade stashRequestFacade;\r\n+  \r\n+  @Mock\r\n+  StashPluginConfiguration config;\r\n+  \r\n+  @Mock\r\n+  ProjectIssues projectIssues;\r\n+  \r\n+  @Mock\r\n+  InputFileCache inputFileCache;\r\n+  \r\n+  @Mock\r\n+  Project project;\r\n+  \r\n+  @Mock\r\n+  SensorContext context;\r\n+  \r\n+  private static final String STASH_PROJECT = \"Project\";\r\n+  private static final String STASH_REPOSITORY = \"Repository\";\r\n+  private static final String STASH_PULLREQUEST_ID = \"1\";\r\n+  private static final String STASH_LOGIN = \"login\";\r\n+  private static final String STASH_PASSWORD = \"password\";\r\n+  private static final String STASH_URL = \"http://url/to/stash\";\r\n+  private static final int STASH_TIMEOUT = 10000;\r\n+\r\n+  private static final String SONARQUBE_URL = \"http://url/to/sonarqube\";\r\n+  \r\n+  @Before\r\n+  public void setUp() throws Exception {\r\n+    projectIssues = mock(ProjectIssues.class);\r\n+    inputFileCache = mock(InputFileCache.class);\r\n+    \r\n+    project = new Project(\"1\");\r\n+    context = mock(SensorContext.class);\r\n+    \r\n+    config = mock(StashPluginConfiguration.class);\r\n+    when(config.getStashURL()).thenReturn(STASH_URL);\r\n+    when(config.getSonarQubeURL()).thenReturn(SONARQUBE_URL);\r\n+    when(config.getStashTimeout()).thenReturn(STASH_TIMEOUT);\r\n+    \r\n+    stashRequestFacade = mock(StashRequestFacade.class);\r\n+    when(stashRequestFacade.getStashProject()).thenReturn(STASH_PROJECT);\r\n+    when(stashRequestFacade.getStashRepository()).thenReturn(STASH_REPOSITORY);\r\n+    when(stashRequestFacade.getStashPullRequestId()).thenReturn(STASH_PULLREQUEST_ID);\r\n+    when(stashRequestFacade.getCredentials()).thenReturn(new StashCredentials(STASH_LOGIN, STASH_PASSWORD));\r\n+  }\r\n+  \r\n+  @Test\r\n+  public void testExecuteOn() throws Exception {\r\n+    when(config.hasToNotifyStash()).thenReturn(true);\r\n+    \r\n+    SonarQubeIssuesReport report = mock(SonarQubeIssuesReport.class);\r\n+    when(report.countIssues()).thenReturn(10);\r\n+    when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report);\r\n+    \r\n+    int issueThreshold = 100;\r\n+    when(stashRequestFacade.getIssueThreshold()).thenReturn(issueThreshold);\r\n+    \r\n+    StashIssueReportingPostJob job = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);\r","path":"src/test/java/org/sonar/plugins/stash/StashIssueReportingPostJobTest.java","position":null,"original_position":82,"commit_id":"302b5da8b7dc7ca08e419dccdf83f2f85aa4d2c0","original_commit_id":"a983ec5e38927969034a92104d9f5b3c07b23a33","user":{"login":"acopet","id":14331633,"avatar_url":"https://avatars.githubusercontent.com/u/14331633?v=3","gravatar_id":"","url":"https://api.github.com/users/acopet","html_url":"https://github.com/acopet","followers_url":"https://api.github.com/users/acopet/followers","following_url":"https://api.github.com/users/acopet/following{/other_user}","gists_url":"https://api.github.com/users/acopet/gists{/gist_id}","starred_url":"https://api.github.com/users/acopet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acopet/subscriptions","organizations_url":"https://api.github.com/users/acopet/orgs","repos_url":"https://api.github.com/users/acopet/repos","events_url":"https://api.github.com/users/acopet/events{/privacy}","received_events_url":"https://api.github.com/users/acopet/received_events","type":"User","site_admin":false},"body":"Done!","created_at":"2015-10-13T20:42:37Z","updated_at":"2015-10-13T20:42:37Z","html_url":"https://github.com/AmadeusITGroup/sonar-stash/pull/5#discussion_r41921943","pull_request_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/comments/41921943"},"html":{"href":"https://github.com/AmadeusITGroup/sonar-stash/pull/5#discussion_r41921943"},"pull_request":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5","id":47000595,"html_url":"https://github.com/AmadeusITGroup/sonar-stash/pull/5","diff_url":"https://github.com/AmadeusITGroup/sonar-stash/pull/5.diff","patch_url":"https://github.com/AmadeusITGroup/sonar-stash/pull/5.patch","issue_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues/5","number":5,"state":"open","locked":false,"title":"Integrate first code quality analysis outcomes from SonarQube (Nemo)","user":{"login":"acopet","id":14331633,"avatar_url":"https://avatars.githubusercontent.com/u/14331633?v=3","gravatar_id":"","url":"https://api.github.com/users/acopet","html_url":"https://github.com/acopet","followers_url":"https://api.github.com/users/acopet/followers","following_url":"https://api.github.com/users/acopet/following{/other_user}","gists_url":"https://api.github.com/users/acopet/gists{/gist_id}","starred_url":"https://api.github.com/users/acopet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acopet/subscriptions","organizations_url":"https://api.github.com/users/acopet/orgs","repos_url":"https://api.github.com/users/acopet/repos","events_url":"https://api.github.com/users/acopet/events{/privacy}","received_events_url":"https://api.github.com/users/acopet/received_events","type":"User","site_admin":false},"body":"Resolve SonarQube issues detected by first Nemo run. Improve Code coverage.\r\nLinked to issue #2.","created_at":"2015-10-07T08:46:41Z","updated_at":"2015-10-13T20:42:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"07c26287150d7b8ceaeb7380c86bf159e3617804","assignee":{"login":"acopet","id":14331633,"avatar_url":"https://avatars.githubusercontent.com/u/14331633?v=3","gravatar_id":"","url":"https://api.github.com/users/acopet","html_url":"https://github.com/acopet","followers_url":"https://api.github.com/users/acopet/followers","following_url":"https://api.github.com/users/acopet/following{/other_user}","gists_url":"https://api.github.com/users/acopet/gists{/gist_id}","starred_url":"https://api.github.com/users/acopet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acopet/subscriptions","organizations_url":"https://api.github.com/users/acopet/orgs","repos_url":"https://api.github.com/users/acopet/repos","events_url":"https://api.github.com/users/acopet/events{/privacy}","received_events_url":"https://api.github.com/users/acopet/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5/commits","review_comments_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5/comments","review_comment_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues/5/comments","statuses_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/statuses/302b5da8b7dc7ca08e419dccdf83f2f85aa4d2c0","head":{"label":"acopet:nemo-issues","ref":"nemo-issues","sha":"302b5da8b7dc7ca08e419dccdf83f2f85aa4d2c0","user":{"login":"acopet","id":14331633,"avatar_url":"https://avatars.githubusercontent.com/u/14331633?v=3","gravatar_id":"","url":"https://api.github.com/users/acopet","html_url":"https://github.com/acopet","followers_url":"https://api.github.com/users/acopet/followers","following_url":"https://api.github.com/users/acopet/following{/other_user}","gists_url":"https://api.github.com/users/acopet/gists{/gist_id}","starred_url":"https://api.github.com/users/acopet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acopet/subscriptions","organizations_url":"https://api.github.com/users/acopet/orgs","repos_url":"https://api.github.com/users/acopet/repos","events_url":"https://api.github.com/users/acopet/events{/privacy}","received_events_url":"https://api.github.com/users/acopet/received_events","type":"User","site_admin":false},"repo":{"id":43247648,"name":"sonar-stash","full_name":"acopet/sonar-stash","owner":{"login":"acopet","id":14331633,"avatar_url":"https://avatars.githubusercontent.com/u/14331633?v=3","gravatar_id":"","url":"https://api.github.com/users/acopet","html_url":"https://github.com/acopet","followers_url":"https://api.github.com/users/acopet/followers","following_url":"https://api.github.com/users/acopet/following{/other_user}","gists_url":"https://api.github.com/users/acopet/gists{/gist_id}","starred_url":"https://api.github.com/users/acopet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acopet/subscriptions","organizations_url":"https://api.github.com/users/acopet/orgs","repos_url":"https://api.github.com/users/acopet/repos","events_url":"https://api.github.com/users/acopet/events{/privacy}","received_events_url":"https://api.github.com/users/acopet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/acopet/sonar-stash","description":"","fork":true,"url":"https://api.github.com/repos/acopet/sonar-stash","forks_url":"https://api.github.com/repos/acopet/sonar-stash/forks","keys_url":"https://api.github.com/repos/acopet/sonar-stash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/acopet/sonar-stash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/acopet/sonar-stash/teams","hooks_url":"https://api.github.com/repos/acopet/sonar-stash/hooks","issue_events_url":"https://api.github.com/repos/acopet/sonar-stash/issues/events{/number}","events_url":"https://api.github.com/repos/acopet/sonar-stash/events","assignees_url":"https://api.github.com/repos/acopet/sonar-stash/assignees{/user}","branches_url":"https://api.github.com/repos/acopet/sonar-stash/branches{/branch}","tags_url":"https://api.github.com/repos/acopet/sonar-stash/tags","blobs_url":"https://api.github.com/repos/acopet/sonar-stash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/acopet/sonar-stash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/acopet/sonar-stash/git/refs{/sha}","trees_url":"https://api.github.com/repos/acopet/sonar-stash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/acopet/sonar-stash/statuses/{sha}","languages_url":"https://api.github.com/repos/acopet/sonar-stash/languages","stargazers_url":"https://api.github.com/repos/acopet/sonar-stash/stargazers","contributors_url":"https://api.github.com/repos/acopet/sonar-stash/contributors","subscribers_url":"https://api.github.com/repos/acopet/sonar-stash/subscribers","subscription_url":"https://api.github.com/repos/acopet/sonar-stash/subscription","commits_url":"https://api.github.com/repos/acopet/sonar-stash/commits{/sha}","git_commits_url":"https://api.github.com/repos/acopet/sonar-stash/git/commits{/sha}","comments_url":"https://api.github.com/repos/acopet/sonar-stash/comments{/number}","issue_comment_url":"https://api.github.com/repos/acopet/sonar-stash/issues/comments{/number}","contents_url":"https://api.github.com/repos/acopet/sonar-stash/contents/{+path}","compare_url":"https://api.github.com/repos/acopet/sonar-stash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/acopet/sonar-stash/merges","archive_url":"https://api.github.com/repos/acopet/sonar-stash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/acopet/sonar-stash/downloads","issues_url":"https://api.github.com/repos/acopet/sonar-stash/issues{/number}","pulls_url":"https://api.github.com/repos/acopet/sonar-stash/pulls{/number}","milestones_url":"https://api.github.com/repos/acopet/sonar-stash/milestones{/number}","notifications_url":"https://api.github.com/repos/acopet/sonar-stash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/acopet/sonar-stash/labels{/name}","releases_url":"https://api.github.com/repos/acopet/sonar-stash/releases{/id}","created_at":"2015-09-27T13:32:17Z","updated_at":"2015-09-27T13:32:18Z","pushed_at":"2015-10-13T20:41:04Z","git_url":"git://github.com/acopet/sonar-stash.git","ssh_url":"git@github.com:acopet/sonar-stash.git","clone_url":"https://github.com/acopet/sonar-stash.git","svn_url":"https://github.com/acopet/sonar-stash","homepage":null,"size":367,"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":"AmadeusITGroup:master","ref":"master","sha":"c39b18f216a9cd15bd5d61a1da4dc4effb3619a9","user":{"login":"AmadeusITGroup","id":6802338,"avatar_url":"https://avatars.githubusercontent.com/u/6802338?v=3","gravatar_id":"","url":"https://api.github.com/users/AmadeusITGroup","html_url":"https://github.com/AmadeusITGroup","followers_url":"https://api.github.com/users/AmadeusITGroup/followers","following_url":"https://api.github.com/users/AmadeusITGroup/following{/other_user}","gists_url":"https://api.github.com/users/AmadeusITGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/AmadeusITGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmadeusITGroup/subscriptions","organizations_url":"https://api.github.com/users/AmadeusITGroup/orgs","repos_url":"https://api.github.com/users/AmadeusITGroup/repos","events_url":"https://api.github.com/users/AmadeusITGroup/events{/privacy}","received_events_url":"https://api.github.com/users/AmadeusITGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":42864318,"name":"sonar-stash","full_name":"AmadeusITGroup/sonar-stash","owner":{"login":"AmadeusITGroup","id":6802338,"avatar_url":"https://avatars.githubusercontent.com/u/6802338?v=3","gravatar_id":"","url":"https://api.github.com/users/AmadeusITGroup","html_url":"https://github.com/AmadeusITGroup","followers_url":"https://api.github.com/users/AmadeusITGroup/followers","following_url":"https://api.github.com/users/AmadeusITGroup/following{/other_user}","gists_url":"https://api.github.com/users/AmadeusITGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/AmadeusITGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmadeusITGroup/subscriptions","organizations_url":"https://api.github.com/users/AmadeusITGroup/orgs","repos_url":"https://api.github.com/users/AmadeusITGroup/repos","events_url":"https://api.github.com/users/AmadeusITGroup/events{/privacy}","received_events_url":"https://api.github.com/users/AmadeusITGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AmadeusITGroup/sonar-stash","description":"","fork":false,"url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash","forks_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/forks","keys_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/teams","hooks_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/hooks","issue_events_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues/events{/number}","events_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/events","assignees_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/assignees{/user}","branches_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/branches{/branch}","tags_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/tags","blobs_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/git/refs{/sha}","trees_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/statuses/{sha}","languages_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/languages","stargazers_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/stargazers","contributors_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/contributors","subscribers_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/subscribers","subscription_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/subscription","commits_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/commits{/sha}","git_commits_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/git/commits{/sha}","comments_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/comments{/number}","issue_comment_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues/comments{/number}","contents_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/contents/{+path}","compare_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/merges","archive_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/downloads","issues_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues{/number}","pulls_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls{/number}","milestones_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/milestones{/number}","notifications_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/labels{/name}","releases_url":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/releases{/id}","created_at":"2015-09-21T12:15:13Z","updated_at":"2015-10-07T11:33:22Z","pushed_at":"2015-10-13T20:41:04Z","git_url":"git://github.com/AmadeusITGroup/sonar-stash.git","ssh_url":"git@github.com:AmadeusITGroup/sonar-stash.git","clone_url":"https://github.com/AmadeusITGroup/sonar-stash.git","svn_url":"https://github.com/AmadeusITGroup/sonar-stash","homepage":null,"size":515,"stargazers_count":13,"watchers_count":13,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":6,"forks":2,"open_issues":6,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5"},"html":{"href":"https://github.com/AmadeusITGroup/sonar-stash/pull/5"},"issue":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues/5"},"comments":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/AmadeusITGroup/sonar-stash/statuses/302b5da8b7dc7ca08e419dccdf83f2f85aa4d2c0"}}}}