You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2016/07/20 09:23:38 UTC
[1/2] james-project git commit: JAMES-1778 Add isActivated attribute
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 <bt...@linagora.com>
Authored: Fri Jun 24 18:14:19 2016 +0700
Committer: Raphael Ouazana <ra...@linagora.com>
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: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/2] james-project git commit: Revert "JAMES-1778 VacationResponse
should be marked as unactivated if outside of time range"
Posted by ro...@apache.org.
Revert "JAMES-1778 VacationResponse should be marked as unactivated if outside of time range"
This reverts commit 50e19442a8b3e7c16c2675b1486ee68ae1f03d0a.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6a657fb9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6a657fb9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6a657fb9
Branch: refs/heads/master
Commit: 6a657fb962441d0a62c349d1fe9a2e532744fd3a
Parents: 8fcd660
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Wed Jul 13 10:27:35 2016 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Wed Jul 20 10:38:59 2016 +0200
----------------------------------------------------------------------
.../CassandraGetVacationResponseTest.java | 6 +-
.../jmap/FixedDateZonedDateTimeProvider.java | 7 --
.../integration/GetVacationResponseTest.java | 7 +-
.../MemoryGetVacationResponseMethodTest.java | 6 +-
.../jmap/methods/GetVacationResponseMethod.java | 7 +-
.../james/jmap/model/VacationResponse.java | 9 +-
.../methods/GetVacationResponseMethodTest.java | 89 +-------------------
.../james/jmap/model/VacationResponseTest.java | 52 ------------
8 files changed, 12 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 66f1687..1421a2e 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,7 +25,6 @@ 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;
@@ -42,11 +41,10 @@ public class CassandraGetVacationResponseTest extends GetVacationResponseTest {
.around(embeddedElasticSearch);
@Override
- protected GuiceJamesServer createJmapServer(ZonedDateTimeProvider zonedDateTimeProvider) {
+ protected GuiceJamesServer createJmapServer() {
return new GuiceJamesServer()
.combineWith(CassandraJamesServerMain.cassandraServerModule)
- .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra),
- binder -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
+ .overrideWith(new CassandraJmapServerModule(temporaryFolder, embeddedElasticSearch, cassandra));
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
index b7dc00c..fd0c24c 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
@@ -27,13 +27,6 @@ public class FixedDateZonedDateTimeProvider implements ZonedDateTimeProvider {
private ZonedDateTime zonedDateTime;
- public FixedDateZonedDateTimeProvider() {
- }
-
- public FixedDateZonedDateTimeProvider(ZonedDateTime zonedDateTime) {
- this.zonedDateTime = zonedDateTime;
- }
-
public void setFixedDateTime(ZonedDateTime zonedDateTime) {
this.zonedDateTime = zonedDateTime;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 a9e7460..8521b75 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,12 +30,10 @@ 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;
@@ -47,7 +45,6 @@ import com.jayway.restassured.http.ContentType;
public abstract class GetVacationResponseTest {
- private static final ZonedDateTime ZONED_DATE_TIME_2014 = ZonedDateTime.parse("2014-10-15T14:10:00Z");
private static final String NAME = "[0][0]";
private static final String ARGUMENTS = "[0][1]";
private static final String USERS_DOMAIN = "domain.tld";
@@ -55,7 +52,7 @@ public abstract class GetVacationResponseTest {
public static final String PASSWORD = "password";
public static final String SUBJECT = "subject";
- protected abstract GuiceJamesServer createJmapServer(ZonedDateTimeProvider zonedDateTimeProvider);
+ protected abstract GuiceJamesServer createJmapServer();
protected abstract void await();
@@ -64,7 +61,7 @@ public abstract class GetVacationResponseTest {
@Before
public void setup() throws Throwable {
- jmapServer = createJmapServer(new FixedDateZonedDateTimeProvider(ZONED_DATE_TIME_2014));
+ jmapServer = createJmapServer();
jmapServer.start();
RestAssured.requestSpecification = new RequestSpecBuilder()
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 c2c3a92..69e0d2b 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,7 +23,6 @@ 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;
@@ -33,11 +32,10 @@ public class MemoryGetVacationResponseMethodTest extends GetVacationResponseTest
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Override
- protected GuiceJamesServer createJmapServer(ZonedDateTimeProvider zonedDateTimeProvider) {
+ protected GuiceJamesServer createJmapServer() {
return new GuiceJamesServer()
.combineWith(MemoryJamesServerMain.inMemoryServerModule)
- .overrideWith(new MemoryJmapServerModule(temporaryFolder),
- binder -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider));
+ .overrideWith(new MemoryJmapServerModule(temporaryFolder));
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 e50bc31..f5f8752 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,7 +31,6 @@ 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;
@@ -41,12 +40,10 @@ 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, ZonedDateTimeProvider zonedDateTimeProvider) {
+ public GetVacationResponseMethod(VacationRepository vacationRepository) {
this.vacationRepository = vacationRepository;
- this.zonedDateTimeProvider = zonedDateTimeProvider;
}
@Override
@@ -78,7 +75,7 @@ public class GetVacationResponseMethod implements Method {
return GetVacationResponse.builder()
.accountId(mailboxSession.getUser().getUserName())
.vacationResponse(VacationResponse.builder()
- .fromVacation(vacation, zonedDateTimeProvider.get())
+ .fromVacation(vacation)
.build())
.build();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 0a3a713..751dfa9 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
@@ -96,9 +96,9 @@ public class VacationResponse {
return this;
}
- public Builder fromVacation(Vacation vacation, ZonedDateTime zonedDateTime) {
+ public Builder fromVacation(Vacation vacation) {
this.id = Vacation.ID;
- this.isEnabled = computeEnabledState(vacation, zonedDateTime);
+ this.isEnabled = Optional.of(vacation.isEnabled());
this.fromDate = vacation.getFromDate();
this.toDate = vacation.getToDate();
this.textBody = vacation.getTextBody();
@@ -107,11 +107,6 @@ public class VacationResponse {
return this;
}
- private Optional<Boolean> computeEnabledState(Vacation vacation, ZonedDateTime zonedDateTime) {
- return Optional.of(vacation.isEnabled())
- .map(enabled -> enabled && vacation.isActiveAtDate(zonedDateTime));
- }
-
public VacationResponse build() {
boolean enabled = isEnabled.orElse(DEFAULT_DISABLED);
if (enabled) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 10f19e8..2bb3902 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,7 +23,6 @@ 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;
@@ -38,29 +37,23 @@ 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 {
public static final String USERNAME = "username";
- public static final ZonedDateTime ZONED_DATE_TIME_2014 = ZonedDateTime.parse("2014-09-30T14:10:00Z");
- public static final ZonedDateTime ZONED_DATE_TIME_2015 = ZonedDateTime.parse("2015-09-30T14:10:00Z");
- public static final ZonedDateTime ZONED_DATE_TIME_2016 = ZonedDateTime.parse("2016-09-30T14:10:00Z");
private GetVacationResponseMethod testee;
private VacationRepository vacationRepository;
private MailboxSession mailboxSession;
private MailboxSession.User user;
- private ZonedDateTimeProvider zonedDateTimeProvider;
@Before
public void setUp() {
vacationRepository = mock(VacationRepository.class);
mailboxSession = mock(MailboxSession.class);
user = mock(MailboxSession.User.class);
- zonedDateTimeProvider = mock(ZonedDateTimeProvider.class);
- testee = new GetVacationResponseMethod(vacationRepository, zonedDateTimeProvider);
+ testee = new GetVacationResponseMethod(vacationRepository);
}
@Test(expected = NullPointerException.class)
@@ -94,7 +87,6 @@ public class GetVacationResponseMethodTest {
when(vacationRepository.retrieveVacation(AccountId.fromString(USERNAME))).thenReturn(CompletableFuture.completedFuture(vacation));
when(mailboxSession.getUser()).thenReturn(user);
when(user.getUserName()).thenReturn(USERNAME);
- when(zonedDateTimeProvider.get()).thenReturn(ZONED_DATE_TIME_2015);
GetVacationRequest getVacationRequest = GetVacationRequest.builder().build();
@@ -106,84 +98,7 @@ public class GetVacationResponseMethodTest {
.response(GetVacationResponse.builder()
.accountId(USERNAME)
.vacationResponse(VacationResponse.builder()
- .id(Vacation.ID)
- .enabled(true)
- .textBody(Optional.of("I am in vacation"))
- .subject(Optional.of("subject"))
- .build())
- .build())
- .build();
- assertThat(result).containsExactly(expected);
- }
-
- @Test
- public void processShouldMarkOutDatedVacationAsUnactivated() {
- ClientId clientId = mock(ClientId.class);
- Vacation vacation = Vacation.builder()
- .enabled(true)
- .textBody("I am in vacation")
- .subject(Optional.of("subject"))
- .fromDate(Optional.of(ZONED_DATE_TIME_2014))
- .toDate(Optional.of(ZONED_DATE_TIME_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(ZONED_DATE_TIME_2016);
-
- 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()
- .enabled(false)
- .id(Vacation.ID)
- .textBody(Optional.of("I am in vacation"))
- .subject(Optional.of("subject"))
- .fromDate(Optional.of(ZONED_DATE_TIME_2014))
- .toDate(Optional.of(ZONED_DATE_TIME_2015))
- .build())
- .build())
- .build();
- assertThat(result).containsExactly(expected);
- }
-
- @Test
- public void processShouldMarkTooEarlyVacationAsUnactivated() {
- ClientId clientId = mock(ClientId.class);
- Vacation vacation = Vacation.builder()
- .enabled(true)
- .textBody("I am in vacation")
- .subject(Optional.of("subject"))
- .fromDate(Optional.of(ZONED_DATE_TIME_2015))
- .toDate(Optional.of(ZONED_DATE_TIME_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(ZONED_DATE_TIME_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()
- .enabled(false)
- .id(Vacation.ID)
- .textBody(Optional.of("I am in vacation"))
- .subject(Optional.of("subject"))
- .fromDate(Optional.of(ZONED_DATE_TIME_2015))
- .toDate(Optional.of(ZONED_DATE_TIME_2016))
+ .fromVacation(vacation)
.build())
.build())
.build();
http://git-wip-us.apache.org/repos/asf/james-project/blob/6a657fb9/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 d3aaeb9..503acdf 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,7 +25,6 @@ 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 {
@@ -36,9 +35,6 @@ public class VacationResponseTest {
public static final ZonedDateTime FROM_DATE = ZonedDateTime.parse("2016-04-15T11:56:32.224+07:00[Asia/Vientiane]");
public static final ZonedDateTime TO_DATE = ZonedDateTime.parse("2016-04-16T11:56:32.224+07:00[Asia/Vientiane]");
public static final String SUBJECT = "subject";
- public static final ZonedDateTime ZONED_DATE_TIME_2014 = ZonedDateTime.parse("2014-09-30T14:10:00Z");
- public static final ZonedDateTime ZONED_DATE_TIME_2015 = ZonedDateTime.parse("2015-09-30T14:10:00Z");
- public static final ZonedDateTime ZONED_DATE_TIME_2016 = ZonedDateTime.parse("2016-09-30T14:10:00Z");
@Test
public void vacationResponseBuilderShouldBeConstructedWithTheRightInformation() {
@@ -112,52 +108,4 @@ public class VacationResponseTest {
assertThat(vacationResponse.getHtmlBody()).contains(MESSAGE);
}
- @Test
- public void fromVacationShouldMarkOutDatedVacationAsDisabled() {
- VacationResponse vacationResponse = VacationResponse.builder()
- .fromVacation(
- Vacation.builder()
- .enabled(true)
- .textBody("Any text")
- .fromDate(Optional.of(ZONED_DATE_TIME_2014))
- .toDate(Optional.of(ZONED_DATE_TIME_2015))
- .build(),
- ZONED_DATE_TIME_2016)
- .build();
-
- assertThat(vacationResponse.isEnabled()).isFalse();
- }
-
- @Test
- public void fromVacationShouldMarkTooEarlyVacationAsDisabled() {
- VacationResponse vacationResponse = VacationResponse.builder()
- .fromVacation(
- Vacation.builder()
- .enabled(true)
- .textBody("Any text")
- .fromDate(Optional.of(ZONED_DATE_TIME_2015))
- .toDate(Optional.of(ZONED_DATE_TIME_2016))
- .build(),
- ZONED_DATE_TIME_2014)
- .build();
-
- assertThat(vacationResponse.isEnabled()).isFalse();
- }
-
- @Test
- public void fromVacationShouldMarkInRangeVacationAsEnabled() {
- VacationResponse vacationResponse = VacationResponse.builder()
- .fromVacation(
- Vacation.builder()
- .enabled(true)
- .textBody("Any text")
- .fromDate(Optional.of(ZONED_DATE_TIME_2014))
- .toDate(Optional.of(ZONED_DATE_TIME_2016))
- .build(),
- ZONED_DATE_TIME_2015)
- .build();
-
- assertThat(vacationResponse.isEnabled()).isTrue();
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org