{"action":"created","comment":{"url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/comments/167789191","pull_request_review_id":96056231,"id":167789191,"diff_hunk":"@@ -0,0 +1,143 @@\n+package fi.metatavu.soteapi.wnspusher;\n+\n+import static org.junit.Assert.assertEquals;\n+\n+import java.io.IOException;\n+import java.util.function.Supplier;\n+\n+import org.apache.http.ParseException;\n+import org.apache.http.StatusLine;\n+import org.apache.http.client.ClientProtocolException;\n+import org.apache.http.client.methods.CloseableHttpResponse;\n+import org.apache.http.client.methods.HttpPost;\n+import org.apache.http.impl.client.CloseableHttpClient;\n+import org.apache.http.util.EntityUtils;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.mockito.ArgumentCaptor;\n+import org.mockito.Mockito;\n+import org.slf4j.Logger;\n+\n+import com.fasterxml.jackson.core.JsonParseException;\n+import com.fasterxml.jackson.databind.JsonMappingException;\n+import com.fasterxml.jackson.databind.JsonNode;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+\n+import fi.metatavu.soteapi.settings.SystemSettingController;\n+\n+public class WnsPusherNotificationControllerTest {\n+  SystemSettingController systemSettingController;\n+  Logger logger;\n+  CloseableHttpClient httpClient;\n+  ArgumentCaptor<HttpPost> httpClientArguments;\n+  CloseableHttpResponse httpResponse;\n+  WnsPusherNotificationController subject;\n+\n+  @Before\n+  public void setUp() throws ClientProtocolException, IOException {\n+    systemSettingController = Mockito.mock(SystemSettingController.class);\n+    logger = Mockito.mock(Logger.class);\n+    httpClient = Mockito.mock(CloseableHttpClient.class);\n+    httpResponse = Mockito.mock(CloseableHttpResponse.class);\n+    httpClientArguments = ArgumentCaptor.forClass(HttpPost.class);\n+\n+    Supplier<CloseableHttpClient> httpClientSupplier = () -> httpClient;\n+    \n+    subject = new WnsPusherNotificationController(\n+        systemSettingController,\n+        logger,\n+        httpClientSupplier\n+    );\n+    \n+    Mockito\n+      .when(systemSettingController.getSettingValue(WnsPusherNotificationConsts.ENDPOINT_SETTING))\n+      .thenReturn(\"TEST_ENDPOINT\");\n+\n+    Mockito\n+      .when(systemSettingController.getSettingValue(WnsPusherNotificationConsts.API_KEY_SETTING))\n+      .thenReturn(\"TEST_API_KEY\");\n+\n+    Mockito\n+      .when(systemSettingController.getSettingValue(WnsPusherNotificationConsts.APP_SETTING))\n+      .thenReturn(\"TEST_APP\");\n+\n+    Mockito\n+      .when(httpClient.execute(httpClientArguments.capture()))\n+      .thenReturn(httpResponse);\n+    \n+    StatusLine statusLine = Mockito.mock(StatusLine.class);\n+    Mockito.when(statusLine.getStatusCode()).thenReturn(200);\n+    Mockito\n+      .when(httpResponse.getStatusLine())\n+      .thenReturn(statusLine);\n+  }\n+\n+  @Test\n+  public void testSendNotificationToTopic() {\n+    subject.sendNotificationToTopic(\"TEST_TOPIC\", \"TEST_TITLE\", \"TEST_MESSAGE\");\n+  }\n+\n+  @Test\n+  public void testSendNotificationHeader() {\n+    subject.sendNotificationToTopic(\"TEST_TOPIC\", \"TEST_TITLE\", \"TEST_MESSAGE\");\n+    assertEquals(httpClientArguments\n+                  .getValue()\n+                  .getLastHeader(\"Authorization\")\n+                  .getValue(),\n+                 \"APIKEY TEST_API_KEY\");\n+  }\n+\n+  @Test\n+  public void testSendNotificationApp()\n+      throws JsonParseException, JsonMappingException, ParseException, IOException {\n+    subject.sendNotificationToTopic(\"TEST_TOPIC\", \"TEST_TITLE\", \"TEST_MESSAGE\");\n+    ObjectMapper objectMapper = new ObjectMapper();\n+    HttpPost httpPost = httpClientArguments.getValue();\n+    JsonNode notification = objectMapper.readTree(EntityUtils.toString(httpPost.getEntity()));\n+    assertEquals(notification.get(\"app\").asText(), \"TEST_APP\");\n+  }\n+\n+  @Test\n+  public void testSendNotificationUrl()\n+      throws JsonParseException, JsonMappingException, ParseException, IOException {","path":"src/test/java/fi/metatavu/soteapi/wnspusher/WnsPusherNotificationControllerTest.java","position":102,"original_position":102,"commit_id":"24067b4348d6b33b6dbf376591f0ecae94630ac8","original_commit_id":"24067b4348d6b33b6dbf376591f0ecae94630ac8","user":{"login":"sonarq","id":21039853,"avatar_url":"https://avatars1.githubusercontent.com/u/21039853?v=4","gravatar_id":"","url":"https://api.github.com/users/sonarq","html_url":"https://github.com/sonarq","followers_url":"https://api.github.com/users/sonarq/followers","following_url":"https://api.github.com/users/sonarq/following{/other_user}","gists_url":"https://api.github.com/users/sonarq/gists{/gist_id}","starred_url":"https://api.github.com/users/sonarq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonarq/subscriptions","organizations_url":"https://api.github.com/users/sonarq/orgs","repos_url":"https://api.github.com/users/sonarq/repos","events_url":"https://api.github.com/users/sonarq/events{/privacy}","received_events_url":"https://api.github.com/users/sonarq/received_events","type":"User","site_admin":false},"body":"![MINOR](https://sonarsource.github.io/sonar-github/severity-minor.png 'Severity: MINOR') Remove the redundant '!unknownSymbol!' thrown exception declaration(s). [![rule](https://sonarsource.github.io/sonar-github/rule.png)](https://sonarcloud.io/coding_rules#rule_key=squid%3ARedundantThrowsDeclarationCheck)\n","created_at":"2018-02-13T08:29:06Z","updated_at":"2018-02-13T08:29:06Z","html_url":"https://github.com/Metatavu/soteapi-server/pull/53#discussion_r167789191","pull_request_url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/comments/167789191"},"html":{"href":"https://github.com/Metatavu/soteapi-server/pull/53#discussion_r167789191"},"pull_request":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53","id":168780159,"html_url":"https://github.com/Metatavu/soteapi-server/pull/53","diff_url":"https://github.com/Metatavu/soteapi-server/pull/53.diff","patch_url":"https://github.com/Metatavu/soteapi-server/pull/53.patch","issue_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues/53","number":53,"state":"open","locked":false,"title":"Feature #52 push notifications for Windows Phone","user":{"login":"ilmoeuro","id":1074146,"avatar_url":"https://avatars2.githubusercontent.com/u/1074146?v=4","gravatar_id":"","url":"https://api.github.com/users/ilmoeuro","html_url":"https://github.com/ilmoeuro","followers_url":"https://api.github.com/users/ilmoeuro/followers","following_url":"https://api.github.com/users/ilmoeuro/following{/other_user}","gists_url":"https://api.github.com/users/ilmoeuro/gists{/gist_id}","starred_url":"https://api.github.com/users/ilmoeuro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilmoeuro/subscriptions","organizations_url":"https://api.github.com/users/ilmoeuro/orgs","repos_url":"https://api.github.com/users/ilmoeuro/repos","events_url":"https://api.github.com/users/ilmoeuro/events{/privacy}","received_events_url":"https://api.github.com/users/ilmoeuro/received_events","type":"User","site_admin":false},"body":"Resolves #52 push notifications for Windows Phone","created_at":"2018-02-13T08:25:52Z","updated_at":"2018-02-13T08:29:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c20b3e00cf289122ac3c2d954288fe2da3464ee1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53/commits","review_comments_url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53/comments","review_comment_url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues/53/comments","statuses_url":"https://api.github.com/repos/Metatavu/soteapi-server/statuses/24067b4348d6b33b6dbf376591f0ecae94630ac8","head":{"label":"Metatavu:feature-#52-Push-notifications-for-Windows-Phone","ref":"feature-#52-Push-notifications-for-Windows-Phone","sha":"24067b4348d6b33b6dbf376591f0ecae94630ac8","user":{"login":"Metatavu","id":20443466,"avatar_url":"https://avatars0.githubusercontent.com/u/20443466?v=4","gravatar_id":"","url":"https://api.github.com/users/Metatavu","html_url":"https://github.com/Metatavu","followers_url":"https://api.github.com/users/Metatavu/followers","following_url":"https://api.github.com/users/Metatavu/following{/other_user}","gists_url":"https://api.github.com/users/Metatavu/gists{/gist_id}","starred_url":"https://api.github.com/users/Metatavu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metatavu/subscriptions","organizations_url":"https://api.github.com/users/Metatavu/orgs","repos_url":"https://api.github.com/users/Metatavu/repos","events_url":"https://api.github.com/users/Metatavu/events{/privacy}","received_events_url":"https://api.github.com/users/Metatavu/received_events","type":"Organization","site_admin":false},"repo":{"id":106740526,"name":"soteapi-server","full_name":"Metatavu/soteapi-server","owner":{"login":"Metatavu","id":20443466,"avatar_url":"https://avatars0.githubusercontent.com/u/20443466?v=4","gravatar_id":"","url":"https://api.github.com/users/Metatavu","html_url":"https://github.com/Metatavu","followers_url":"https://api.github.com/users/Metatavu/followers","following_url":"https://api.github.com/users/Metatavu/following{/other_user}","gists_url":"https://api.github.com/users/Metatavu/gists{/gist_id}","starred_url":"https://api.github.com/users/Metatavu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metatavu/subscriptions","organizations_url":"https://api.github.com/users/Metatavu/orgs","repos_url":"https://api.github.com/users/Metatavu/repos","events_url":"https://api.github.com/users/Metatavu/events{/privacy}","received_events_url":"https://api.github.com/users/Metatavu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metatavu/soteapi-server","description":null,"fork":false,"url":"https://api.github.com/repos/Metatavu/soteapi-server","forks_url":"https://api.github.com/repos/Metatavu/soteapi-server/forks","keys_url":"https://api.github.com/repos/Metatavu/soteapi-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metatavu/soteapi-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metatavu/soteapi-server/teams","hooks_url":"https://api.github.com/repos/Metatavu/soteapi-server/hooks","issue_events_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues/events{/number}","events_url":"https://api.github.com/repos/Metatavu/soteapi-server/events","assignees_url":"https://api.github.com/repos/Metatavu/soteapi-server/assignees{/user}","branches_url":"https://api.github.com/repos/Metatavu/soteapi-server/branches{/branch}","tags_url":"https://api.github.com/repos/Metatavu/soteapi-server/tags","blobs_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metatavu/soteapi-server/statuses/{sha}","languages_url":"https://api.github.com/repos/Metatavu/soteapi-server/languages","stargazers_url":"https://api.github.com/repos/Metatavu/soteapi-server/stargazers","contributors_url":"https://api.github.com/repos/Metatavu/soteapi-server/contributors","subscribers_url":"https://api.github.com/repos/Metatavu/soteapi-server/subscribers","subscription_url":"https://api.github.com/repos/Metatavu/soteapi-server/subscription","commits_url":"https://api.github.com/repos/Metatavu/soteapi-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metatavu/soteapi-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metatavu/soteapi-server/contents/{+path}","compare_url":"https://api.github.com/repos/Metatavu/soteapi-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metatavu/soteapi-server/merges","archive_url":"https://api.github.com/repos/Metatavu/soteapi-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metatavu/soteapi-server/downloads","issues_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues{/number}","pulls_url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls{/number}","milestones_url":"https://api.github.com/repos/Metatavu/soteapi-server/milestones{/number}","notifications_url":"https://api.github.com/repos/Metatavu/soteapi-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metatavu/soteapi-server/labels{/name}","releases_url":"https://api.github.com/repos/Metatavu/soteapi-server/releases{/id}","deployments_url":"https://api.github.com/repos/Metatavu/soteapi-server/deployments","created_at":"2017-10-12T20:12:49Z","updated_at":"2017-10-13T00:03:02Z","pushed_at":"2018-02-13T08:25:53Z","git_url":"git://github.com/Metatavu/soteapi-server.git","ssh_url":"git@github.com:Metatavu/soteapi-server.git","clone_url":"https://github.com/Metatavu/soteapi-server.git","svn_url":"https://github.com/Metatavu/soteapi-server","homepage":null,"size":214,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"Metatavu:develop","ref":"develop","sha":"2ff343e0c8da233e5bb8c66d440492d4382f2db9","user":{"login":"Metatavu","id":20443466,"avatar_url":"https://avatars0.githubusercontent.com/u/20443466?v=4","gravatar_id":"","url":"https://api.github.com/users/Metatavu","html_url":"https://github.com/Metatavu","followers_url":"https://api.github.com/users/Metatavu/followers","following_url":"https://api.github.com/users/Metatavu/following{/other_user}","gists_url":"https://api.github.com/users/Metatavu/gists{/gist_id}","starred_url":"https://api.github.com/users/Metatavu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metatavu/subscriptions","organizations_url":"https://api.github.com/users/Metatavu/orgs","repos_url":"https://api.github.com/users/Metatavu/repos","events_url":"https://api.github.com/users/Metatavu/events{/privacy}","received_events_url":"https://api.github.com/users/Metatavu/received_events","type":"Organization","site_admin":false},"repo":{"id":106740526,"name":"soteapi-server","full_name":"Metatavu/soteapi-server","owner":{"login":"Metatavu","id":20443466,"avatar_url":"https://avatars0.githubusercontent.com/u/20443466?v=4","gravatar_id":"","url":"https://api.github.com/users/Metatavu","html_url":"https://github.com/Metatavu","followers_url":"https://api.github.com/users/Metatavu/followers","following_url":"https://api.github.com/users/Metatavu/following{/other_user}","gists_url":"https://api.github.com/users/Metatavu/gists{/gist_id}","starred_url":"https://api.github.com/users/Metatavu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metatavu/subscriptions","organizations_url":"https://api.github.com/users/Metatavu/orgs","repos_url":"https://api.github.com/users/Metatavu/repos","events_url":"https://api.github.com/users/Metatavu/events{/privacy}","received_events_url":"https://api.github.com/users/Metatavu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metatavu/soteapi-server","description":null,"fork":false,"url":"https://api.github.com/repos/Metatavu/soteapi-server","forks_url":"https://api.github.com/repos/Metatavu/soteapi-server/forks","keys_url":"https://api.github.com/repos/Metatavu/soteapi-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metatavu/soteapi-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metatavu/soteapi-server/teams","hooks_url":"https://api.github.com/repos/Metatavu/soteapi-server/hooks","issue_events_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues/events{/number}","events_url":"https://api.github.com/repos/Metatavu/soteapi-server/events","assignees_url":"https://api.github.com/repos/Metatavu/soteapi-server/assignees{/user}","branches_url":"https://api.github.com/repos/Metatavu/soteapi-server/branches{/branch}","tags_url":"https://api.github.com/repos/Metatavu/soteapi-server/tags","blobs_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metatavu/soteapi-server/statuses/{sha}","languages_url":"https://api.github.com/repos/Metatavu/soteapi-server/languages","stargazers_url":"https://api.github.com/repos/Metatavu/soteapi-server/stargazers","contributors_url":"https://api.github.com/repos/Metatavu/soteapi-server/contributors","subscribers_url":"https://api.github.com/repos/Metatavu/soteapi-server/subscribers","subscription_url":"https://api.github.com/repos/Metatavu/soteapi-server/subscription","commits_url":"https://api.github.com/repos/Metatavu/soteapi-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metatavu/soteapi-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metatavu/soteapi-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metatavu/soteapi-server/contents/{+path}","compare_url":"https://api.github.com/repos/Metatavu/soteapi-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metatavu/soteapi-server/merges","archive_url":"https://api.github.com/repos/Metatavu/soteapi-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metatavu/soteapi-server/downloads","issues_url":"https://api.github.com/repos/Metatavu/soteapi-server/issues{/number}","pulls_url":"https://api.github.com/repos/Metatavu/soteapi-server/pulls{/number}","milestones_url":"https://api.github.com/repos/Metatavu/soteapi-server/milestones{/number}","notifications_url":"https://api.github.com/repos/Metatavu/soteapi-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metatavu/soteapi-server/labels{/name}","releases_url":"https://api.github.com/repos/Metatavu/soteapi-server/releases{/id}","deployments_url":"https://api.github.com/repos/Metatavu/soteapi-server/deployments","created_at":"2017-10-12T20:12:49Z","updated_at":"2017-10-13T00:03:02Z","pushed_at":"2018-02-13T08:25:53Z","git_url":"git://github.com/Metatavu/soteapi-server.git","ssh_url":"git@github.com:Metatavu/soteapi-server.git","clone_url":"https://github.com/Metatavu/soteapi-server.git","svn_url":"https://github.com/Metatavu/soteapi-server","homepage":null,"size":214,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53"},"html":{"href":"https://github.com/Metatavu/soteapi-server/pull/53"},"issue":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/issues/53"},"comments":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/Metatavu/soteapi-server/statuses/24067b4348d6b33b6dbf376591f0ecae94630ac8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sonarq"}}