james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/3] james-project git commit: MAILBOX-310 Rename ACLDiff
Date Thu, 19 Oct 2017 01:55:56 GMT
Repository: james-project
Updated Branches:
  refs/heads/master a1c4f1bfe -> ee233b34e


MAILBOX-310 Rename ACLDiff


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ee233b34
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ee233b34
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ee233b34

Branch: refs/heads/master
Commit: ee233b34e9553b17b630e0a77c4a954f2fd4eb62
Parents: 3cdb45a
Author: benwa <btellier@linagora.com>
Authored: Tue Oct 10 17:02:38 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Thu Oct 19 08:55:21 2017 +0700

----------------------------------------------------------------------
 .../org/apache/james/mailbox/acl/ACLDiff.java   |  70 ------
 .../james/mailbox/acl/PositiveUserACLDiff.java  |  70 ++++++
 .../apache/james/mailbox/acl/ACLDiffTest.java   | 238 -------------------
 .../mailbox/acl/PositiveUserACLDiffTest.java    | 238 +++++++++++++++++++
 .../mail/CassandraUserMailboxRightsDAO.java     |  11 +-
 5 files changed, 313 insertions(+), 314 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ee233b34/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java
deleted file mode 100644
index 847fa43..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.acl;
-
-import java.util.Map;
-import java.util.stream.Stream;
-
-import org.apache.james.mailbox.model.MailboxACL;
-
-public class ACLDiff {
-
-    public static ACLDiff from(MailboxACL oldACL, MailboxACL newACL) {
-        return new ACLDiff(oldACL, newACL);
-    }
-
-    private final MailboxACL oldACL;
-    private final MailboxACL newACL;
-
-    private ACLDiff(MailboxACL oldACL, MailboxACL newACL) {
-        this.oldACL = oldACL;
-        this.newACL = newACL;
-    }
-
-    public Stream<MailboxACL.Entry> addedEntries() {
-        Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user);
-
-        return newACL.ofPositiveNameType(MailboxACL.NameType.user)
-            .entrySet()
-            .stream()
-            .filter(entry -> !oldEntries.containsKey(entry.getKey()))
-            .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
-    }
-
-    public Stream<MailboxACL.Entry> removedEntries() {
-        Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> newEntries = newACL.ofPositiveNameType(MailboxACL.NameType.user);
-
-        return oldACL.ofPositiveNameType(MailboxACL.NameType.user)
-            .entrySet()
-            .stream()
-            .filter(entry -> !newEntries.containsKey(entry.getKey()))
-            .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
-    }
-
-    public Stream<MailboxACL.Entry> changedEntries() {
-        Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user);
-
-        return newACL.ofPositiveNameType(MailboxACL.NameType.user)
-            .entrySet()
-            .stream()
-            .filter(entry -> oldEntries.containsKey(entry.getKey())
-                && !oldEntries.get(entry.getKey()).equals(entry.getValue()))
-            .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ee233b34/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
new file mode 100644
index 0000000..065ef67
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
@@ -0,0 +1,70 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.acl;
+
+import java.util.Map;
+import java.util.stream.Stream;
+
+import org.apache.james.mailbox.model.MailboxACL;
+
+public class PositiveUserACLDiff {
+
+    public static PositiveUserACLDiff computeDiff(MailboxACL oldACL, MailboxACL newACL) {
+        return new PositiveUserACLDiff(oldACL, newACL);
+    }
+
+    private final MailboxACL oldACL;
+    private final MailboxACL newACL;
+
+    private PositiveUserACLDiff(MailboxACL oldACL, MailboxACL newACL) {
+        this.oldACL = oldACL;
+        this.newACL = newACL;
+    }
+
+    public Stream<MailboxACL.Entry> addedEntries() {
+        Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user);
+
+        return newACL.ofPositiveNameType(MailboxACL.NameType.user)
+            .entrySet()
+            .stream()
+            .filter(entry -> !oldEntries.containsKey(entry.getKey()))
+            .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+    }
+
+    public Stream<MailboxACL.Entry> removedEntries() {
+        Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> newEntries = newACL.ofPositiveNameType(MailboxACL.NameType.user);
+
+        return oldACL.ofPositiveNameType(MailboxACL.NameType.user)
+            .entrySet()
+            .stream()
+            .filter(entry -> !newEntries.containsKey(entry.getKey()))
+            .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+    }
+
+    public Stream<MailboxACL.Entry> changedEntries() {
+        Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user);
+
+        return newACL.ofPositiveNameType(MailboxACL.NameType.user)
+            .entrySet()
+            .stream()
+            .filter(entry -> oldEntries.containsKey(entry.getKey())
+                && !oldEntries.get(entry.getKey()).equals(entry.getValue()))
+            .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ee233b34/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java
deleted file mode 100644
index f5d3097..0000000
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.acl;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.james.mailbox.exception.UnsupportedRightException;
-import org.apache.james.mailbox.model.MailboxACL;
-import org.apache.james.mailbox.model.MailboxACL.Entry;
-import org.apache.james.mailbox.model.MailboxACL.EntryKey;
-import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
-import org.apache.james.mailbox.model.MailboxACL.Right;
-import org.junit.Test;
-
-public class ACLDiffTest {
-
-    private static final EntryKey ENTRY_KEY = EntryKey.createUserEntryKey("user");
-    private static final Rfc4314Rights RIGHTS = new Rfc4314Rights(Right.Administer);
-
-    @Test
-    public void addedEntriesShouldReturnEmptyWhenSameACL() {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY,
-            MailboxACL.EMPTY);
-
-        assertThat(aclDiff.addedEntries()).isEmpty();
-    }
-
-    @Test
-    public void addedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException
{
-        MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
-            MailboxACL.command()
-                .key(ENTRY_KEY)
-                .rights(RIGHTS)
-                .asAddition());
-
-        ACLDiff aclDiff = ACLDiff.from(mailboxACL, mailboxACL);
-
-        assertThat(aclDiff.addedEntries()).isEmpty();
-    }
-
-    @Test
-    public void removedEntriesShouldReturnEmptyWhenSameACL() {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY,
-            MailboxACL.EMPTY);
-
-        assertThat(aclDiff.removedEntries()).isEmpty();
-    }
-
-    @Test
-    public void removedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException
{
-        MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
-            MailboxACL.command()
-                .key(ENTRY_KEY)
-                .rights(RIGHTS)
-                .asAddition());
-
-        ACLDiff aclDiff = ACLDiff.from(mailboxACL, mailboxACL);
-
-        assertThat(aclDiff.removedEntries()).isEmpty();
-    }
-
-    @Test
-    public void changedEntriesShouldReturnEmptyWhenSameACL() {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY,
-            MailboxACL.EMPTY);
-
-        assertThat(aclDiff.changedEntries()).isEmpty();
-    }
-
-    @Test
-    public void changedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException
{
-        MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
-            MailboxACL.command()
-                .key(ENTRY_KEY)
-                .rights(RIGHTS)
-                .asAddition());
-
-        ACLDiff aclDiff = ACLDiff.from(mailboxACL, mailboxACL);
-
-        assertThat(aclDiff.changedEntries()).isEmpty();
-    }
-    @Test
-    public void addedEntriesShouldReturnNewEntryWhenAddedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY,
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()));
-
-        assertThat(aclDiff.addedEntries())
-            .containsOnly(new Entry(ENTRY_KEY, RIGHTS));
-    }
-
-    @Test
-    public void changedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY,
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()));
-
-        assertThat(aclDiff.changedEntries())
-            .isEmpty();
-    }
-
-    @Test
-    public void removedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY,
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()));
-
-        assertThat(aclDiff.removedEntries())
-            .isEmpty();
-    }
-
-    @Test
-    public void addedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()),
-            MailboxACL.EMPTY);
-
-        assertThat(aclDiff.addedEntries())
-            .isEmpty();
-    }
-
-    @Test
-    public void changedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()),
-            MailboxACL.EMPTY);
-
-        assertThat(aclDiff.changedEntries())
-            .isEmpty();
-    }
-
-    @Test
-    public void removedEntriesShouldReturnEntryWhenRemovedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()),
-            MailboxACL.EMPTY);
-
-        assertThat(aclDiff.removedEntries())
-            .containsOnly(new Entry(ENTRY_KEY, RIGHTS));
-    }
-
-    @Test
-    public void removedEntriesShouldReturnEmptyWhenChangedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()),
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(Right.Lookup)
-                    .asAddition()));
-
-        assertThat(aclDiff.removedEntries())
-            .isEmpty();
-    }
-
-    @Test
-    public void addedEntriesShouldReturnEmptyWhenChangedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(RIGHTS)
-                    .asAddition()),
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(Right.Lookup)
-                    .asAddition()));
-
-        assertThat(aclDiff.addedEntries())
-            .isEmpty();
-    }
-
-    @Test
-    public void changedEntriesShouldReturnEntryWhenChangedEntry() throws Exception {
-        ACLDiff aclDiff = ACLDiff.from(
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(Right.Administer)
-                    .asAddition()),
-            MailboxACL.EMPTY.apply(
-                MailboxACL.command()
-                    .key(ENTRY_KEY)
-                    .rights(Right.Lookup)
-                    .asAddition()));
-
-        assertThat(aclDiff.changedEntries())
-            .containsOnly(new Entry(ENTRY_KEY, new Rfc4314Rights(MailboxACL.Right.Lookup)));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ee233b34/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
new file mode 100644
index 0000000..1b81080
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
@@ -0,0 +1,238 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.acl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.mailbox.exception.UnsupportedRightException;
+import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxACL.Entry;
+import org.apache.james.mailbox.model.MailboxACL.EntryKey;
+import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
+import org.apache.james.mailbox.model.MailboxACL.Right;
+import org.junit.Test;
+
+public class PositiveUserACLDiffTest {
+
+    private static final EntryKey ENTRY_KEY = EntryKey.createUserEntryKey("user");
+    private static final Rfc4314Rights RIGHTS = new Rfc4314Rights(Right.Administer);
+
+    @Test
+    public void addedEntriesShouldReturnEmptyWhenSameACL() {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY,
+            MailboxACL.EMPTY);
+
+        assertThat(positiveUserAclDiff.addedEntries()).isEmpty();
+    }
+
+    @Test
+    public void addedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException
{
+        MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
+            MailboxACL.command()
+                .key(ENTRY_KEY)
+                .rights(RIGHTS)
+                .asAddition());
+
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(mailboxACL,
mailboxACL);
+
+        assertThat(positiveUserAclDiff.addedEntries()).isEmpty();
+    }
+
+    @Test
+    public void removedEntriesShouldReturnEmptyWhenSameACL() {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY,
+            MailboxACL.EMPTY);
+
+        assertThat(positiveUserAclDiff.removedEntries()).isEmpty();
+    }
+
+    @Test
+    public void removedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException
{
+        MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
+            MailboxACL.command()
+                .key(ENTRY_KEY)
+                .rights(RIGHTS)
+                .asAddition());
+
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(mailboxACL,
mailboxACL);
+
+        assertThat(positiveUserAclDiff.removedEntries()).isEmpty();
+    }
+
+    @Test
+    public void changedEntriesShouldReturnEmptyWhenSameACL() {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY,
+            MailboxACL.EMPTY);
+
+        assertThat(positiveUserAclDiff.changedEntries()).isEmpty();
+    }
+
+    @Test
+    public void changedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException
{
+        MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
+            MailboxACL.command()
+                .key(ENTRY_KEY)
+                .rights(RIGHTS)
+                .asAddition());
+
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(mailboxACL,
mailboxACL);
+
+        assertThat(positiveUserAclDiff.changedEntries()).isEmpty();
+    }
+    @Test
+    public void addedEntriesShouldReturnNewEntryWhenAddedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY,
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()));
+
+        assertThat(positiveUserAclDiff.addedEntries())
+            .containsOnly(new Entry(ENTRY_KEY, RIGHTS));
+    }
+
+    @Test
+    public void changedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY,
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()));
+
+        assertThat(positiveUserAclDiff.changedEntries())
+            .isEmpty();
+    }
+
+    @Test
+    public void removedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY,
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()));
+
+        assertThat(positiveUserAclDiff.removedEntries())
+            .isEmpty();
+    }
+
+    @Test
+    public void addedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()),
+            MailboxACL.EMPTY);
+
+        assertThat(positiveUserAclDiff.addedEntries())
+            .isEmpty();
+    }
+
+    @Test
+    public void changedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()),
+            MailboxACL.EMPTY);
+
+        assertThat(positiveUserAclDiff.changedEntries())
+            .isEmpty();
+    }
+
+    @Test
+    public void removedEntriesShouldReturnEntryWhenRemovedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()),
+            MailboxACL.EMPTY);
+
+        assertThat(positiveUserAclDiff.removedEntries())
+            .containsOnly(new Entry(ENTRY_KEY, RIGHTS));
+    }
+
+    @Test
+    public void removedEntriesShouldReturnEmptyWhenChangedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()),
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(Right.Lookup)
+                    .asAddition()));
+
+        assertThat(positiveUserAclDiff.removedEntries())
+            .isEmpty();
+    }
+
+    @Test
+    public void addedEntriesShouldReturnEmptyWhenChangedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(RIGHTS)
+                    .asAddition()),
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(Right.Lookup)
+                    .asAddition()));
+
+        assertThat(positiveUserAclDiff.addedEntries())
+            .isEmpty();
+    }
+
+    @Test
+    public void changedEntriesShouldReturnEntryWhenChangedEntry() throws Exception {
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(Right.Administer)
+                    .asAddition()),
+            MailboxACL.EMPTY.apply(
+                MailboxACL.command()
+                    .key(ENTRY_KEY)
+                    .rights(Right.Lookup)
+                    .asAddition()));
+
+        assertThat(positiveUserAclDiff.changedEntries())
+            .containsOnly(new Entry(ENTRY_KEY, new Rfc4314Rights(MailboxACL.Right.Lookup)));
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ee233b34/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
index 7b05f2f..89173de 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
@@ -30,7 +30,6 @@ import static org.apache.james.mailbox.cassandra.table.CassandraUserMailboxRight
 import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -39,8 +38,8 @@ import javax.inject.Inject;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
-import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.acl.PositiveUserACLChanged;
+import org.apache.james.mailbox.acl.PositiveUserACLDiff;
 import org.apache.james.mailbox.cassandra.ids.CassandraId;
 import org.apache.james.mailbox.exception.UnsupportedRightException;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -100,11 +99,11 @@ public class CassandraUserMailboxRightsDAO {
     }
 
     public CompletableFuture<Void> update(CassandraId cassandraId, PositiveUserACLChanged
positiveUserAclChanged) {
-        ACLDiff aclDiff = ACLDiff.from(positiveUserAclChanged.getOldACL(), positiveUserAclChanged.getNewACL());
+        PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(positiveUserAclChanged.getOldACL(),
positiveUserAclChanged.getNewACL());
         return CompletableFuture.allOf(
-            addAll(cassandraId, aclDiff.addedEntries()),
-            removeAll(cassandraId, aclDiff.removedEntries()),
-            addAll(cassandraId, aclDiff.changedEntries()));
+            addAll(cassandraId, positiveUserAclDiff.addedEntries()),
+            removeAll(cassandraId, positiveUserAclDiff.removedEntries()),
+            addAll(cassandraId, positiveUserAclDiff.changedEntries()));
     }
 
     private CompletableFuture<Stream<Void>> removeAll(CassandraId cassandraId,
Stream<MailboxACL.Entry> removedEntries) {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message