You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/04/29 08:15:38 UTC
[james-project] branch master updated (d7f9883 -> c052ab0)
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from d7f9883 Merge remote-tracking branch 'trantienduchn/fix-domain-mapping-route'
new df3f684 JAMES-2742 MailRepositoryProperties POJO
new 651044a JAMES-2742 MailRepositoryPropertiesStore API + Contract + Memory Impl
new c052ab0 Merge remote-tracking branch 'trantienduchn/browsable'
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
...{MailKey.java => MailRepositoryProperties.java} | 60 ++++++++---
.../api/MailRepositoryPropertiesStore.java} | 10 +-
.../api/MailRepositoryPropertiesStoreContract.java | 119 +++++++++++++++++++++
.../api/MailRepositoryPropertiesTest.java | 6 +-
.../MemoryMailRepositoryPropertiesStore.java} | 32 +++---
...> MemoryMailRepositoryPropertiesStoreTest.java} | 18 ++--
6 files changed, 194 insertions(+), 51 deletions(-)
copy server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/{MailKey.java => MailRepositoryProperties.java} (55%)
copy server/{data/data-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryUrlStore.java => mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStore.java} (83%)
create mode 100644 server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStoreContract.java
copy third-party/linshare/src/test/java/org/apache/james/linshare/client/ShareResultTest.java => server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesTest.java (90%)
copy server/{data/data-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryUrlStore.java => mailrepository/mailrepository-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStore.java} (58%)
copy server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/{MemoryMailRepositoryTest.java => MemoryMailRepositoryPropertiesStoreTest.java} (73%)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 02/03: JAMES-2742 MailRepositoryPropertiesStore API
+ Contract + Memory Impl
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 651044a1ea8784b44c39d40fd7d87777e06ef977
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Mon Apr 22 15:51:54 2019 +0700
JAMES-2742 MailRepositoryPropertiesStore API + Contract + Memory Impl
---
.../api/MailRepositoryProperties.java | 34 ++++--
.../api/MailRepositoryPropertiesStore.java | 29 +++++
.../api/MailRepositoryPropertiesStoreContract.java | 119 +++++++++++++++++++++
.../MemoryMailRepositoryPropertiesStore.java | 51 +++++++++
.../MemoryMailRepositoryPropertiesStoreTest.java | 39 +++++++
5 files changed, 263 insertions(+), 9 deletions(-)
diff --git a/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java b/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java
index 1822b0d..cd78e2b 100644
--- a/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java
+++ b/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java
@@ -25,21 +25,37 @@ import com.google.common.base.MoreObjects;
public class MailRepositoryProperties {
- public static class Builder {
- private boolean browsable;
+ static class Builder {
- public Builder browsable(boolean browsable) {
- this.browsable = browsable;
- return this;
+ @FunctionalInterface
+ interface RequireBrowsable {
+ ReadyToBuild browsable(boolean browsable);
+
+ default ReadyToBuild canBrowse() {
+ return browsable(true);
+ }
+
+ default ReadyToBuild canNotBrowse() {
+ return browsable(false);
+ }
}
- MailRepositoryProperties build() {
- return new MailRepositoryProperties(browsable);
+ static class ReadyToBuild {
+
+ private final boolean browsable;
+
+ ReadyToBuild(boolean browsable) {
+ this.browsable = browsable;
+ }
+
+ MailRepositoryProperties build() {
+ return new MailRepositoryProperties(browsable);
+ }
}
}
- public static Builder builder() {
- return new Builder();
+ static Builder.RequireBrowsable builder() {
+ return Builder.ReadyToBuild::new;
}
private final boolean browsable;
diff --git a/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStore.java b/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStore.java
new file mode 100644
index 0000000..b129097
--- /dev/null
+++ b/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStore.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.mailrepository.api;
+
+import org.reactivestreams.Publisher;
+
+public interface MailRepositoryPropertiesStore {
+
+ Publisher<Void> store(MailRepositoryUrl url, MailRepositoryProperties properties);
+
+ Publisher<MailRepositoryProperties> retrieve(MailRepositoryUrl url);
+}
diff --git a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStoreContract.java b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStoreContract.java
new file mode 100644
index 0000000..72c99e2
--- /dev/null
+++ b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesStoreContract.java
@@ -0,0 +1,119 @@
+/****************************************************************
+ * 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.mailrepository.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.jupiter.api.Test;
+
+import reactor.core.publisher.Mono;
+
+public interface MailRepositoryPropertiesStoreContract {
+
+ MailRepositoryProperties NON_BROWSABLE = MailRepositoryProperties.builder()
+ .canNotBrowse()
+ .build();
+ MailRepositoryProperties BROWSABLE = MailRepositoryProperties.builder()
+ .canBrowse()
+ .build();
+
+ MailRepositoryUrl URL_1 = MailRepositoryUrl.from("protocol://deletedMessages/user1");
+ MailRepositoryUrl URL_2 = MailRepositoryUrl.from("protocol://deletedMessages/user2");
+ MailRepositoryUrl URL_3 = MailRepositoryUrl.from("protocol://deletedMessages/user3");
+
+ MailRepositoryPropertiesStore testee();
+
+ @Test
+ default void storeShouldStorePropertiesWithBelongingUrl() {
+ Mono.from(testee().store(URL_1, NON_BROWSABLE))
+ .block();
+
+ assertThat(Mono.from(testee().retrieve(URL_1)).block())
+ .isEqualTo(NON_BROWSABLE);
+ }
+
+ @Test
+ default void storeShouldOverrideTheResultWhenCalledMultipleTimes() {
+ Mono.from(testee().store(URL_1, NON_BROWSABLE)).block();
+ Mono.from(testee().store(URL_1, BROWSABLE)).block();
+
+ assertThat(Mono.from(testee().retrieve(URL_1)).block())
+ .isEqualTo(BROWSABLE);
+ }
+
+ @Test
+ default void storeShouldNotThrowWhenStoringDifferentUrl() {
+ assertThatCode(() -> {
+ Mono.from(testee().store(URL_1, NON_BROWSABLE)).block();
+ Mono.from(testee().store(URL_2, BROWSABLE)).block();
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ default void retrieveShouldReturnTheRightPropertiesByTheUrl() {
+ Mono.from(testee().store(URL_1, NON_BROWSABLE)).block();
+ Mono.from(testee().store(URL_2, BROWSABLE)).block();
+
+ assertThat(Mono.from(testee().retrieve(URL_2)).block())
+ .isEqualTo(BROWSABLE);
+ }
+
+ @Test
+ default void retrieveShouldReturnEmptyWhenRetrievingByNonExistedUrl() {
+ Mono.from(testee().store(URL_1, NON_BROWSABLE)).block();
+ Mono.from(testee().store(URL_2, BROWSABLE)).block();
+
+ assertThat(Mono.from(testee().retrieve(URL_3)).blockOptional())
+ .isEmpty();
+ }
+
+ @Test
+ default void doingMappingOnTheResultShouldNotThrowWhenEmptyResult() {
+ assertThatCode(() ->
+ Mono.from(testee().retrieve(URL_1))
+ .map(MailRepositoryProperties::isBrowsable)
+ .block())
+ .doesNotThrowAnyException();
+ }
+
+ @Test
+ default void doingMappingOnTheResultShouldNotThrowAfterANullMappingPipeLineWhenEmptyResult() {
+ assertThatCode(() ->
+ Mono.from(testee().retrieve(URL_1))
+ .map(properties -> (MailRepositoryProperties) null)
+ .map(MailRepositoryProperties::isBrowsable)
+ .block())
+ .doesNotThrowAnyException();
+ }
+
+ @Test
+ default void doingMappingOnTheResultShouldThrowAfterANullMappingPipeLineWhenNotEmptyResult() {
+ Mono.from(testee().store(URL_1, NON_BROWSABLE)).block();
+
+ assertThatThrownBy(() ->
+ Mono.from(testee().retrieve(URL_1))
+ .map(properties -> (MailRepositoryProperties) null)
+ .map(MailRepositoryProperties::isBrowsable)
+ .block())
+ .isInstanceOf(NullPointerException.class);
+ }
+}
diff --git a/server/mailrepository/mailrepository-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStore.java b/server/mailrepository/mailrepository-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStore.java
new file mode 100644
index 0000000..82f8dea
--- /dev/null
+++ b/server/mailrepository/mailrepository-memory/src/main/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStore.java
@@ -0,0 +1,51 @@
+/****************************************************************
+ * 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.mailrepository.memory;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.james.mailrepository.api.MailRepositoryProperties;
+import org.apache.james.mailrepository.api.MailRepositoryPropertiesStore;
+import org.apache.james.mailrepository.api.MailRepositoryUrl;
+import org.reactivestreams.Publisher;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import reactor.core.publisher.Mono;
+
+public class MemoryMailRepositoryPropertiesStore implements MailRepositoryPropertiesStore {
+
+ private final ConcurrentHashMap<MailRepositoryUrl, MailRepositoryProperties> propertiesMap;
+
+ @VisibleForTesting
+ MemoryMailRepositoryPropertiesStore() {
+ this.propertiesMap = new ConcurrentHashMap<>();
+ }
+
+ @Override
+ public Publisher<Void> store(MailRepositoryUrl url, MailRepositoryProperties properties) {
+ return Mono.fromRunnable(() -> propertiesMap.put(url, properties));
+ }
+
+ @Override
+ public Publisher<MailRepositoryProperties> retrieve(MailRepositoryUrl url) {
+ return Mono.fromSupplier(() -> propertiesMap.get(url));
+ }
+}
diff --git a/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStoreTest.java b/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStoreTest.java
new file mode 100644
index 0000000..33b6d66
--- /dev/null
+++ b/server/mailrepository/mailrepository-memory/src/test/java/org/apache/james/mailrepository/memory/MemoryMailRepositoryPropertiesStoreTest.java
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.mailrepository.memory;
+
+import org.apache.james.mailrepository.api.MailRepositoryPropertiesStore;
+import org.apache.james.mailrepository.api.MailRepositoryPropertiesStoreContract;
+import org.junit.jupiter.api.BeforeEach;
+
+class MemoryMailRepositoryPropertiesStoreTest implements MailRepositoryPropertiesStoreContract {
+
+ private MemoryMailRepositoryPropertiesStore testee;
+
+ @BeforeEach
+ void beforeEach() {
+ testee = new MemoryMailRepositoryPropertiesStore();
+ }
+
+ @Override
+ public MailRepositoryPropertiesStore testee() {
+ return testee;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 03/03: Merge remote-tracking branch
'trantienduchn/browsable'
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c052ab06b2830ed6d37ff30b614f007b96b09dcc
Merge: d7f9883 651044a
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Mon Apr 29 10:13:35 2019 +0200
Merge remote-tracking branch 'trantienduchn/browsable'
.../api/MailRepositoryProperties.java | 92 ++++++++++++++++
.../api/MailRepositoryPropertiesStore.java | 29 +++++
.../api/MailRepositoryPropertiesStoreContract.java | 119 +++++++++++++++++++++
.../api/MailRepositoryPropertiesTest.java | 33 ++++++
.../MemoryMailRepositoryPropertiesStore.java | 51 +++++++++
.../MemoryMailRepositoryPropertiesStoreTest.java | 39 +++++++
6 files changed, 363 insertions(+)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 01/03: JAMES-2742 MailRepositoryProperties POJO
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit df3f684e56f97e049f328cb26c8a610ea9d2121e
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Mon Apr 22 14:58:59 2019 +0700
JAMES-2742 MailRepositoryProperties POJO
---
.../api/MailRepositoryProperties.java | 76 ++++++++++++++++++++++
.../api/MailRepositoryPropertiesTest.java | 33 ++++++++++
2 files changed, 109 insertions(+)
diff --git a/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java b/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java
new file mode 100644
index 0000000..1822b0d
--- /dev/null
+++ b/server/mailrepository/mailrepository-api/src/main/java/org/apache/james/mailrepository/api/MailRepositoryProperties.java
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.mailrepository.api;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+public class MailRepositoryProperties {
+
+ public static class Builder {
+ private boolean browsable;
+
+ public Builder browsable(boolean browsable) {
+ this.browsable = browsable;
+ return this;
+ }
+
+ MailRepositoryProperties build() {
+ return new MailRepositoryProperties(browsable);
+ }
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ private final boolean browsable;
+
+ private MailRepositoryProperties(boolean browsable) {
+ this.browsable = browsable;
+ }
+
+ public boolean isBrowsable() {
+ return browsable;
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o instanceof MailRepositoryProperties) {
+ MailRepositoryProperties that = (MailRepositoryProperties) o;
+
+ return Objects.equals(this.browsable, that.browsable);
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(browsable);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("browsable", browsable)
+ .toString();
+ }
+}
diff --git a/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesTest.java b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesTest.java
new file mode 100644
index 0000000..bca1954
--- /dev/null
+++ b/server/mailrepository/mailrepository-api/src/test/java/org/apache/james/mailrepository/api/MailRepositoryPropertiesTest.java
@@ -0,0 +1,33 @@
+/****************************************************************
+ * 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.mailrepository.api;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class MailRepositoryPropertiesTest {
+
+ @Test
+ void shouldMatchBeanContract() {
+ EqualsVerifier.forClass(MailRepositoryProperties.class)
+ .verify();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org