@Test public void jmapVacationShouldSendNotificationTwiceWhenVacationReset() throws Exception { /* Test scenario : - User 1 benw@mydomain.tld sets a Vacation on its account - User 2 matthieu@mydomain.tld sends User 1 a mail - User 2 matthieu@mydomain.tld sends User 1 a second mail - User 1 should well receive this mail - User 2 should well receive only one notification about user 1 vacation */ // Given AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD); AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD); // User 1 benw@mydomain.tld sets a Vacation on its account setVacationResponse(user1AccessToken); // User 2 matthieu@mydomain.tld sends User 1 a mail String user2OutboxId = getOutboxId(user2AccessToken); sendMail(user2AccessToken, user2OutboxId, "user|inbox|1"); // Wait user 1 to receive the eMail before reset of vacation calmlyAwait.atMost(30, TimeUnit.SECONDS) .until(() -> isTextMessageReceived(user1AccessToken, getInboxId(user1AccessToken), ORIGINAL_MESSAGE_TEXT_BODY, USER_2, USER_1)); // When // User 1 benw@mydomain.tld resets a Vacation on its account setVacationResponse(user1AccessToken); // User 2 matthieu@mydomain.tld sends User 1 a mail sendMail(user2AccessToken, user2OutboxId, "user|inbox|2"); // Then // User 2 should well receive two notification about user 1 vacation calmlyAwait.atMost(30, TimeUnit.SECONDS) .until(() -> areTwoTextMessageReceived(user2AccessToken, getInboxId(user2AccessToken))); }
@Test public void jmapVacationShouldNotSendNotificationTwice() throws Exception { /* Test scenario : - User 1 benw@mydomain.tld sets a Vacation on its account - User 2 matthieu@mydomain.tld sends User 1 a mail - User 2 matthieu@mydomain.tld sends User 1 a second mail - User 1 should well receive this mail - User 2 should well receive only one notification about user 1 vacation */ // Given AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD); AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD); // User 1 benw@mydomain.tld sets a Vacation on its account setVacationResponse(user1AccessToken); // When // User 2 matthieu@mydomain.tld sends User 1 a mail String user2OutboxId = getOutboxId(user2AccessToken); sendMail(user2AccessToken, user2OutboxId, "user|inbox|1"); sendMail(user2AccessToken, user2OutboxId, "user|inbox|2"); // Then // User 2 should well receive a notification about user 1 vacation calmlyAwait.atMost(30, TimeUnit.SECONDS) .until(() -> isTextMessageReceived(user2AccessToken, getInboxId(user2AccessToken), REASON, USER_1, USER_2)); // User 2 should not receive another notification Thread.sleep(1000L); assertOneMessageReceived(user2AccessToken, getInboxId(user2AccessToken), REASON, USER_1, USER_2); }
@Test public void jmapVacationShouldGenerateAReplyWhenActive() throws Exception { /* Test scenario : - User 1 benw@mydomain.tld sets a Vacation on its account - User 2 matthieu@mydomain.tld sends User 1 a mail - User 1 should well receive this mail - User 2 should well receive a notification about user 1 vacation */ // Given AccessToken user1AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_1, PASSWORD); AccessToken user2AccessToken = authenticateJamesUser(baseUri(guiceJamesServer), USER_2, PASSWORD); // User 1 benw@mydomain.tld sets a Vacation on its account setVacationResponse(user1AccessToken); // When // User 2 matthieu@mydomain.tld sends User 1 a mail String user2OutboxId = getOutboxId(user2AccessToken); sendMail(user2AccessToken, user2OutboxId, "user|inbox|1"); // Then // User 1 should well receive this mail calmlyAwait.atMost(30, TimeUnit.SECONDS) .until(() -> isTextMessageReceived(user1AccessToken, getInboxId(user1AccessToken), ORIGINAL_MESSAGE_TEXT_BODY, USER_2, USER_1)); // User 2 should well receive a notification about user 1 vacation calmlyAwait.atMost(30, TimeUnit.SECONDS) .until(() -> isTextMessageReceived(user2AccessToken, getInboxId(user2AccessToken), REASON, USER_1, USER_2)); }