JAMES-1717 Changing vacations should flush notification registry
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3e738bc3 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3e738bc3 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3e738bc3 Branch: refs/heads/master Commit: 3e738bc31c06f9ee8dc40e8e9e9cad59dc41df7d Parents: 0be6047 Author: Benoit Tellier <btell...@linagora.com> Authored: Wed Apr 20 13:33:59 2016 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Fri May 27 18:02:46 2016 +0700 ---------------------------------------------------------------------- .../jmap/methods/SetVacationResponseMethod.java | 6 +++++- .../jmap/methods/SetVacationResponseMethodTest.java | 16 ++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/3e738bc3/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java index cc022c3..136a162 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetVacationResponseMethod.java @@ -24,6 +24,7 @@ import java.util.stream.Stream; import javax.inject.Inject; import org.apache.james.jmap.api.vacation.AccountId; +import org.apache.james.jmap.api.vacation.NotificationRegistry; import org.apache.james.jmap.api.vacation.Vacation; import org.apache.james.jmap.api.vacation.VacationRepository; import org.apache.james.jmap.model.ClientId; @@ -45,10 +46,12 @@ public class SetVacationResponseMethod implements Method { public static final String INVALID_ARGUMENT_DESCRIPTION = "update field should just contain one entry with key \"singleton\""; private final VacationRepository vacationRepository; + private final NotificationRegistry notificationRegistry; @Inject - public SetVacationResponseMethod(VacationRepository vacationRepository) { + public SetVacationResponseMethod(VacationRepository vacationRepository, NotificationRegistry notificationRegistry) { this.vacationRepository = vacationRepository; + this.notificationRegistry = notificationRegistry; } @Override @@ -90,6 +93,7 @@ public class SetVacationResponseMethod implements Method { private Stream<JmapResponse> process(ClientId clientId, AccountId accountId, VacationResponse vacationResponse) { if (vacationResponse.isValid()) { vacationRepository.modifyVacation(accountId, convertToVacation(vacationResponse)).join(); + notificationRegistry.flush(accountId); return Stream.of(JmapResponse.builder() .clientId(clientId) .responseName(RESPONSE_NAME) http://git-wip-us.apache.org/repos/asf/james-project/blob/3e738bc3/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetVacationResponseMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetVacationResponseMethodTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetVacationResponseMethodTest.java index 338430f..69d1c72 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetVacationResponseMethodTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetVacationResponseMethodTest.java @@ -32,6 +32,7 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.Stream; import org.apache.james.jmap.api.vacation.AccountId; +import org.apache.james.jmap.api.vacation.NotificationRegistry; import org.apache.james.jmap.api.vacation.Vacation; import org.apache.james.jmap.api.vacation.VacationRepository; import org.apache.james.jmap.model.ClientId; @@ -74,13 +75,15 @@ public class SetVacationResponseMethodTest { private VacationRepository vacationRepository; private ClientId clientId; private MailboxSession mailboxSession; + private NotificationRegistry notificationRegistry; @Before public void setUp() { clientId = mock(ClientId.class); mailboxSession = mock(MailboxSession.class); vacationRepository = mock(VacationRepository.class); - testee = new SetVacationResponseMethod(vacationRepository); + notificationRegistry = mock(NotificationRegistry.class); + testee = new SetVacationResponseMethod(vacationRepository, notificationRegistry); } @Test(expected = NullPointerException.class) @@ -119,7 +122,7 @@ public class SetVacationResponseMethodTest { .build()) .build(); assertThat(result).containsExactly(expected); - verifyNoMoreInteractions(vacationRepository); + verifyNoMoreInteractions(vacationRepository, notificationRegistry); } @Test @@ -142,7 +145,7 @@ public class SetVacationResponseMethodTest { .build()) .build(); assertThat(result).containsExactly(expected); - verifyNoMoreInteractions(vacationRepository); + verifyNoMoreInteractions(vacationRepository, notificationRegistry); } @Test @@ -170,7 +173,7 @@ public class SetVacationResponseMethodTest { .build()) .build(); assertThat(result).containsExactly(expected); - verifyNoMoreInteractions(vacationRepository); + verifyNoMoreInteractions(vacationRepository, notificationRegistry); } @Test @@ -205,7 +208,8 @@ public class SetVacationResponseMethodTest { assertThat(result).containsExactly(expected); verify(vacationRepository).modifyVacation(accountId, vacation); - verifyNoMoreInteractions(vacationRepository); + verify(notificationRegistry).flush(accountId); + verifyNoMoreInteractions(vacationRepository, notificationRegistry); } @Test @@ -232,7 +236,7 @@ public class SetVacationResponseMethodTest { .build()) .build(); assertThat(result).containsExactly(expected); - verifyNoMoreInteractions(vacationRepository); + verifyNoMoreInteractions(vacationRepository, notificationRegistry); } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org