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
The following commit(s) were added to refs/heads/master by this push:
new 20af073850 JAMES-4163 Do not run PG RLS tests on top of
non-domain-contextualised domains
20af073850 is described below
commit 20af0738503fddfd9327a34feb78bb87a056b650
Author: Benoit TELLIER <[email protected]>
AuthorDate: Thu Jan 15 15:18:57 2026 +0100
JAMES-4163 Do not run PG RLS tests on top of non-domain-contextualised
domains
---
.../vacation/api/VacationRepositoryContract.java | 84 ++++---
.../change/PostgresEmailChangeRepositoryTest.java | 2 +-
... PostgresEmailChangeRepositoryWithLRSTest.java} | 9 +-
.../PostgresMailboxChangeRepositoryTest.java | 2 +-
...ostgresMailboxChangeRepositoryWithRLSTest.java} | 9 +-
.../PostgresPushSubscriptionRepositoryTest.java | 2 +-
...gresPushSubscriptionRepositoryWithRLSTest.java} | 8 +-
.../api/change/EmailChangeRepositoryContract.java | 278 +++++++++++----------
.../change/MailboxChangeRepositoryContract.java | 204 +++++++--------
.../PushSubscriptionRepositoryContract.scala | 122 ++++-----
.../postgres/PostgresVacationRepositoryTest.java | 2 +-
... => PostgresVacationRepositoryWithLRSTest.java} | 8 +-
12 files changed, 385 insertions(+), 345 deletions(-)
diff --git
a/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
b/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
index 814545d9d5..37f66598bc 100644
---
a/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
+++
b/server/data/data-api/src/test/java/org/apache/james/vacation/api/VacationRepositoryContract.java
@@ -47,9 +47,13 @@ public interface VacationRepositoryContract {
VacationRepository vacationRepository();
+ default AccountId accountId() {
+ return ACCOUNT_ID;
+ }
+
@Test
default void retrieveVacationShouldReturnDefaultValueByDefault() {
-
assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block()).isEqualTo(VacationRepository.DEFAULT_VACATION);
+
assertThat(vacationRepository().retrieveVacation(accountId()).block()).isEqualTo(VacationRepository.DEFAULT_VACATION);
}
@Test
@@ -58,9 +62,9 @@ public interface VacationRepositoryContract {
.isEnabled(true)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(Vacation.builder()
.enabled(true)
.build());
@@ -72,9 +76,9 @@ public interface VacationRepositoryContract {
.fromDate(DATE_2014)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(Vacation.builder()
.fromDate(Optional.of(DATE_2014))
.enabled(false)
@@ -87,9 +91,9 @@ public interface VacationRepositoryContract {
.toDate(DATE_2017)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(Vacation.builder()
.toDate(Optional.of(DATE_2017))
.enabled(false)
@@ -103,9 +107,9 @@ public interface VacationRepositoryContract {
.subject(newSubject)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(Vacation.builder()
.subject(Optional.of(newSubject))
.enabled(false)
@@ -119,9 +123,9 @@ public interface VacationRepositoryContract {
.textBody(newTextBody)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(Vacation.builder()
.textBody(newTextBody)
.enabled(false)
@@ -135,9 +139,9 @@ public interface VacationRepositoryContract {
.htmlBody(newHtmlBody)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(Vacation.builder()
.enabled(false)
.htmlBody(newHtmlBody)
@@ -149,9 +153,9 @@ public interface VacationRepositoryContract {
VacationPatch vacationPatch = VacationPatch.builderFrom(VACATION)
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(VACATION);
}
@@ -160,46 +164,46 @@ public interface VacationRepositoryContract {
VacationPatch vacationPatch = VacationPatch.builder()
.build();
- vacationRepository().modifyVacation(ACCOUNT_ID, vacationPatch).block();
+ vacationRepository().modifyVacation(accountId(),
vacationPatch).block();
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(VacationRepository.DEFAULT_VACATION);
}
@Test
default void emptyUpdatesShouldNotChangeExistingVacations() {
// Given
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
// When
- vacationRepository().modifyVacation(ACCOUNT_ID, VacationPatch.builder()
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builder()
.build())
.block();
// Then
- assertThat(vacationRepository().retrieveVacation(ACCOUNT_ID).block())
+ assertThat(vacationRepository().retrieveVacation(accountId()).block())
.isEqualTo(VACATION);
}
@Test
default void nullUpdateShouldResetSubject() {
// Given
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
// When
- vacationRepository().modifyVacation(ACCOUNT_ID, VacationPatch.builder()
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builder()
.subject(ValuePatch.remove())
.build())
.block();
// Then
- Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ Vacation vacation =
vacationRepository().retrieveVacation(accountId()).block();
assertThat(vacation.getSubject()).isEmpty();
assertThat(vacation)
.isEqualTo(Vacation.builder()
@@ -214,19 +218,19 @@ public interface VacationRepositoryContract {
@Test
default void nullUpdateShouldResetText() {
// Given
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
// When
- vacationRepository().modifyVacation(ACCOUNT_ID, VacationPatch.builder()
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builder()
.textBody(ValuePatch.remove())
.build())
.block();
// Then
- Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ Vacation vacation =
vacationRepository().retrieveVacation(accountId()).block();
assertThat(vacation.getTextBody()).isEmpty();
assertThat(vacation)
.isEqualTo(Vacation.builder()
@@ -241,19 +245,19 @@ public interface VacationRepositoryContract {
@Test
default void nullUpdateShouldResetHtml() {
// Given
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
// When
- vacationRepository().modifyVacation(ACCOUNT_ID, VacationPatch.builder()
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builder()
.htmlBody(ValuePatch.remove())
.build())
.block();
// Then
- Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ Vacation vacation =
vacationRepository().retrieveVacation(accountId()).block();
assertThat(vacation.getHtmlBody()).isEmpty();
assertThat(vacation)
.isEqualTo(Vacation.builder()
@@ -268,19 +272,19 @@ public interface VacationRepositoryContract {
@Test
default void nullUpdateShouldResetToDate() {
// Given
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
// When
- vacationRepository().modifyVacation(ACCOUNT_ID, VacationPatch.builder()
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builder()
.toDate(ValuePatch.remove())
.build())
.block();
// Then
- Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ Vacation vacation =
vacationRepository().retrieveVacation(accountId()).block();
assertThat(vacation.getToDate()).isEmpty();
assertThat(vacation)
.isEqualTo(Vacation.builder()
@@ -295,19 +299,19 @@ public interface VacationRepositoryContract {
@Test
default void nullUpdateShouldResetFromDate() {
// Given
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
// When
- vacationRepository().modifyVacation(ACCOUNT_ID, VacationPatch.builder()
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builder()
.fromDate(ValuePatch.remove())
.build())
.block();
// Then
- Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ Vacation vacation =
vacationRepository().retrieveVacation(accountId()).block();
assertThat(vacation.getFromDate()).isEmpty();
assertThat(vacation)
.isEqualTo(Vacation.builder()
@@ -333,31 +337,31 @@ public interface VacationRepositoryContract {
@Test
default void modifyVacationShouldThrowOnNullVacation() {
- assertThatThrownBy(() ->
vacationRepository().modifyVacation(ACCOUNT_ID, null))
+ assertThatThrownBy(() ->
vacationRepository().modifyVacation(accountId(), null))
.isInstanceOf(NullPointerException.class);
}
@Test
default void retrieveVacationShouldIgnoreCase() {
- vacationRepository().modifyVacation(ACCOUNT_ID,
+ vacationRepository().modifyVacation(accountId(),
VacationPatch.builderFrom(VACATION)
.build())
.block();
- AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ AccountId upperCaseAccount =
AccountId.fromString(accountId().getIdentifier().toUpperCase());
Vacation vacation =
vacationRepository().retrieveVacation(upperCaseAccount).block();
assertThat(vacation).isNotNull();
}
@Test
default void modifiyVacationShouldIgnoreCase() {
- AccountId upperCaseAccount =
AccountId.fromString(ACCOUNT_ID.getIdentifier().toUpperCase());
+ AccountId upperCaseAccount =
AccountId.fromString(accountId().getIdentifier().toUpperCase());
vacationRepository().modifyVacation(upperCaseAccount,
VacationPatch.builderFrom(VACATION)
.build())
.block();
- Vacation vacation =
vacationRepository().retrieveVacation(ACCOUNT_ID).block();
+ Vacation vacation =
vacationRepository().retrieveVacation(accountId()).block();
assertThat(vacation).isNotNull();
}
}
diff --git
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
index 7cf34b4167..568d80ff13 100644
---
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
+++
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
public class PostgresEmailChangeRepositoryTest implements
EmailChangeRepositoryContract {
@RegisterExtension
- static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(PostgresEmailChangeDataDefinition.MODULE);
+ static PostgresExtension postgresExtension =
PostgresExtension.withoutRowLevelSecurity(PostgresEmailChangeDataDefinition.MODULE);
PostgresEmailChangeRepository postgresEmailChangeRepository;
diff --git
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryWithLRSTest.java
similarity index 88%
copy from
server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
copy to
server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryWithLRSTest.java
index 7cf34b4167..e91e3c81fe 100644
---
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryTest.java
+++
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresEmailChangeRepositoryWithLRSTest.java
@@ -22,15 +22,17 @@ package org.apache.james.jmap.postgres.change;
import java.util.UUID;
import org.apache.james.backends.postgres.PostgresExtension;
+import org.apache.james.core.Username;
import org.apache.james.jmap.api.change.EmailChangeRepository;
import org.apache.james.jmap.api.change.EmailChangeRepositoryContract;
import org.apache.james.jmap.api.change.State;
+import org.apache.james.jmap.api.model.AccountId;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.postgres.PostgresMessageId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
-public class PostgresEmailChangeRepositoryTest implements
EmailChangeRepositoryContract {
+public class PostgresEmailChangeRepositoryWithLRSTest implements
EmailChangeRepositoryContract {
@RegisterExtension
static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(PostgresEmailChangeDataDefinition.MODULE);
@@ -55,4 +57,9 @@ public class PostgresEmailChangeRepositoryTest implements
EmailChangeRepositoryC
public State generateNewState() {
return new PostgresStateFactory().generate();
}
+
+ @Override
+ public AccountId accountId() {
+ return AccountId.fromUsername(Username.of("[email protected]"));
+ }
}
diff --git
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
index ec9f9dc017..49517cb945 100644
---
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
+++
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
class PostgresMailboxChangeRepositoryTest implements
MailboxChangeRepositoryContract {
@RegisterExtension
- static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(PostgresMailboxChangeDataDefinition.MODULE);
+ static PostgresExtension postgresExtension =
PostgresExtension.withoutRowLevelSecurity(PostgresMailboxChangeDataDefinition.MODULE);
PostgresMailboxChangeRepository postgresMailboxChangeRepository;
diff --git
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryWithRLSTest.java
similarity index 89%
copy from
server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
copy to
server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryWithRLSTest.java
index ec9f9dc017..ed85a7c1d2 100644
---
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryTest.java
+++
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/change/PostgresMailboxChangeRepositoryWithRLSTest.java
@@ -22,15 +22,17 @@ package org.apache.james.jmap.postgres.change;
import java.util.UUID;
import org.apache.james.backends.postgres.PostgresExtension;
+import org.apache.james.core.Username;
import org.apache.james.jmap.api.change.MailboxChangeRepository;
import org.apache.james.jmap.api.change.MailboxChangeRepositoryContract;
import org.apache.james.jmap.api.change.State;
+import org.apache.james.jmap.api.model.AccountId;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.postgres.PostgresMailboxId;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
-class PostgresMailboxChangeRepositoryTest implements
MailboxChangeRepositoryContract {
+class PostgresMailboxChangeRepositoryWithRLSTest implements
MailboxChangeRepositoryContract {
@RegisterExtension
static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(PostgresMailboxChangeDataDefinition.MODULE);
@@ -55,4 +57,9 @@ class PostgresMailboxChangeRepositoryTest implements
MailboxChangeRepositoryCont
public MailboxId generateNewMailboxId() {
return PostgresMailboxId.of(UUID.randomUUID());
}
+
+ @Override
+ public AccountId accountId() {
+ return AccountId.fromUsername(Username.of("[email protected]"));
+ }
}
diff --git
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
index 028a2b691e..5d178b4e0d 100644
---
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
+++
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
@@ -36,7 +36,7 @@ import scala.jdk.javaapi.CollectionConverters;
class PostgresPushSubscriptionRepositoryTest implements
PushSubscriptionRepositoryContract {
@RegisterExtension
- static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(
+ static PostgresExtension postgresExtension =
PostgresExtension.withoutRowLevelSecurity(
PostgresDataDefinition.aggregateModules(PostgresPushSubscriptionDataDefinition.MODULE));
UpdatableTickingClock clock;
diff --git
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryWithRLSTest.java
similarity index 92%
copy from
server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
copy to
server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryWithRLSTest.java
index 028a2b691e..2704ea5cb7 100644
---
a/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryTest.java
+++
b/server/data/data-jmap-postgres/src/test/java/org/apache/james/jmap/postgres/pushsubscription/PostgresPushSubscriptionRepositoryWithRLSTest.java
@@ -23,6 +23,7 @@ import java.util.Set;
import org.apache.james.backends.postgres.PostgresDataDefinition;
import org.apache.james.backends.postgres.PostgresExtension;
+import org.apache.james.core.Username;
import org.apache.james.jmap.api.change.TypeStateFactory;
import org.apache.james.jmap.api.model.TypeName;
import org.apache.james.jmap.api.pushsubscription.PushSubscriptionRepository;
@@ -33,7 +34,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import scala.jdk.javaapi.CollectionConverters;
-class PostgresPushSubscriptionRepositoryTest implements
PushSubscriptionRepositoryContract {
+class PostgresPushSubscriptionRepositoryWithRLSTest implements
PushSubscriptionRepositoryContract {
@RegisterExtension
static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(
@@ -59,4 +60,9 @@ class PostgresPushSubscriptionRepositoryTest implements
PushSubscriptionReposito
public PushSubscriptionRepository testee() {
return pushSubscriptionRepository;
}
+
+ @Override
+ public Username alice() {
+ return Username.of("[email protected]");
+ }
}
diff --git
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/EmailChangeRepositoryContract.java
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/EmailChangeRepositoryContract.java
index 641a78f70e..35546fd2bb 100644
---
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/EmailChangeRepositoryContract.java
+++
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/EmailChangeRepositoryContract.java
@@ -38,6 +38,10 @@ public interface EmailChangeRepositoryContract {
AccountId ACCOUNT_ID = AccountId.fromUsername(BOB);
ZonedDateTime DATE = ZonedDateTime.now();
+ default AccountId accountId() {
+ return ACCOUNT_ID;
+ }
+
EmailChangeRepository emailChangeRepository();
MessageId generateNewMessageId();
@@ -49,7 +53,7 @@ public interface EmailChangeRepositoryContract {
EmailChangeRepository repository = emailChangeRepository();
EmailChange change = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -64,7 +68,7 @@ public interface EmailChangeRepositoryContract {
default void getLatestStateShouldReturnInitialWhenEmpty() {
EmailChangeRepository repository = emailChangeRepository();
- assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ assertThat(repository.getLatestState(accountId()).block())
.isEqualTo(State.INITIAL);
}
@@ -77,21 +81,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -101,7 +105,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ assertThat(repository.getLatestState(accountId()).block())
.isEqualTo(change3.getState());
}
@@ -114,21 +118,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(true)
@@ -138,7 +142,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ assertThat(repository.getLatestState(accountId()).block())
.isEqualTo(change2.getState());
}
@@ -150,14 +154,14 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId)
.build();
EmailChange change = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -166,7 +170,7 @@ public interface EmailChangeRepositoryContract {
repository.save(oldState).block();
repository.save(change).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.empty()).block().getAllChanges())
.hasSameElementsAs(change.getUpdated());
}
@@ -176,7 +180,7 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(1))
.isShared(false)
@@ -184,7 +188,7 @@ public interface EmailChangeRepositoryContract {
.build();
repository.save(oldState).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.empty()).block().getAllChanges())
.isEmpty();
}
@@ -195,7 +199,7 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(1))
.isShared(false)
@@ -203,7 +207,7 @@ public interface EmailChangeRepositoryContract {
.build();
repository.save(oldState).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.empty()).block().getNewState())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.empty()).block().getNewState())
.isEqualTo(oldState.getState());
}
@@ -219,35 +223,35 @@ public interface EmailChangeRepositoryContract {
MessageId messageId5 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId3)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
.created(messageId4)
.build();
EmailChange change4 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.plusHours(1))
.isShared(false)
@@ -259,7 +263,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change3).block();
repository.save(change4).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.of(Limit.of(3))).block().getCreated())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.of(Limit.of(3))).block().getCreated())
.containsExactlyInAnyOrder(messageId2, messageId3, messageId4);
}
@@ -274,28 +278,28 @@ public interface EmailChangeRepositoryContract {
MessageId messageId4 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId3)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -306,7 +310,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.of(Limit.of(3))).block().getCreated())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.of(Limit.of(3))).block().getCreated())
.containsExactlyInAnyOrder(messageId1, messageId2, messageId3);
}
@@ -325,28 +329,28 @@ public interface EmailChangeRepositoryContract {
MessageId messageId4 = generateNewMessageId();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state2)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state3)
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId3)
.build();
EmailChange change4 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state4)
.date(DATE)
.isShared(false)
@@ -358,7 +362,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change3).block();
repository.save(change4).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.of(Limit.of(3))).block().getNewState())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.of(Limit.of(3))).block().getNewState())
.isEqualTo(state3);
}
@@ -377,21 +381,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId7 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2, messageId3, messageId4, messageId5,
messageId6)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -402,7 +406,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.empty()).block().getAllChanges())
.hasSameElementsAs(change1.getCreated());
}
@@ -419,21 +423,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId5 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2, messageId3)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -443,7 +447,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.of(Limit.of(3))).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.of(Limit.of(3))).block().getAllChanges())
.hasSameElementsAs(change1.getCreated());
}
@@ -460,14 +464,14 @@ public interface EmailChangeRepositoryContract {
MessageId messageId5 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
@@ -476,7 +480,7 @@ public interface EmailChangeRepositoryContract {
repository.save(oldState).block();
repository.save(change1).block();
- assertThatThrownBy(() -> repository.getSinceState(ACCOUNT_ID, state,
Optional.of(Limit.of(1))).block().getAllChanges())
+ assertThatThrownBy(() -> repository.getSinceState(accountId(), state,
Optional.of(Limit.of(1))).block().getAllChanges())
.isInstanceOf(CanNotCalculateChangesException.class)
.hasMessage("Current change collector limit 1 is exceeded by a
single change, hence we cannot calculate changes.");
}
@@ -492,21 +496,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2, messageId3)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -516,7 +520,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.empty()).block().getNewState())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.empty()).block().getNewState())
.isEqualTo(change2.getState());
}
@@ -531,21 +535,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2, messageId3)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -555,7 +559,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.of(Limit.of(2))).block().hasMoreChanges())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.of(Limit.of(2))).block().hasMoreChanges())
.isTrue();
}
@@ -570,21 +574,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId2, messageId3)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -594,7 +598,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, state,
Optional.of(Limit.of(4))).block().hasMoreChanges())
+ assertThat(repository.getSinceState(accountId(), state,
Optional.of(Limit.of(4))).block().hasMoreChanges())
.isFalse();
}
@@ -616,21 +620,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId10 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1, messageId9, messageId10)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2, messageId3, messageId4, messageId5)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
@@ -639,7 +643,7 @@ public interface EmailChangeRepositoryContract {
.destroyed(messageId4, messageId9)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -652,7 +656,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- EmailChanges emailChanges = repository.getSinceState(ACCOUNT_ID,
state, Optional.of(Limit.of(20))).block();
+ EmailChanges emailChanges = repository.getSinceState(accountId(),
state, Optional.of(Limit.of(20))).block();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(emailChanges.getCreated()).containsExactlyInAnyOrder(messageId2,
messageId3, messageId6, messageId7, messageId8);
@@ -677,28 +681,28 @@ public interface EmailChangeRepositoryContract {
MessageId messageId8 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2, messageId3, messageId4, messageId5)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(true)
.created(messageId6, messageId7)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -709,7 +713,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- EmailChanges emailChanges = repository.getSinceState(ACCOUNT_ID,
state, Optional.of(Limit.of(20))).block();
+ EmailChanges emailChanges = repository.getSinceState(accountId(),
state, Optional.of(Limit.of(20))).block();
assertThat(emailChanges.getCreated())
.containsExactlyInAnyOrder(messageId2, messageId3, messageId4,
messageId5, messageId8);
@@ -726,21 +730,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.updated(messageId1, messageId2)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -751,7 +755,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- EmailChanges emailChanges = repository.getSinceState(ACCOUNT_ID,
state, Optional.of(Limit.of(3))).block();
+ EmailChanges emailChanges = repository.getSinceState(accountId(),
state, Optional.of(Limit.of(3))).block();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(emailChanges.getUpdated()).containsExactly(messageId1,
messageId2);
softly.assertThat(emailChanges.getCreated()).containsExactly(messageId3);
@@ -762,7 +766,7 @@ public interface EmailChangeRepositoryContract {
default void getChangesShouldFailWhenSinceStateNotFound() {
EmailChangeRepository repository = emailChangeRepository();
- assertThatThrownBy(() -> repository.getSinceState(ACCOUNT_ID,
generateNewState(), Optional.empty()).block())
+ assertThatThrownBy(() -> repository.getSinceState(accountId(),
generateNewState(), Optional.empty()).block())
.isInstanceOf(ChangeNotFoundException.class);
}
@@ -770,7 +774,7 @@ public interface EmailChangeRepositoryContract {
default void getLatestStateWithDelegationShouldReturnInitialWhenEmpty() {
EmailChangeRepository repository = emailChangeRepository();
- assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+
assertThat(repository.getLatestStateWithDelegation(accountId()).block())
.isEqualTo(State.INITIAL);
}
@@ -779,21 +783,21 @@ public interface EmailChangeRepositoryContract {
EmailChangeRepository repository = emailChangeRepository();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -803,7 +807,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+
assertThat(repository.getLatestStateWithDelegation(accountId()).block())
.isEqualTo(change3.getState());
}
@@ -812,21 +816,21 @@ public interface EmailChangeRepositoryContract {
EmailChangeRepository repository = emailChangeRepository();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(true)
@@ -836,7 +840,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+
assertThat(repository.getLatestStateWithDelegation(accountId()).block())
.isEqualTo(change3.getState());
}
@@ -847,14 +851,14 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -863,7 +867,7 @@ public interface EmailChangeRepositoryContract {
repository.save(oldState).block();
repository.save(change).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.empty()).block().getAllChanges())
.hasSameElementsAs(change.getUpdated());
}
@@ -874,7 +878,7 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(1))
.isShared(false)
@@ -882,7 +886,7 @@ public interface EmailChangeRepositoryContract {
.build();
repository.save(oldState).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.empty()).block().getAllChanges())
.isEmpty();
}
@@ -893,7 +897,7 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(1))
.isShared(false)
@@ -901,7 +905,7 @@ public interface EmailChangeRepositoryContract {
.build();
repository.save(oldState).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.empty()).block().getNewState())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.empty()).block().getNewState())
.isEqualTo(oldState.getState());
}
@@ -918,35 +922,35 @@ public interface EmailChangeRepositoryContract {
MessageId messageId5 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId3)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
.created(messageId4)
.build();
EmailChange change4 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.plusHours(1))
.isShared(false)
@@ -958,7 +962,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change3).block();
repository.save(change4).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(3))).block().getCreated())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(3))).block().getCreated())
.containsExactlyInAnyOrder(messageId2, messageId3, messageId4);
}
@@ -972,28 +976,28 @@ public interface EmailChangeRepositoryContract {
MessageId messageId4 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(messageId3)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1004,7 +1008,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID,
State.INITIAL, Optional.of(Limit.of(3))).block().getCreated())
+ assertThat(repository.getSinceStateWithDelegation(accountId(),
State.INITIAL, Optional.of(Limit.of(3))).block().getCreated())
.containsExactlyInAnyOrder(messageId1, messageId2, messageId3);
}
@@ -1015,21 +1019,21 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId(), generateNewMessageId(),
generateNewMessageId(), generateNewMessageId(), generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1040,7 +1044,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.empty()).block().getAllChanges())
.hasSameElementsAs(change1.getCreated());
}
@@ -1051,21 +1055,21 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId(), generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1075,7 +1079,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(3))).block().getAllChanges())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(3))).block().getAllChanges())
.hasSameElementsAs(change1.getCreated());
}
@@ -1086,21 +1090,21 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId(), generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1109,7 +1113,7 @@ public interface EmailChangeRepositoryContract {
repository.save(oldState).block();
repository.save(change1).block();
- assertThatThrownBy(() ->
repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(1))).block().getAllChanges())
+ assertThatThrownBy(() ->
repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(1))).block().getAllChanges())
.isInstanceOf(CanNotCalculateChangesException.class)
.hasMessage("Current change collector limit 1 is exceeded by a
single change, hence we cannot calculate changes.");
}
@@ -1121,21 +1125,21 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId(), generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1145,7 +1149,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.empty()).block().getNewState())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.empty()).block().getNewState())
.isEqualTo(change2.getState());
}
@@ -1156,21 +1160,21 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId(), generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1180,7 +1184,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(2))).block().hasMoreChanges())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(2))).block().hasMoreChanges())
.isTrue();
}
@@ -1191,21 +1195,21 @@ public interface EmailChangeRepositoryContract {
State state = generateNewState();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(generateNewMessageId())
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.created(generateNewMessageId(), generateNewMessageId())
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1215,7 +1219,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(4))).block().hasMoreChanges())
+ assertThat(repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(4))).block().hasMoreChanges())
.isFalse();
}
@@ -1237,21 +1241,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId10 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1, messageId9, messageId10)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2, messageId3, messageId4, messageId5)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
@@ -1260,7 +1264,7 @@ public interface EmailChangeRepositoryContract {
.destroyed(messageId4, messageId9)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1273,7 +1277,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- EmailChanges emailChanges = repository.getSinceState(ACCOUNT_ID,
state, Optional.of(Limit.of(20))).block();
+ EmailChanges emailChanges = repository.getSinceState(accountId(),
state, Optional.of(Limit.of(20))).block();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(emailChanges.getCreated()).containsExactlyInAnyOrder(messageId2,
messageId3, messageId6, messageId7, messageId8);
@@ -1297,28 +1301,28 @@ public interface EmailChangeRepositoryContract {
MessageId messageId8 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(3))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId2, messageId3, messageId4, messageId5)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(true)
.created(messageId6, messageId7)
.build();
EmailChange change3 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1329,7 +1333,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- EmailChanges emailChanges =
repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(20))).block();
+ EmailChanges emailChanges =
repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(20))).block();
assertThat(emailChanges.getCreated())
.containsExactlyInAnyOrder(messageId2, messageId3, messageId4,
messageId5, messageId6, messageId7, messageId8);
@@ -1346,21 +1350,21 @@ public interface EmailChangeRepositoryContract {
MessageId messageId3 = generateNewMessageId();
EmailChange oldState = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(state)
.date(DATE.minusHours(2))
.isShared(false)
.created(messageId1)
.build();
EmailChange change1 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE.minusHours(1))
.isShared(false)
.updated(messageId1, messageId2)
.build();
EmailChange change2 = EmailChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(generateNewState())
.date(DATE)
.isShared(false)
@@ -1371,7 +1375,7 @@ public interface EmailChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- EmailChanges emailChanges =
repository.getSinceStateWithDelegation(ACCOUNT_ID, state,
Optional.of(Limit.of(3))).block();
+ EmailChanges emailChanges =
repository.getSinceStateWithDelegation(accountId(), state,
Optional.of(Limit.of(3))).block();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(emailChanges.getUpdated()).containsExactly(messageId1,
messageId2);
softly.assertThat(emailChanges.getCreated()).containsExactly(messageId3);
@@ -1382,7 +1386,7 @@ public interface EmailChangeRepositoryContract {
default void getSinceStateWithDelegationShouldFailWhenSinceStateNotFound()
{
EmailChangeRepository repository = emailChangeRepository();
- assertThatThrownBy(() ->
repository.getSinceStateWithDelegation(ACCOUNT_ID, generateNewState(),
Optional.empty()).block())
+ assertThatThrownBy(() ->
repository.getSinceStateWithDelegation(accountId(), generateNewState(),
Optional.empty()).block())
.isInstanceOf(ChangeNotFoundException.class);
}
}
diff --git
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
index 3d2c6972d4..3a38050074 100644
---
a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
+++
b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
@@ -40,6 +40,10 @@ public interface MailboxChangeRepositoryContract {
ZonedDateTime DATE = ZonedDateTime.now();
Limit DEFAULT_NUMBER_OF_CHANGES = Limit.of(5);
+ default AccountId accountId() {
+ return ACCOUNT_ID;
+ }
+
State.Factory stateFactory();
MailboxChangeRepository mailboxChangeRepository();
@@ -52,7 +56,7 @@ public interface MailboxChangeRepositoryContract {
State state = stateFactory().generate();
MailboxId id1 = generateNewMailboxId();
- MailboxChange change =
MailboxChange.builder().accountId(ACCOUNT_ID).state(state).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change =
MailboxChange.builder().accountId(accountId()).state(state).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
assertThatCode(() -> repository.save(change).block())
.doesNotThrowAnyException();
@@ -62,7 +66,7 @@ public interface MailboxChangeRepositoryContract {
default void getLatestStateShouldReturnInitialWhenEmpty() {
MailboxChangeRepository repository = mailboxChangeRepository();
- assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ assertThat(repository.getLatestState(accountId()).block())
.isEqualTo(State.INITIAL);
}
@@ -73,14 +77,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id3)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id3)).build();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ assertThat(repository.getLatestState(accountId()).block())
.isEqualTo(change3.getState());
}
@@ -92,10 +96,10 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
MailboxChange change3 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(false)
@@ -106,7 +110,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ assertThat(repository.getLatestState(accountId()).block())
.isEqualTo(change2.getState());
}
@@ -114,7 +118,7 @@ public interface MailboxChangeRepositoryContract {
default void getLatestStateWithDelegationShouldReturnInitialWhenEmpty() {
MailboxChangeRepository repository = mailboxChangeRepository();
- assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+
assertThat(repository.getLatestStateWithDelegation(accountId()).block())
.isEqualTo(State.INITIAL);
}
@@ -126,14 +130,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id3)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id3)).build();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+
assertThat(repository.getLatestStateWithDelegation(accountId()).block())
.isEqualTo(change3.getState());
}
@@ -145,10 +149,10 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2)).build();
MailboxChange change3 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(false)
@@ -159,7 +163,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+
assertThat(repository.getLatestStateWithDelegation(accountId()).block())
.isEqualTo(change3.getState());
}
@@ -171,12 +175,12 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2)).build();
repository.save(oldState).block();
repository.save(change).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.empty()).block().getAllChanges())
.hasSameElementsAs(change.getUpdated());
}
@@ -187,10 +191,10 @@ public interface MailboxChangeRepositoryContract {
State referenceState = stateFactory.generate();
MailboxId id1 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
repository.save(oldState).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.empty()).block().getAllChanges())
.isEmpty();
}
@@ -201,10 +205,10 @@ public interface MailboxChangeRepositoryContract {
State referenceState = stateFactory.generate();
MailboxId id1 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
repository.save(oldState).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.empty()).block().getNewState())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.empty()).block().getNewState())
.isEqualTo(oldState.getState());
}
@@ -218,16 +222,16 @@ public interface MailboxChangeRepositoryContract {
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
MailboxId id4 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id3)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id3)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.of(Limit.of(3))).block().getCreated())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.of(Limit.of(3))).block().getCreated())
.containsExactlyInAnyOrder(id2, id3, id4);
}
@@ -241,16 +245,16 @@ public interface MailboxChangeRepositoryContract {
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
MailboxId id4 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id3)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id3)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.of(Limit.of(3))).block().getCreated())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.of(Limit.of(3))).block().getCreated())
.containsExactlyInAnyOrder(id1, id2, id3);
}
@@ -264,20 +268,20 @@ public interface MailboxChangeRepositoryContract {
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
MailboxId id4 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
State state2 = stateFactory.generate();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(state2).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id3)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(state2).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id3)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.of(Limit.of(3))).block().getNewState())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.of(Limit.of(3))).block().getNewState())
.isEqualTo(state2);
}
@@ -292,16 +296,16 @@ public interface MailboxChangeRepositoryContract {
MailboxId id3 = generateNewMailboxId();
MailboxId id4 = generateNewMailboxId();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).shared(true).created(ImmutableList.of(id3)).build();
- MailboxChange change4 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).shared(true).created(ImmutableList.of(id4)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).shared(true).created(ImmutableList.of(id3)).build();
+ MailboxChange change4 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).shared(true).created(ImmutableList.of(id4)).build();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
repository.save(change4).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.empty()).block().getCreated())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.empty()).block().getCreated())
.containsExactlyInAnyOrder(id1, id2);
}
@@ -316,16 +320,16 @@ public interface MailboxChangeRepositoryContract {
MailboxId id3 = generateNewMailboxId();
MailboxId id4 = generateNewMailboxId();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
- MailboxChange change3 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).shared(true).created(ImmutableList.of(id3)).build();
- MailboxChange change4 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).shared(true).created(ImmutableList.of(id4)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange change3 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).shared(true).created(ImmutableList.of(id3)).build();
+ MailboxChange change4 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).shared(true).created(ImmutableList.of(id4)).build();
repository.save(change1).block();
repository.save(change2).block();
repository.save(change3).block();
repository.save(change4).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID,
State.INITIAL, Optional.empty()).block().getCreated())
+ assertThat(repository.getSinceStateWithDelegation(accountId(),
State.INITIAL, Optional.empty()).block().getCreated())
.containsExactlyInAnyOrder(id1, id2, id3, id4);
}
@@ -342,15 +346,15 @@ public interface MailboxChangeRepositoryContract {
MailboxId id5 = generateNewMailboxId();
MailboxId id6 = generateNewMailboxId();
MailboxId id7 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3, id4, id5, id6)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id7)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3, id4, id5, id6)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id7)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.empty()).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.empty()).block().getAllChanges())
.hasSameElementsAs(change1.getCreated());
}
@@ -365,14 +369,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id3 = generateNewMailboxId();
MailboxId id4 = generateNewMailboxId();
MailboxId id5 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4,
id5)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id4,
id5)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.of(Limit.of(3))).block().getAllChanges())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.of(Limit.of(3))).block().getAllChanges())
.hasSameElementsAs(change1.getCreated());
}
@@ -385,12 +389,12 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
repository.save(oldState).block();
repository.save(change1).block();
- assertThatThrownBy(() -> repository.getSinceState(ACCOUNT_ID,
referenceState, Optional.of(Limit.of(1))).block().getAllChanges())
+ assertThatThrownBy(() -> repository.getSinceState(accountId(),
referenceState, Optional.of(Limit.of(1))).block().getAllChanges())
.isInstanceOf(CanNotCalculateChangesException.class)
.hasMessage("Current change collector limit 1 is exceeded by a
single change, hence we cannot calculate changes.");
}
@@ -404,14 +408,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2,
id3)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2,
id3)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.empty()).block().getNewState())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.empty()).block().getNewState())
.isEqualTo(change2.getState());
}
@@ -424,14 +428,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2,
id1)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2,
id1)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.of(Limit.of(2))).block().hasMoreChanges())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.of(Limit.of(2))).block().hasMoreChanges())
.isTrue();
}
@@ -444,14 +448,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
- MailboxChange change2 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2,
id3)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).created(ImmutableList.of(id2,
id3)).build();
+ MailboxChange change2 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).updated(ImmutableList.of(id2,
id3)).build();
repository.save(oldState).block();
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, referenceState,
Optional.of(Limit.of(4))).block().hasMoreChanges())
+ assertThat(repository.getSinceState(accountId(), referenceState,
Optional.of(Limit.of(4))).block().hasMoreChanges())
.isFalse();
}
@@ -471,10 +475,10 @@ public interface MailboxChangeRepositoryContract {
MailboxId id8 = generateNewMailboxId();
MailboxId id9 = generateNewMailboxId();
MailboxId id10 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2,
id3, id4, id5)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(3)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id2,
id3, id4, id5)).build();
MailboxChange change2 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE.minusHours(1))
.isCountChange(false)
@@ -482,7 +486,7 @@ public interface MailboxChangeRepositoryContract {
.updated(ImmutableList.of(id2, id3, id9))
.destroyed(ImmutableList.of(id4)).build();
MailboxChange change3 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(false)
@@ -495,7 +499,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change2).block();
repository.save(change3).block();
- MailboxChanges mailboxChanges = repository.getSinceState(ACCOUNT_ID,
referenceState, Optional.of(Limit.of(20))).block();
+ MailboxChanges mailboxChanges = repository.getSinceState(accountId(),
referenceState, Optional.of(Limit.of(20))).block();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(mailboxChanges.getCreated()).containsExactlyInAnyOrder(id2,
id3, id6, id7, id8);
@@ -513,10 +517,10 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxId id3 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change1 =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).updated(ImmutableList.of(id1,
id2)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change1 =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE.minusHours(1)).isCountChange(false).updated(ImmutableList.of(id1,
id2)).build();
MailboxChange change2 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(false)
@@ -528,7 +532,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- MailboxChanges mailboxChanges = repository.getSinceState(ACCOUNT_ID,
referenceState, Optional.of(Limit.of(3))).block();
+ MailboxChanges mailboxChanges = repository.getSinceState(accountId(),
referenceState, Optional.of(Limit.of(3))).block();
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(mailboxChanges.getUpdated()).containsExactlyInAnyOrder(id1,
id2);
softly.assertThat(mailboxChanges.getCreated()).containsExactly(id3);
@@ -542,9 +546,9 @@ public interface MailboxChangeRepositoryContract {
State referenceState = stateFactory.generate();
MailboxId id1 = generateNewMailboxId();
- MailboxChange oldState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange oldState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE.minusHours(2)).isCountChange(false).created(ImmutableList.of(id1)).build();
MailboxChange change1 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE.minusHours(1))
.isCountChange(false)
@@ -555,7 +559,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(oldState).block();
repository.save(change1).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID,
referenceState, Optional.empty()).block().getUpdated())
+ assertThat(repository.getSinceStateWithDelegation(accountId(),
referenceState, Optional.empty()).block().getUpdated())
.containsExactly(id1);
}
@@ -563,7 +567,7 @@ public interface MailboxChangeRepositoryContract {
default void isCountChangeOnlyShouldBeFalseWhenNoChanges() {
MailboxChangeRepository repository = mailboxChangeRepository();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.empty()).block().isCountChangesOnly())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.empty()).block().isCountChangesOnly())
.isFalse();
}
@@ -575,14 +579,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxChange change1 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE.minusHours(1))
.isCountChange(false)
.created(ImmutableList.of(id1))
.build();
MailboxChange change2 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(false)
@@ -592,7 +596,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.empty()).block().isCountChangesOnly())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.empty()).block().isCountChangesOnly())
.isFalse();
}
@@ -604,14 +608,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxChange change1 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE.minusHours(1))
.isCountChange(false)
.created(ImmutableList.of(id1))
.build();
MailboxChange change2 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(false)
@@ -621,7 +625,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceState(ACCOUNT_ID, State.INITIAL,
Optional.empty()).block().isCountChangesOnly())
+ assertThat(repository.getSinceState(accountId(), State.INITIAL,
Optional.empty()).block().isCountChangesOnly())
.isFalse();
}
@@ -633,14 +637,14 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
MailboxChange change1 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE.minusHours(1))
.isCountChange(true)
.updated(ImmutableList.of(id1))
.build();
MailboxChange change2 = MailboxChange.builder()
- .accountId(ACCOUNT_ID)
+ .accountId(accountId())
.state(stateFactory.generate())
.date(DATE)
.isCountChange(true)
@@ -650,7 +654,7 @@ public interface MailboxChangeRepositoryContract {
repository.save(change1).block();
repository.save(change2).block();
- assertThat(repository.getSinceStateWithDelegation(ACCOUNT_ID,
State.INITIAL, Optional.empty()).block().isCountChangesOnly())
+ assertThat(repository.getSinceStateWithDelegation(accountId(),
State.INITIAL, Optional.empty()).block().isCountChangesOnly())
.isTrue();
}
@@ -662,12 +666,12 @@ public interface MailboxChangeRepositoryContract {
MailboxId id1 = generateNewMailboxId();
MailboxId id2 = generateNewMailboxId();
- MailboxChange currentState =
MailboxChange.builder().accountId(ACCOUNT_ID).state(referenceState).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
- MailboxChange change =
MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id2)).build();
+ MailboxChange currentState =
MailboxChange.builder().accountId(accountId()).state(referenceState).date(DATE).isCountChange(false).created(ImmutableList.of(id1)).build();
+ MailboxChange change =
MailboxChange.builder().accountId(accountId()).state(stateFactory.generate()).date(DATE).isCountChange(false).created(ImmutableList.of(id2)).build();
repository.save(currentState).block();
repository.save(change).block();
- assertThatThrownBy(() -> repository.getSinceState(ACCOUNT_ID,
referenceState, Optional.of(Limit.of(-1))))
+ assertThatThrownBy(() -> repository.getSinceState(accountId(),
referenceState, Optional.of(Limit.of(-1))))
.isInstanceOf(IllegalArgumentException.class);
}
@@ -677,7 +681,7 @@ public interface MailboxChangeRepositoryContract {
State.Factory stateFactory = stateFactory();
State referenceState = stateFactory.generate();
- assertThatThrownBy(() -> repository.getSinceState(ACCOUNT_ID,
referenceState, Optional.empty()).block())
+ assertThatThrownBy(() -> repository.getSinceState(accountId(),
referenceState, Optional.empty()).block())
.isInstanceOf(ChangeNotFoundException.class);
}
}
diff --git
a/server/data/data-jmap/src/test/scala/org/apache/james/jmap/api/pushsubscription/PushSubscriptionRepositoryContract.scala
b/server/data/data-jmap/src/test/scala/org/apache/james/jmap/api/pushsubscription/PushSubscriptionRepositoryContract.scala
index ff3d2ee50a..93dda35495 100644
---
a/server/data/data-jmap/src/test/scala/org/apache/james/jmap/api/pushsubscription/PushSubscriptionRepositoryContract.scala
+++
b/server/data/data-jmap/src/test/scala/org/apache/james/jmap/api/pushsubscription/PushSubscriptionRepositoryContract.scala
@@ -75,14 +75,16 @@ trait PushSubscriptionRepositoryContract {
def clock: UpdatableTickingClock
def testee: PushSubscriptionRepository
+ def alice() = ALICE;
+
@Test
def validSubscriptionShouldBeSavedSuccessfully(): Unit = {
val validRequest = PushSubscriptionCreationRequest(
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- val singleRecordSaved = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).count().block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ val singleRecordSaved = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).count().block()
assertThat(singleRecordSaved).isEqualTo(1)
}
@@ -93,8 +95,8 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- val newSavedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ val newSavedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(newSavedSubscription.validated).isEqualTo(false)
}
@@ -106,8 +108,8 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
expires = Some(PushSubscriptionExpiredTime(VALID_EXPIRE.plusDays(8))),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
request)).block().id
- val newSavedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
request)).block().id
+ val newSavedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(newSavedSubscription.expires.value).isEqualTo(MAX_EXPIRE)
}
@@ -120,7 +122,7 @@ trait PushSubscriptionRepositoryContract {
expires = Some(PushSubscriptionExpiredTime(INVALID_EXPIRE)),
types = Some(Seq(CustomTypeName1)))
- assertThatThrownBy(() => SMono.fromPublisher(testee.save(ALICE,
invalidRequest)).block())
+ assertThatThrownBy(() => SMono.fromPublisher(testee.save(alice(),
invalidRequest)).block())
.isInstanceOf(classOf[ExpireTimeInvalidException])
}
@@ -130,14 +132,14 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- SMono.fromPublisher(testee.save(ALICE, firstRequest)).block()
+ SMono.fromPublisher(testee.save(alice(), firstRequest)).block()
val secondRequestWithDuplicatedDeviceClientId =
PushSubscriptionCreationRequest(
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- assertThatThrownBy(() => SMono.fromPublisher(testee.save(ALICE,
secondRequestWithDuplicatedDeviceClientId)).block())
+ assertThatThrownBy(() => SMono.fromPublisher(testee.save(alice(),
secondRequestWithDuplicatedDeviceClientId)).block())
.isInstanceOf(classOf[DeviceClientIdInvalidException])
}
@@ -147,9 +149,9 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
- assertThatThrownBy(() =>
SMono.fromPublisher(testee.updateExpireTime(ALICE, pushSubscriptionId,
INVALID_EXPIRE)).block())
+ assertThatThrownBy(() =>
SMono.fromPublisher(testee.updateExpireTime(alice(), pushSubscriptionId,
INVALID_EXPIRE)).block())
.isInstanceOf(classOf[ExpireTimeInvalidException])
}
@@ -159,10 +161,10 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- SMono.fromPublisher(testee.updateExpireTime(ALICE, pushSubscriptionId,
MAX_EXPIRE.plusDays(1))).block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ SMono.fromPublisher(testee.updateExpireTime(alice(), pushSubscriptionId,
MAX_EXPIRE.plusDays(1))).block()
- val updatedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val updatedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(updatedSubscription.expires.value).isEqualTo(MAX_EXPIRE)
}
@@ -170,7 +172,7 @@ trait PushSubscriptionRepositoryContract {
def updateExpiresWithNotFoundPushSubscriptionIdShouldThrowException(): Unit
= {
val randomId = PushSubscriptionId.generate()
- assertThatThrownBy(() =>
SMono.fromPublisher(testee.updateExpireTime(ALICE, randomId,
VALID_EXPIRE)).block())
+ assertThatThrownBy(() =>
SMono.fromPublisher(testee.updateExpireTime(alice(), randomId,
VALID_EXPIRE)).block())
.isInstanceOf(classOf[PushSubscriptionNotFoundException])
}
@@ -180,10 +182,10 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- SMono.fromPublisher(testee.updateExpireTime(ALICE, pushSubscriptionId,
VALID_EXPIRE)).block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ SMono.fromPublisher(testee.updateExpireTime(alice(), pushSubscriptionId,
VALID_EXPIRE)).block()
- val updatedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val updatedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(updatedSubscription.expires.value).isEqualTo(VALID_EXPIRE)
}
@@ -193,8 +195,8 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- val fixedExpires = SMono.fromPublisher(testee.updateExpireTime(ALICE,
pushSubscriptionId, MAX_EXPIRE.plusDays(1))).block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ val fixedExpires = SMono.fromPublisher(testee.updateExpireTime(alice(),
pushSubscriptionId, MAX_EXPIRE.plusDays(1))).block()
assertThat(fixedExpires).isEqualTo(PushSubscriptionExpiredTime(MAX_EXPIRE))
}
@@ -205,12 +207,12 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
val newTypes: Set[TypeName] = Set(CustomTypeName1, CustomTypeName2)
- SMono.fromPublisher(testee.updateTypes(ALICE, pushSubscriptionId,
newTypes.asJava)).block()
+ SMono.fromPublisher(testee.updateTypes(alice(), pushSubscriptionId,
newTypes.asJava)).block()
- val updatedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val updatedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(updatedSubscription.types.toSet.asJava).containsExactlyInAnyOrder(CustomTypeName1,
CustomTypeName2)
}
@@ -219,7 +221,7 @@ trait PushSubscriptionRepositoryContract {
val randomId = PushSubscriptionId.generate()
val newTypes: Set[TypeName] = Set(CustomTypeName1, CustomTypeName2)
- assertThatThrownBy(() => SMono.fromPublisher(testee.updateTypes(ALICE,
randomId, newTypes.asJava)).block())
+ assertThatThrownBy(() => SMono.fromPublisher(testee.updateTypes(alice(),
randomId, newTypes.asJava)).block())
.isInstanceOf(classOf[PushSubscriptionNotFoundException])
}
@@ -227,7 +229,7 @@ trait PushSubscriptionRepositoryContract {
def getNotFoundShouldReturnEmpty(): Unit = {
val randomId = PushSubscriptionId.generate()
- assertThat(SMono.fromPublisher(testee.get(ALICE,
Set(randomId).asJava)).blockOption().toJava)
+ assertThat(SMono.fromPublisher(testee.get(alice(),
Set(randomId).asJava)).blockOption().toJava)
.isEmpty
}
@@ -237,12 +239,12 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- val singleRecordSaved = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).count().block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ val singleRecordSaved = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).count().block()
assertThat(singleRecordSaved).isEqualTo(1)
- SMono.fromPublisher(testee.revoke(ALICE, pushSubscriptionId)).block()
- val remaining = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).collectSeq().block().asJava
+ SMono.fromPublisher(testee.revoke(alice(), pushSubscriptionId)).block()
+ val remaining = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).collectSeq().block().asJava
assertThat(remaining).isEmpty()
}
@@ -253,12 +255,12 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- val singleRecordSaved = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).count().block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ val singleRecordSaved = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).count().block()
assertThat(singleRecordSaved).isEqualTo(1)
- SMono.fromPublisher(testee.delete(ALICE)).block()
- val remaining = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).collectSeq().block().asJava
+ SMono.fromPublisher(testee.delete(alice())).block()
+ val remaining = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).collectSeq().block().asJava
assertThat(remaining).isEmpty()
}
@@ -266,14 +268,14 @@ trait PushSubscriptionRepositoryContract {
@Test
def revokeNotFoundShouldNotFail(): Unit = {
val pushSubscriptionId = PushSubscriptionId.generate()
- assertThatCode(() => SMono.fromPublisher(testee.revoke(ALICE,
pushSubscriptionId)).block())
+ assertThatCode(() => SMono.fromPublisher(testee.revoke(alice(),
pushSubscriptionId)).block())
.doesNotThrowAnyException()
}
@Test
def deleteNotFoundShouldNotFail(): Unit = {
val pushSubscriptionId = PushSubscriptionId.generate()
- assertThatCode(() => SMono.fromPublisher(testee.delete(ALICE)).block())
+ assertThatCode(() => SMono.fromPublisher(testee.delete(alice())).block())
.doesNotThrowAnyException()
}
@@ -291,10 +293,10 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
expires = Option(PushSubscriptionExpiredTime(VALID_EXPIRE)),
types = Some(Seq(CustomTypeName2)))
- val pushSubscriptionId1 = SMono.fromPublisher(testee.save(ALICE,
validRequest1)).block().id
- val pushSubscriptionId2 = SMono.fromPublisher(testee.save(ALICE,
validRequest2)).block().id
+ val pushSubscriptionId1 = SMono.fromPublisher(testee.save(alice(),
validRequest1)).block().id
+ val pushSubscriptionId2 = SMono.fromPublisher(testee.save(alice(),
validRequest2)).block().id
- val pushSubscriptions = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId1, pushSubscriptionId2).asJava)).collectSeq().block()
+ val pushSubscriptions = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId1, pushSubscriptionId2).asJava)).collectSeq().block()
assertThat(pushSubscriptions.map(_.id).toList.asJava).containsExactlyInAnyOrder(pushSubscriptionId1,
pushSubscriptionId2)
}
@@ -307,10 +309,10 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
expires = Option(PushSubscriptionExpiredTime(VALID_EXPIRE)),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId1 = SMono.fromPublisher(testee.save(ALICE,
validRequest1)).block().id
+ val pushSubscriptionId1 = SMono.fromPublisher(testee.save(alice(),
validRequest1)).block().id
val pushSubscriptionId2 = PushSubscriptionId.generate()
- val pushSubscriptions = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId1, pushSubscriptionId2).asJava)).collectSeq().block()
+ val pushSubscriptions = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId1, pushSubscriptionId2).asJava)).collectSeq().block()
assertThat(pushSubscriptions.map(_.id).toList.asJava).containsExactlyInAnyOrder(pushSubscriptionId1)
}
@@ -322,11 +324,11 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
expires = Option(PushSubscriptionExpiredTime(VALID_EXPIRE.plusDays(1))),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest1)).block().id
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest1)).block().id
clock.setInstant(VALID_EXPIRE.plusDays(2).toInstant)
- val pushSubscriptions = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).collectSeq().block()
+ val pushSubscriptions = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).collectSeq().block()
assertThat(pushSubscriptions.map(_.id).toList.asJava).containsOnly(pushSubscriptionId)
}
@@ -343,10 +345,10 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = deviceClientId2,
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName2)))
- val pushSubscriptionId1: PushSubscriptionId =
SMono.fromPublisher(testee.save(ALICE, validRequest1)).block().id
- val pushSubscriptionId2: PushSubscriptionId =
SMono.fromPublisher(testee.save(ALICE, validRequest2)).block().id
+ val pushSubscriptionId1: PushSubscriptionId =
SMono.fromPublisher(testee.save(alice(), validRequest1)).block().id
+ val pushSubscriptionId2: PushSubscriptionId =
SMono.fromPublisher(testee.save(alice(), validRequest2)).block().id
- val idList: List[PushSubscription] =
SFlux(testee.list(ALICE)).collectSeq().block().toList
+ val idList: List[PushSubscription] =
SFlux(testee.list(alice())).collectSeq().block().toList
SoftAssertions.assertSoftly(softly => {
softly.assertThat(idList.map(_.id).asJava).containsExactlyInAnyOrder(pushSubscriptionId1,
pushSubscriptionId2)
@@ -361,11 +363,11 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
expires = Option(PushSubscriptionExpiredTime(VALID_EXPIRE.plusDays(1))),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest1)).block().id
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest1)).block().id
clock.setInstant(VALID_EXPIRE.plusDays(2).toInstant)
- val pushSubscriptions =
SFlux.fromPublisher(testee.list(ALICE)).collectSeq().block()
+ val pushSubscriptions =
SFlux.fromPublisher(testee.list(alice())).collectSeq().block()
assertThat(pushSubscriptions.map(_.id).toList.asJava).containsOnly(pushSubscriptionId)
}
@@ -376,10 +378,10 @@ trait PushSubscriptionRepositoryContract {
deviceClientId = DeviceClientId("1"),
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
- SMono.fromPublisher(testee.validateVerificationCode(ALICE,
pushSubscriptionId)).block()
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
+ SMono.fromPublisher(testee.validateVerificationCode(alice(),
pushSubscriptionId)).block()
- val validatedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val validatedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(validatedSubscription.validated).isEqualTo(true)
}
@@ -387,7 +389,7 @@ trait PushSubscriptionRepositoryContract {
def
validateVerificationCodeWithNotFoundPushSubscriptionIdShouldThrowException():
Unit = {
val randomId = PushSubscriptionId.generate()
- assertThatThrownBy(() =>
SMono.fromPublisher(testee.validateVerificationCode(ALICE, randomId)).block())
+ assertThatThrownBy(() =>
SMono.fromPublisher(testee.validateVerificationCode(alice(), randomId)).block())
.isInstanceOf(classOf[PushSubscriptionNotFoundException])
}
@@ -400,9 +402,9 @@ trait PushSubscriptionRepositoryContract {
types = Some(Seq(CustomTypeName1)),
keys = fullKeyPair)
- val pushSubscriptionId1 = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
+ val pushSubscriptionId1 = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
- val pushSubscriptions = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId1).asJava)).collectSeq().block()
+ val pushSubscriptions = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId1).asJava)).collectSeq().block()
assertThat(pushSubscriptions.map(_.keys).toList.asJava).containsExactlyInAnyOrder(fullKeyPair)
}
@@ -415,9 +417,9 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new
URI("https://example.com/push").toURL()),
types = Some(Seq(CustomTypeName1)),
keys = emptyKeyPair)
- val pushSubscriptionId1 = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
+ val pushSubscriptionId1 = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
- val pushSubscriptions = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId1).asJava)).collectSeq().block()
+ val pushSubscriptions = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId1).asJava)).collectSeq().block()
assertThat(pushSubscriptions.map(_.keys).toList.asJava).containsExactlyInAnyOrder(emptyKeyPair)
}
@@ -432,7 +434,7 @@ trait PushSubscriptionRepositoryContract {
types = Some(Seq(CustomTypeName1)),
keys = emptyP256hKey)
- assertThatThrownBy(() => SMono.fromPublisher(testee.save(ALICE,
validRequest)).block())
+ assertThatThrownBy(() => SMono.fromPublisher(testee.save(alice(),
validRequest)).block())
.isInstanceOf(classOf[InvalidPushSubscriptionKeys])
}
@@ -446,7 +448,7 @@ trait PushSubscriptionRepositoryContract {
types = Some(Seq(CustomTypeName1)),
keys = emptyAuthKey)
- assertThatThrownBy(() => SMono.fromPublisher(testee.save(ALICE,
validRequest)).block())
+ assertThatThrownBy(() => SMono.fromPublisher(testee.save(alice(),
validRequest)).block())
.isInstanceOf(classOf[InvalidPushSubscriptionKeys])
}
@@ -457,15 +459,15 @@ trait PushSubscriptionRepositoryContract {
url = PushSubscriptionServerURL(new URL("https://example.com/push")),
types = Some(Seq(CustomTypeName1)))
- val pushSubscriptionId = SMono.fromPublisher(testee.save(ALICE,
validRequest)).block().id
+ val pushSubscriptionId = SMono.fromPublisher(testee.save(alice(),
validRequest)).block().id
val ZONE_ID: ZoneId = ZoneId.of("Europe/Paris")
val CLOCK: Clock = Clock.fixed(Instant.parse("2021-10-25T07:05:39.160Z"),
ZONE_ID)
val zonedDateTime: ZonedDateTime = ZonedDateTime.now(CLOCK)
- SMono.fromPublisher(testee.updateExpireTime(ALICE, pushSubscriptionId,
zonedDateTime)).block()
+ SMono.fromPublisher(testee.updateExpireTime(alice(), pushSubscriptionId,
zonedDateTime)).block()
- val updatedSubscription = SFlux.fromPublisher(testee.get(ALICE,
Set(pushSubscriptionId).asJava)).blockFirst().get
+ val updatedSubscription = SFlux.fromPublisher(testee.get(alice(),
Set(pushSubscriptionId).asJava)).blockFirst().get
assertThat(updatedSubscription.expires.value).isEqualTo(zonedDateTime)
}
diff --git
a/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
b/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
index b5779b0235..d630452f92 100644
---
a/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
+++
b/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
class PostgresVacationRepositoryTest implements VacationRepositoryContract {
@RegisterExtension
- static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(PostgresDataDefinition.aggregateModules(PostgresVacationDataDefinition.MODULE));
+ static PostgresExtension postgresExtension =
PostgresExtension.withoutRowLevelSecurity(PostgresDataDefinition.aggregateModules(PostgresVacationDataDefinition.MODULE));
VacationRepository vacationRepository;
diff --git
a/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
b/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryWithLRSTest.java
similarity index 89%
copy from
server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
copy to
server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryWithLRSTest.java
index b5779b0235..f155541a51 100644
---
a/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryTest.java
+++
b/server/data/data-postgres/src/test/java/org/apache/james/vacation/postgres/PostgresVacationRepositoryWithLRSTest.java
@@ -21,12 +21,13 @@ package org.apache.james.vacation.postgres;
import org.apache.james.backends.postgres.PostgresDataDefinition;
import org.apache.james.backends.postgres.PostgresExtension;
+import org.apache.james.vacation.api.AccountId;
import org.apache.james.vacation.api.VacationRepository;
import org.apache.james.vacation.api.VacationRepositoryContract;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
-class PostgresVacationRepositoryTest implements VacationRepositoryContract {
+class PostgresVacationRepositoryWithLRSTest implements
VacationRepositoryContract {
@RegisterExtension
static PostgresExtension postgresExtension =
PostgresExtension.withRowLevelSecurity(PostgresDataDefinition.aggregateModules(PostgresVacationDataDefinition.MODULE));
@@ -41,4 +42,9 @@ class PostgresVacationRepositoryTest implements
VacationRepositoryContract {
public VacationRepository vacationRepository() {
return vacationRepository;
}
+
+ @Override
+ public AccountId accountId() {
+ return AccountId.fromString("[email protected]");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]