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 bt...@apache.org on 2019/05/10 11:30:17 UTC
[james-project] 04/17: JAMES-2712 Small test code refactoring for
Linshare export
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 9dde84ee76bda91de1028fc33eab818bde7cb5f1
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed May 8 15:28:52 2019 +0700
JAMES-2712 Small test code refactoring for Linshare export
---
...LinshareBlobExportMechanismIntegrationTest.java | 28 +++++++++++-----------
.../linshare/LinshareBlobExportMechanismTest.java | 22 +++++++++--------
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
index ef7239e..068827d 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
@@ -122,13 +122,13 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
}
@Test
- void exportShouldShareTheDocumentViaLinShareWhenJmapDelete() {
+ void exportShouldShareTheDocumentViaLinshareWhenJmapDelete() {
bartSendMessageToHomer();
WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
- WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+ WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
@@ -139,7 +139,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
}
@Test
- void exportShouldShareTheDocumentViaLinShareWhenImapDelete() throws Exception {
+ void exportShouldShareTheDocumentViaLinshareWhenImapDelete() throws Exception {
bartSendMessageToHomer();
WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
@@ -150,7 +150,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
.setFlagsForAllMessagesInMailbox("\\Deleted");
imapMessageReader.expunge();
- WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+ WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
@@ -167,7 +167,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
- WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+ WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
@@ -196,15 +196,15 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
.setFlagsForAllMessagesInMailbox("\\Deleted");
imapMessageReader.expunge();
- WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+ WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
WAIT_TEN_SECONDS.untilAsserted(
- () -> fakeSmtpRequestSpecification
- .get("/api/email")
- .then()
- .body("", hasSize(2)));
+ () -> fakeSmtpRequestSpecification
+ .get("/api/email")
+ .then()
+ .body("", hasSize(2)));
fakeSmtpRequestSpecification
.get("/api/email")
@@ -214,13 +214,13 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
}
@Test
- void exportShouldShareNonEmptyZipViaLinShareWhenJmapDelete() throws Exception {
+ void exportShouldShareNonEmptyZipViaLinshareWhenJmapDelete() throws Exception {
bartSendMessageToHomer();
WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
- WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+ WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
@@ -233,7 +233,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
}
@Test
- void exportShouldShareNonEmptyZipViaLinShareWhenImapDelete() throws Exception {
+ void exportShouldShareNonEmptyZipViaLinshareWhenImapDelete() throws Exception {
bartSendMessageToHomer();
WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
@@ -244,7 +244,7 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
.setFlagsForAllMessagesInMailbox("\\Deleted");
imapMessageReader.expunge();
- WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+ WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).isEmpty());
exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
index fa7e1c3..51150c4 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
@@ -47,7 +47,9 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import io.restassured.specification.RequestSpecification;
class LinshareBlobExportMechanismTest {
+ private static final String FILE_CONTENT = "content";
private static final String EXPLANATION = "Explanation about the file being shared";
+ private static final FileExtension FILE_TEXT_EXTENSION = FileExtension.of("txt");
@RegisterExtension
static LinshareExtension linshareExtension = new LinshareExtension();
@@ -70,13 +72,13 @@ class LinshareBlobExportMechanismTest {
}
@Test
- void exportShouldShareTheDocumentViaLinShare() throws Exception {
- BlobId blobId = blobStore.save("content").block();
+ void exportShouldShareTheDocumentViaLinshare() throws Exception {
+ BlobId blobId = blobStore.save(FILE_CONTENT).block();
testee.blobId(blobId)
.with(new MailAddress(USER_2.getUsername()))
.explanation(EXPLANATION)
- .fileExtension(FileExtension.of("txt"))
+ .fileExtension(FILE_TEXT_EXTENSION)
.export();
assertThat(user2API.receivedShares())
@@ -88,12 +90,12 @@ class LinshareBlobExportMechanismTest {
@Test
void exportShouldSendAnEmailToSharee() throws Exception {
- BlobId blobId = blobStore.save("content").block();
+ BlobId blobId = blobStore.save(FILE_CONTENT).block();
testee.blobId(blobId)
.with(new MailAddress(USER_2.getUsername()))
.explanation(EXPLANATION)
- .fileExtension(FileExtension.of("txt"))
+ .fileExtension(FILE_TEXT_EXTENSION)
.export();
RequestSpecification request = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
@@ -115,18 +117,18 @@ class LinshareBlobExportMechanismTest {
}
@Test
- void exportShouldShareTheDocumentAndAllowDownloadViaLinShare() throws Exception {
- BlobId blobId = blobStore.save("content").block();
+ void exportShouldShareTheDocumentAndAllowDownloadViaLinshare() throws Exception {
+ BlobId blobId = blobStore.save(FILE_CONTENT).block();
testee.blobId(blobId)
.with(new MailAddress(USER_2.getUsername()))
.explanation(EXPLANATION)
- .fileExtension(FileExtension.of("txt"))
+ .fileExtension(FILE_TEXT_EXTENSION)
.export();
Document sharedDoc = user2API.receivedShares().get(0).getDocument();
byte[] sharedFile = linshareExtension.downloadSharedFile(USER_2, sharedDoc.getId(), sharedDoc.getName());
- assertThat(sharedFile).isEqualTo("content".getBytes(StandardCharsets.UTF_8));
+ assertThat(sharedFile).isEqualTo(FILE_CONTENT.getBytes(StandardCharsets.UTF_8));
}
@Test
@@ -137,7 +139,7 @@ class LinshareBlobExportMechanismTest {
() -> testee.blobId(blobId)
.with(new MailAddress(USER_2.getUsername()))
.explanation(EXPLANATION)
- .fileExtension(FileExtension.of("txt"))
+ .fileExtension(FILE_TEXT_EXTENSION)
.export())
.isInstanceOf(BlobExportMechanism.BlobExportException.class);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org