Example usage for java.time LocalDate plusDays

List of usage examples for java.time LocalDate plusDays

Introduction

In this page you can find the example usage for java.time LocalDate plusDays.

Prototype

public LocalDate plusDays(long daysToAdd) 

Source Link

Document

Returns a copy of this LocalDate with the specified number of days added.

Usage

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldReturnSkipMessagesWhenPositionAndLimitGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(2)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();//from ww  w . j a v a  2 s  . c o  m

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"position\":1, \"limit\":1, \"sort\":[\"date desc\"]}, \"#0\"]]")
            .when().post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message2.getMessageId().serialize()));
}

From source file:cz.muni.fi.pv168.project.hotelmanager.TestReservationManagerImpl.java

@Test
public void TestGetCostForReservation() {
    LocalDate checkin = LocalDate.of(2016, 8, 7);
    LocalDate checkout = LocalDate.of(2016, 8, 11);
    LocalDate reservationdate = LocalDate.now(prepareClockMock(now));

    Room room1 = setRoom(101, 2, 125, true);
    Room room2 = setRoom(102, 3, 250, false);
    roomManager.createRoom(room1);//from  www .  j av  a  2s . c  o  m
    roomManager.createRoom(room2);

    Guest guest1 = setGuest("Oleg Bezpalko", "Zagorska", "75899654", "Oleg999@mail");
    Guest guest2 = setGuest("Bogdan Voedylo", "Sobranetska", "78965452", "Myro777@mail");
    guestManager.createGuest(guest1);
    guestManager.createGuest(guest2);

    Reservation r1 = setReservation(room1.getId(), guest1.getId(), checkin, checkout, reservationdate);
    Reservation r2 = setReservation(room2.getId(), guest2.getId(), checkin.plusDays(1), checkout.plusDays(2),
            reservationdate);

    reservationManager.createReservation(r1);
    reservationManager.createReservation(r2);

    assertThat("reservation 1 resturns wrong total price",
            reservationManager.getCoastForReservation(r1.getGuestId()), is(equalTo(5 * 125)));
    assertThat("reservation 2 returns wrong total price",
            reservationManager.getCoastForReservation(r2.getGuestId()), is(equalTo(6 * 250)));
    assertThat("with no reservation price differs from 0", reservationManager.getCoastForReservation(3L),
            is(equalTo(0)));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldReturnLimitMessagesWhenLimitGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();// w  w w .  j a  v  a2  s  .co m

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"limit\":1}, \"#0\"]]").when().post("/jmap").then().statusCode(200)
            .body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", contains(message.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldChainFetchingMessagesWhenAskedFor() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    await();//from w  ww . j  av a  2 s.  c om

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"fetchMessages\":true}, \"#0\"]]").when().post("/jmap").then()
            .statusCode(200).body("[0][0]", equalTo("messageList")).body("[1][0]", equalTo("messages"))
            .body("[0][1].messageIds", hasSize(1))
            .body("[0][1].messageIds[0]", equalTo(message.getMessageId().serialize()))
            .body("[1][1].list", hasSize(1))
            .body("[1][1].list[0].id", equalTo(message.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldSortMessagesWhenSortedByDateDefault() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*  w  w w.  j  a  va 2 s . c  o  m*/

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"sort\":[\"date\"]}, \"#0\"]]").when().post("/jmap").then()
            .statusCode(200).body(NAME, equalTo("messageList")).body(ARGUMENTS + ".messageIds",
                    contains(message1.getMessageId().serialize(), message2.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldSortMessagesWhenSortedByDateAsc() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from  w ww. j  a va  2  s.  co  m*/

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"sort\":[\"date asc\"]}, \"#0\"]]").when().post("/jmap").then()
            .statusCode(200).body(NAME, equalTo("messageList")).body(ARGUMENTS + ".messageIds",
                    contains(message2.getMessageId().serialize(), message1.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldSortMessagesWhenSortedByDateDesc() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from  w  ww.  j a  v a2s  . co  m*/

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"sort\":[\"date desc\"]}, \"#0\"]]").when().post("/jmap").then()
            .statusCode(200).body(NAME, equalTo("messageList")).body(ARGUMENTS + ".messageIds",
                    contains(message1.getMessageId().serialize(), message2.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldReturnAllMessagesWhenPositionIsNotGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();//from   w w w.  j a v a 2s . co  m

    given().header("Authorization", accessToken.serialize()).body("[[\"getMessageList\", {}, \"#0\"]]").when()
            .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(),
                    message2.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldReturnAllMessagesWhenLimitIsNotGiven() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();/*from w w w.j a v a  2s. c  o m*/

    given().header("Authorization", accessToken.serialize()).body("[[\"getMessageList\", {}, \"#0\"]]").when()
            .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(),
                    message2.getMessageId().serialize()));
}

From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java

@Test
public void getMessageListShouldSupportIdSorting() throws Exception {
    mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox");

    LocalDate date = LocalDate.now();
    ComposedMessageId message1 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()),
            convertToDate(date.plusDays(1)), false, new Flags());
    ComposedMessageId message2 = mailboxProbe.appendMessage(username,
            new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
            new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false,
            new Flags());
    await();//from   w w  w. j a  va  2  s  .  c o m

    given().header("Authorization", accessToken.serialize())
            .body("[[\"getMessageList\", {\"sort\":[\"id\"]}, \"#0\"]]").when().post("/jmap").then()
            .statusCode(200).body(NAME, equalTo("messageList"))
            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message2.getMessageId().serialize(),
                    message1.getMessageId().serialize()));
}