Repository: james-project
Updated Branches:
  refs/heads/master 8fcd6606c -> a17b49a64


JAMES-1778 Add isActivated attribute


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a17b49a6
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a17b49a6
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a17b49a6

Branch: refs/heads/master
Commit: a17b49a64df663fa18097438eb0e6cead4d8f6ef
Parents: 6a657fb
Author: Benoit Tellier <[email protected]>
Authored: Fri Jun 24 18:14:19 2016 +0700
Committer: Raphael Ouazana <[email protected]>
Committed: Wed Jul 20 10:38:59 2016 +0200

----------------------------------------------------------------------
 .../CassandraGetVacationResponseTest.java       |  6 +-
 .../integration/GetVacationResponseTest.java    | 69 +++++++++++++++-
 .../integration/SetVacationResponseTest.java    | 29 +++++++
 .../MemoryGetVacationResponseMethodTest.java    |  6 +-
 .../jmap/methods/GetVacationResponseMethod.java |  6 +-
 .../james/jmap/model/VacationResponse.java      | 29 ++++++-
 .../methods/GetVacationResponseMethodTest.java  | 84 +++++++++++++++++++-
 .../james/jmap/model/VacationResponseTest.java  |  1 +
 8 files changed, 218 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
index 1421a2e..66f1687 100644
--- 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
+++ 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraGetVacationResponseTest.java
@@ -25,6 +25,7 @@ import org.apache.james.backends.cassandra.EmbeddedCassandra;
 import org.apache.james.jmap.methods.integration.GetVacationResponseTest;
 import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
 import org.apache.james.modules.CassandraJmapServerModule;
+import org.apache.james.util.date.ZonedDateTimeProvider;
 import org.junit.Rule;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
@@ -41,10 +42,11 @@ public class CassandraGetVacationResponseTest extends 
GetVacationResponseTest {
         .around(embeddedElasticSearch);
 
     @Override
-    protected GuiceJamesServer createJmapServer() {
+    protected GuiceJamesServer createJmapServer(ZonedDateTimeProvider 
zonedDateTimeProvider) {
         return new GuiceJamesServer()
                     
.combineWith(CassandraJamesServerMain.cassandraServerModule)
-                    .overrideWith(new 
CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
+                    .overrideWith(new 
CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra),
+                        binder -> 
binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
index 8521b75..3b67695 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetVacationResponseTest.java
@@ -30,10 +30,12 @@ import java.time.ZonedDateTime;
 import java.util.Optional;
 
 import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.FixedDateZonedDateTimeProvider;
 import org.apache.james.jmap.JmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.api.vacation.AccountId;
 import org.apache.james.jmap.api.vacation.Vacation;
+import org.apache.james.util.date.ZonedDateTimeProvider;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -51,17 +53,24 @@ public abstract class GetVacationResponseTest {
     public static final String USER = "username@" + USERS_DOMAIN;
     public static final String PASSWORD = "password";
     public static final String SUBJECT = "subject";
+    public static final ZonedDateTime DATE_2015 = 
ZonedDateTime.parse("2015-10-15T14:10:00Z");
+    public static final ZonedDateTime DATE_2014 = 
ZonedDateTime.parse("2014-09-30T14:10:00+02:00");
+    public static final ZonedDateTime DATE_2016 = 
ZonedDateTime.parse("2016-04-15T11:56:32.224+07:00[Asia/Vientiane]");
 
-    protected abstract GuiceJamesServer createJmapServer();
+    protected abstract GuiceJamesServer createJmapServer(ZonedDateTimeProvider 
zonedDateTimeProvider);
 
     protected abstract void await();
 
     private AccessToken accessToken;
     private GuiceJamesServer jmapServer;
+    private FixedDateZonedDateTimeProvider fixedDateZonedDateTimeProvider;
 
     @Before
     public void setup() throws Throwable {
-        jmapServer = createJmapServer();
+        fixedDateZonedDateTimeProvider = new FixedDateZonedDateTimeProvider();
+        fixedDateZonedDateTimeProvider.setFixedDateTime(DATE_2015);
+
+        jmapServer = createJmapServer(fixedDateZonedDateTimeProvider);
         jmapServer.start();
 
         RestAssured.requestSpecification = new RequestSpecBuilder()
@@ -176,6 +185,62 @@ public abstract class GetVacationResponseTest {
     }
 
     @Test
+    public void getVacationResponseShouldReturnIsActivatedWhenInRange() {
+        jmapServer.serverProbe().modifyVacation(AccountId.fromString(USER),
+            Vacation.builder()
+                .enabled(true)
+                .fromDate(Optional.of(DATE_2014))
+                .toDate(Optional.of(DATE_2016))
+                .textBody("Test explaining my vacations")
+                .build());
+
+        given()
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", accessToken.serialize())
+            .body("[[" +
+                    "\"getVacationResponse\", " +
+                    "{}, " +
+                "\"#0\"" +
+                "]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("vacationResponse"))
+            .body(ARGUMENTS + ".list[0].isActivated", equalTo(true));
+    }
+
+    @Test
+    public void getVacationResponseShouldNotReturnIsActivatedWhenOutOfRange() {
+        fixedDateZonedDateTimeProvider.setFixedDateTime(DATE_2014);
+
+        jmapServer.serverProbe().modifyVacation(AccountId.fromString(USER),
+            Vacation.builder()
+                .enabled(true)
+                .fromDate(Optional.of(DATE_2015))
+                .toDate(Optional.of(DATE_2016))
+                .textBody("Test explaining my vacations")
+                .build());
+
+        given()
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", accessToken.serialize())
+            .body("[[" +
+                    "\"getVacationResponse\", " +
+                    "{}, " +
+                "\"#0\"" +
+                "]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("vacationResponse"))
+            .body(ARGUMENTS + ".list[0].isActivated", equalTo(false));
+    }
+
+    @Test
     public void accountIdIsNotSupported() {
         jmapServer.serverProbe().modifyVacation(AccountId.fromString(USER),
             Vacation.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
index 762a1ad..18414a6 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetVacationResponseTest.java
@@ -110,6 +110,35 @@ public abstract class SetVacationResponseTest {
     }
 
     @Test
+    public void setVacationResponseShouldBeAbleToContainIsActivated() {
+        String bodyRequest = "[[" +
+            "\"setVacationResponse\", " +
+                "{" +
+                    "\"update\":{" +
+                        "\"singleton\" : {" +
+                        "\"id\": \"singleton\"," +
+                        "\"isActivated\": \"true\"," +
+                        "\"isEnabled\": \"true\"," +
+                        "\"textBody\": \"Message explaining my wonderful 
vacations\"" +
+                    "}" +
+                "}" +
+            "}, " +
+            "\"#0\"" +
+            "]]";
+
+        given()
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", accessToken.serialize())
+            .body(bodyRequest)
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(ARGUMENTS + ".updated[0]", equalTo("singleton"));
+    }
+
+    @Test
     public void setVacationResponseShouldContainAnErrorWhenInvalidId() {
         String bodyRequest = "[[" +
             "\"setVacationResponse\", " +

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
index 69e0d2b..c2c3a92 100644
--- 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryGetVacationResponseMethodTest.java
@@ -23,6 +23,7 @@ import org.apache.james.GuiceJamesServer;
 import org.apache.james.MemoryJamesServerMain;
 import org.apache.james.jmap.methods.integration.GetVacationResponseTest;
 import org.apache.james.jmap.servers.MemoryJmapServerModule;
+import org.apache.james.util.date.ZonedDateTimeProvider;
 import org.junit.Rule;
 import org.junit.rules.TemporaryFolder;
 
@@ -32,10 +33,11 @@ public class MemoryGetVacationResponseMethodTest extends 
GetVacationResponseTest
     public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
     @Override
-    protected GuiceJamesServer createJmapServer() {
+    protected GuiceJamesServer createJmapServer(ZonedDateTimeProvider 
zonedDateTimeProvider) {
         return new GuiceJamesServer()
                     .combineWith(MemoryJamesServerMain.inMemoryServerModule)
-                    .overrideWith(new MemoryJmapServerModule(temporaryFolder));
+                    .overrideWith(new MemoryJmapServerModule(temporaryFolder),
+                        binder -> 
binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
index f5f8752..d2b86ad 100644
--- 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetVacationResponseMethod.java
@@ -31,6 +31,7 @@ import org.apache.james.jmap.model.GetVacationRequest;
 import org.apache.james.jmap.model.GetVacationResponse;
 import org.apache.james.jmap.model.VacationResponse;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.util.date.ZonedDateTimeProvider;
 
 import com.google.common.base.Preconditions;
 
@@ -40,10 +41,12 @@ public class GetVacationResponseMethod implements Method {
     public static final Response.Name RESPONSE_NAME = 
Response.name("vacationResponse");
 
     private final VacationRepository vacationRepository;
+    private final ZonedDateTimeProvider zonedDateTimeProvider;
 
     @Inject
-    public GetVacationResponseMethod(VacationRepository vacationRepository) {
+    public GetVacationResponseMethod(VacationRepository vacationRepository, 
ZonedDateTimeProvider zonedDateTimeProvider) {
         this.vacationRepository = vacationRepository;
+        this.zonedDateTimeProvider = zonedDateTimeProvider;
     }
 
     @Override
@@ -76,6 +79,7 @@ public class GetVacationResponseMethod implements Method {
             .accountId(mailboxSession.getUser().getUserName())
             .vacationResponse(VacationResponse.builder()
                 .fromVacation(vacation)
+                
.activated(vacation.isActiveAtDate(zonedDateTimeProvider.get()))
                 .build())
             .build();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/VacationResponse.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/VacationResponse.java
 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/VacationResponse.java
index 751dfa9..1c2d2df 100644
--- 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/VacationResponse.java
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/VacationResponse.java
@@ -52,6 +52,7 @@ public class VacationResponse {
         private Optional<String> subject = Optional.empty();
         private Optional<String> textBody = Optional.empty();
         private Optional<String> htmlBody = Optional.empty();
+        private Optional<Boolean> isActivated = Optional.empty();
 
         public Builder id(String id) {
             this.id = id;
@@ -64,6 +65,18 @@ public class VacationResponse {
             return this;
         }
 
+        @JsonProperty("isActivated")
+        public Builder activated(Optional<Boolean> activated) {
+            Preconditions.checkNotNull(activated);
+            this.isActivated = activated;
+            return this;
+        }
+
+        @JsonIgnore
+        public Builder activated(boolean activated) {
+            return activated(Optional.of(activated));
+        }
+
         @JsonDeserialize(using = OptionalZonedDateTimeDeserializer.class)
         public Builder fromDate(Optional<ZonedDateTime> fromDate) {
             Preconditions.checkNotNull(fromDate);
@@ -112,7 +125,7 @@ public class VacationResponse {
             if (enabled) {
                 Preconditions.checkState(textBody.isPresent() || 
htmlBody.isPresent(), "textBody or htmlBody property of vacationResponse object 
should not be null when enabled");
             }
-            return new VacationResponse(id, enabled, fromDate, toDate, 
textBody, subject, htmlBody);
+            return new VacationResponse(id, enabled, fromDate, toDate, 
textBody, subject, htmlBody, isActivated);
         }
     }
 
@@ -123,9 +136,10 @@ public class VacationResponse {
     private final Optional<String> subject;
     private final Optional<String> textBody;
     private final Optional<String> htmlBody;
+    private final Optional<Boolean> isActivated;
 
     private VacationResponse(String id, boolean isEnabled, 
Optional<ZonedDateTime> fromDate, Optional<ZonedDateTime> toDate,
-                             Optional<String> textBody, Optional<String> 
subject, Optional<String> htmlBody) {
+                             Optional<String> textBody, Optional<String> 
subject, Optional<String> htmlBody, Optional<Boolean> isActivated) {
         this.id = id;
         this.isEnabled = isEnabled;
         this.fromDate = fromDate;
@@ -133,6 +147,7 @@ public class VacationResponse {
         this.textBody = textBody;
         this.subject = subject;
         this.htmlBody = htmlBody;
+        this.isActivated = isActivated;
     }
 
     public String getId() {
@@ -171,6 +186,11 @@ public class VacationResponse {
         return id.equals(Vacation.ID);
     }
 
+    @JsonProperty("isActivated")
+    public Optional<Boolean> isActivated() {
+        return isActivated;
+    }
+
     @Override
     public boolean equals(Object o) {
         if (o == null || getClass() != o.getClass()) {
@@ -185,11 +205,12 @@ public class VacationResponse {
             && Objects.equals(this.toDate, that.toDate)
             && Objects.equals(this.textBody, that.textBody)
             && Objects.equals(this.subject, that.subject)
-            && Objects.equals(this.htmlBody, that.htmlBody);
+            && Objects.equals(this.htmlBody, that.htmlBody)
+            && Objects.equals(this.isActivated, that.isActivated);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(id, isEnabled, fromDate, toDate, textBody, 
subject, htmlBody);
+        return Objects.hash(id, isEnabled, fromDate, toDate, textBody, 
subject, htmlBody, isActivated);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetVacationResponseMethodTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetVacationResponseMethodTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetVacationResponseMethodTest.java
index 2bb3902..e7df6cf 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetVacationResponseMethodTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetVacationResponseMethodTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.time.ZonedDateTime;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import java.util.stream.Stream;
@@ -37,23 +38,32 @@ import org.apache.james.jmap.model.GetVacationResponse;
 import org.apache.james.jmap.model.SetMailboxesRequest;
 import org.apache.james.jmap.model.VacationResponse;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.util.date.ZonedDateTimeProvider;
 import org.junit.Before;
 import org.junit.Test;
 
 public class GetVacationResponseMethodTest {
 
+    private static final ZonedDateTime DATE_2014 = 
ZonedDateTime.parse("2014-09-30T14:10:00Z");
+    private static final ZonedDateTime DATE_2015 = 
ZonedDateTime.parse("2015-09-30T14:10:00Z");
+    private static final ZonedDateTime DATE_2016 = 
ZonedDateTime.parse("2016-09-30T14:10:00Z");
+
     public static final String USERNAME = "username";
     private GetVacationResponseMethod testee;
     private VacationRepository vacationRepository;
     private MailboxSession mailboxSession;
     private MailboxSession.User user;
+    private ZonedDateTimeProvider zonedDateTimeProvider;
 
     @Before
     public void setUp() {
+        zonedDateTimeProvider = mock(ZonedDateTimeProvider.class);
         vacationRepository = mock(VacationRepository.class);
         mailboxSession = mock(MailboxSession.class);
         user = mock(MailboxSession.User.class);
-        testee = new GetVacationResponseMethod(vacationRepository);
+        testee = new GetVacationResponseMethod(vacationRepository, 
zonedDateTimeProvider);
+
+        when(zonedDateTimeProvider.get()).thenReturn(DATE_2014);
     }
 
     @Test(expected = NullPointerException.class)
@@ -83,10 +93,81 @@ public class GetVacationResponseMethodTest {
             .enabled(true)
             .textBody("I am in vacation")
             .subject(Optional.of("subject"))
+            .fromDate(Optional.of(DATE_2014))
+            .toDate(Optional.of(DATE_2016))
+            .build();
+        
when(vacationRepository.retrieveVacation(AccountId.fromString(USERNAME))).thenReturn(CompletableFuture.completedFuture(vacation));
+        when(mailboxSession.getUser()).thenReturn(user);
+        when(user.getUserName()).thenReturn(USERNAME);
+        when(zonedDateTimeProvider.get()).thenReturn(DATE_2015);
+
+        GetVacationRequest getVacationRequest = 
GetVacationRequest.builder().build();
+
+        Stream<JmapResponse> result = testee.process(getVacationRequest, 
clientId, mailboxSession);
+
+        JmapResponse expected = JmapResponse.builder()
+            .clientId(clientId)
+            .responseName(GetVacationResponseMethod.RESPONSE_NAME)
+            .response(GetVacationResponse.builder()
+                .accountId(USERNAME)
+                .vacationResponse(VacationResponse.builder()
+                    .fromVacation(vacation)
+                    .activated(true)
+                    .build())
+                .build())
+            .build();
+        assertThat(result).containsExactly(expected);
+    }
+
+    @Test
+    public void processShouldReturnUnActivatedVacationResponseWhenBeforeDate() 
{
+        ClientId clientId = mock(ClientId.class);
+        Vacation vacation = Vacation.builder()
+            .enabled(true)
+            .textBody("I am in vacation")
+            .subject(Optional.of("subject"))
+            .fromDate(Optional.of(DATE_2015))
+            .toDate(Optional.of(DATE_2016))
+            .build();
+        
when(vacationRepository.retrieveVacation(AccountId.fromString(USERNAME))).thenReturn(CompletableFuture.completedFuture(vacation));
+        when(mailboxSession.getUser()).thenReturn(user);
+        when(user.getUserName()).thenReturn(USERNAME);
+        when(zonedDateTimeProvider.get()).thenReturn(DATE_2014);
+
+        GetVacationRequest getVacationRequest = 
GetVacationRequest.builder().build();
+
+        Stream<JmapResponse> result = testee.process(getVacationRequest, 
clientId, mailboxSession);
+
+        JmapResponse expected = JmapResponse.builder()
+            .clientId(clientId)
+            .responseName(GetVacationResponseMethod.RESPONSE_NAME)
+            .response(GetVacationResponse.builder()
+                .accountId(USERNAME)
+                .vacationResponse(VacationResponse.builder()
+                    .fromVacation(vacation)
+                    .activated(false)
+                    .build())
+                .build())
+            .build();
+        assertThat(result).containsExactly(expected);
+    }
+
+
+
+    @Test
+    public void processShouldReturnUnActivatedVacationResponseWhenAfterDate() {
+        ClientId clientId = mock(ClientId.class);
+        Vacation vacation = Vacation.builder()
+            .enabled(true)
+            .textBody("I am in vacation")
+            .subject(Optional.of("subject"))
+            .fromDate(Optional.of(DATE_2014))
+            .toDate(Optional.of(DATE_2015))
             .build();
         
when(vacationRepository.retrieveVacation(AccountId.fromString(USERNAME))).thenReturn(CompletableFuture.completedFuture(vacation));
         when(mailboxSession.getUser()).thenReturn(user);
         when(user.getUserName()).thenReturn(USERNAME);
+        when(zonedDateTimeProvider.get()).thenReturn(DATE_2016);
 
         GetVacationRequest getVacationRequest = 
GetVacationRequest.builder().build();
 
@@ -99,6 +180,7 @@ public class GetVacationResponseMethodTest {
                 .accountId(USERNAME)
                 .vacationResponse(VacationResponse.builder()
                     .fromVacation(vacation)
+                    .activated(false)
                     .build())
                 .build())
             .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/a17b49a6/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/VacationResponseTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/VacationResponseTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/VacationResponseTest.java
index 503acdf..779a812 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/VacationResponseTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/VacationResponseTest.java
@@ -25,6 +25,7 @@ import static 
org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.time.ZonedDateTime;
 import java.util.Optional;
 
+import org.apache.james.jmap.api.vacation.Vacation;
 import org.junit.Test;
 
 public class VacationResponseTest {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to