{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/96452740","pull_request_review_id":17034803,"id":96452740,"diff_hunk":"@@ -0,0 +1,349 @@\n+/****************************************************************\n+ * Licensed to the Apache Software Foundation (ASF) under one   *\n+ * or more contributor license agreements.  See the NOTICE file *\n+ * distributed with this work for additional information        *\n+ * regarding copyright ownership.  The ASF licenses this file   *\n+ * to you under the Apache License, Version 2.0 (the            *\n+ * \"License\"); you may not use this file except in compliance   *\n+ * with the License.  You may obtain a copy of the License at   *\n+ *                                                              *\n+ *   http://www.apache.org/licenses/LICENSE-2.0                 *\n+ *                                                              *\n+ * Unless required by applicable law or agreed to in writing,   *\n+ * software distributed under the License is distributed on an  *\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *\n+ * KIND, either express or implied.  See the License for the    *\n+ * specific language governing permissions and limitations      *\n+ * under the License.                                           *\n+ ****************************************************************/\n+\n+package org.apache.james.transport.mailets;\n+\n+import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;\n+import static org.assertj.core.api.Assertions.assertThat;\n+\n+import java.util.List;\n+import java.util.Map;\n+import java.util.stream.Collectors;\n+\n+import javax.mail.MessagingException;\n+\n+import org.apache.mailet.Mail;\n+import org.apache.mailet.MailAddress;\n+import org.apache.mailet.base.MailAddressFixture;\n+import org.apache.mailet.base.test.FakeMail;\n+import org.apache.mailet.base.test.FakeMailetConfig;\n+import org.junit.Before;\n+import org.junit.Rule;\n+import org.junit.Test;\n+import org.junit.rules.ExpectedException;\n+\n+import com.google.common.base.Charsets;\n+import com.google.common.collect.ImmutableMap;\n+\n+import net.fortuna.ical4j.data.CalendarBuilder;\n+import net.fortuna.ical4j.model.Calendar;\n+\n+public class ICALToJsonAttributeTest {\n+    public static final MailAddress SENDER = MailAddressFixture.ANY_AT_JAMES;\n+\n+    @Rule\n+    public ExpectedException expectedException = ExpectedException.none();\n+\n+    private ICALToJsonAttribute testee;\n+\n+    @Before\n+    public void setUp() {\n+        testee = new ICALToJsonAttribute();\n+    }\n+\n+    @Test\n+    public void getMailetInfoShouldReturnExpectedValue() throws Exception {\n+        assertThat(testee.getMailetInfo()).isEqualTo(\"ICALToJson Mailet\");\n+    }\n+\n+    @Test\n+    public void initShouldSetAttributesWhenAbsent() throws Exception {\n+        testee.init(FakeMailetConfig.builder().build());\n+\n+        assertThat(testee.getSourceAttributeName()).isEqualTo(ICALToJsonAttribute.DEFAULT_SOURCE_ATTRIBUTE_NAME);\n+        assertThat(testee.getDestinationAttributeName()).isEqualTo(ICALToJsonAttribute.DEFAULT_DESTINATION_ATTRIBUTE_NAME);\n+    }\n+\n+    @Test\n+    public void initShouldThrowOnEmptySourceAttribute() throws Exception {\n+        expectedException.expect(MessagingException.class);\n+\n+        testee.init(FakeMailetConfig.builder()\n+            .setProperty(ICALToJsonAttribute.SOURCE_ATTRIBUTE_NAME, \"\")\n+            .build());\n+    }\n+\n+    @Test\n+    public void initShouldThrowOnEmptyDestinationAttribute() throws Exception {\n+        expectedException.expect(MessagingException.class);\n+\n+        testee.init(FakeMailetConfig.builder()\n+            .setProperty(ICALToJsonAttribute.DESTINATION_ATTRIBUTE_NAME, \"\")\n+            .build());\n+    }\n+\n+    @Test\n+    public void initShouldSetAttributesWhenPresent() throws Exception {\n+        String destination = \"myDestination\";\n+        String source = \"mySource\";\n+        testee.init(FakeMailetConfig.builder()\n+            .setProperty(ICALToJsonAttribute.SOURCE_ATTRIBUTE_NAME, source)\n+            .setProperty(ICALToJsonAttribute.DESTINATION_ATTRIBUTE_NAME, destination)\n+            .build());\n+\n+        assertThat(testee.getSourceAttributeName()).isEqualTo(source);\n+        assertThat(testee.getDestinationAttributeName()).isEqualTo(destination);\n+    }\n+\n+    @Test\n+    public void serviceShouldFilterMailsWithoutICALs() throws Exception {\n+        testee.init(FakeMailetConfig.builder().build());\n+\n+        Mail mail = FakeMail.builder()\n+            .sender(SENDER)\n+            .recipient(MailAddressFixture.OTHER_AT_JAMES)\n+            .build();\n+        testee.service(mail);\n+\n+        assertThat(mail.getAttribute(ICALToJsonAttribute.DEFAULT_DESTINATION_ATTRIBUTE_NAME))\n+            .isNull();\n+    }\n+\n+    @Test\n+    public void serviceShouldNotFailOnWrongAttributeType() throws Exception {\n+        testee.init(FakeMailetConfig.builder().build());\n+\n+        Mail mail = FakeMail.builder()\n+            .sender(SENDER)\n+            .recipient(MailAddressFixture.OTHER_AT_JAMES)\n+            .attribute(ICALToJsonAttribute.DEFAULT_SOURCE_ATTRIBUTE_NAME, \"wrong type\")\n+            .build();\n+        testee.service(mail);\n+\n+        assertThat(mail.getAttribute(ICALToJsonAttribute.DEFAULT_DESTINATION_ATTRIBUTE_NAME))\n+            .isNull();\n+    }\n+\n+    @Test\n+    public void serviceShouldNotFailOnWrongAttributeParameter() throws Exception {\n+        testee.init(FakeMailetConfig.builder().build());\n+\n+        ImmutableMap<String, String> wrongParametrizedMap = ImmutableMap.<String, String>builder()\n+            .put(\"key\", \"value\")\n+            .build();\n+        Mail mail = FakeMail.builder()\n+            .sender(SENDER)\n+            .recipient(MailAddressFixture.OTHER_AT_JAMES)\n+            .attribute(ICALToJsonAttribute.DEFAULT_SOURCE_ATTRIBUTE_NAME, wrongParametrizedMap)\n+            .build();\n+        testee.service(mail);\n+\n+        assertThat(mail.getAttribute(ICALToJsonAttribute.DEFAULT_DESTINATION_ATTRIBUTE_NAME))\n+            .isNull();\n+    }\n+\n+    @Test\n+    public void serviceShouldFilterMailsWithoutSender() throws Exception {","path":"mailet/icalendar/src/test/java/org/apache/james/transport/mailets/ICALToJsonAttributeTest.java","position":152,"original_position":152,"commit_id":"e4a939b3b02a68f215463f414c0e4a1f93a09234","original_commit_id":"e4a939b3b02a68f215463f414c0e4a1f93a09234","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"Required property in json?","created_at":"2017-01-17T16:37:41Z","updated_at":"2017-01-17T16:37:41Z","html_url":"https://github.com/linagora/james-project/pull/567#discussion_r96452740","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/567","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/96452740"},"html":{"href":"https://github.com/linagora/james-project/pull/567#discussion_r96452740"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/567"}}},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/567","id":101627945,"html_url":"https://github.com/linagora/james-project/pull/567","diff_url":"https://github.com/linagora/james-project/pull/567.diff","patch_url":"https://github.com/linagora/james-project/pull/567.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/567","number":567,"state":"open","locked":false,"title":"Mailet 148 ICALToJsonAttribute mailet","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"Only the last commit to review (uses test data of MAILET-146)","created_at":"2017-01-16T04:13:20Z","updated_at":"2017-01-17T16:37:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef8e85488fd6c2835282d730dd3fb7583ccde76d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/567/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/567/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/567/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/e4a939b3b02a68f215463f414c0e4a1f93a09234","head":{"label":"chibenwa:MAILET-148","ref":"MAILET-148","sha":"e4a939b3b02a68f215463f414c0e4a1f93a09234","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"repo":{"id":42459504,"name":"james-project","full_name":"chibenwa/james-project","owner":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chibenwa/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/chibenwa/james-project","forks_url":"https://api.github.com/repos/chibenwa/james-project/forks","keys_url":"https://api.github.com/repos/chibenwa/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chibenwa/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chibenwa/james-project/teams","hooks_url":"https://api.github.com/repos/chibenwa/james-project/hooks","issue_events_url":"https://api.github.com/repos/chibenwa/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/chibenwa/james-project/events","assignees_url":"https://api.github.com/repos/chibenwa/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/chibenwa/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/chibenwa/james-project/tags","blobs_url":"https://api.github.com/repos/chibenwa/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chibenwa/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chibenwa/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/chibenwa/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chibenwa/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/chibenwa/james-project/languages","stargazers_url":"https://api.github.com/repos/chibenwa/james-project/stargazers","contributors_url":"https://api.github.com/repos/chibenwa/james-project/contributors","subscribers_url":"https://api.github.com/repos/chibenwa/james-project/subscribers","subscription_url":"https://api.github.com/repos/chibenwa/james-project/subscription","commits_url":"https://api.github.com/repos/chibenwa/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/chibenwa/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/chibenwa/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/chibenwa/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/chibenwa/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/chibenwa/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chibenwa/james-project/merges","archive_url":"https://api.github.com/repos/chibenwa/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chibenwa/james-project/downloads","issues_url":"https://api.github.com/repos/chibenwa/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/chibenwa/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/chibenwa/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/chibenwa/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chibenwa/james-project/labels{/name}","releases_url":"https://api.github.com/repos/chibenwa/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/chibenwa/james-project/deployments","created_at":"2015-09-14T15:57:25Z","updated_at":"2016-01-24T14:16:15Z","pushed_at":"2017-01-17T08:09:52Z","git_url":"git://github.com/chibenwa/james-project.git","ssh_url":"git@github.com:chibenwa/james-project.git","clone_url":"https://github.com/chibenwa/james-project.git","svn_url":"https://github.com/chibenwa/james-project","homepage":null,"size":17830,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"linagora:master","ref":"master","sha":"8256ad1b3a2b7350074ca3c12e82363ab2a48695","user":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2017-01-16T04:13:23Z","pushed_at":"2017-01-17T15:47:03Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":16750,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":32,"forks":14,"open_issues":32,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/567"},"html":{"href":"https://github.com/linagora/james-project/pull/567"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/567"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/567/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/567/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/567/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/e4a939b3b02a68f215463f414c0e4a1f93a09234"}}}}
{"actor":{"display_login":"chibenwa"}}