List of usage examples for java.time LocalDate now
public static LocalDate now()
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();// w ww. j a v a 2 s .com 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())); }
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();// ww w . ja v a 2 s . 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 ww w . j a v a2 s. c om 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 getMessageListShouldReturnSkipMessagesWhenPositionIsGiven() 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(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 v a 2 s . c om*/ given().header("Authorization", accessToken.serialize()) .body("[[\"getMessageList\", {\"position\":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: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();// w ww . j ava 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:org.efaps.esjp.common.uiform.Field_Base.java
/** * @param _parameter Parameter as passed from the eFaps API * @return Return containing Html Snipplet * @throws EFapsException on error//from w w w . j a v a 2s .com */ public Return getOptionList4DateTime(final Parameter _parameter) throws EFapsException { final List<DropDownPosition> positions = new ArrayList<>(); final String dateFieldType = getProperty(_parameter, "DateFieldType", "YEAR"); switch (dateFieldType) { case "MONTH": for (final Month month : Month.values()) { final DropDownPosition pos = getDropDownPosition(_parameter, month.getValue(), month.getDisplayName(TextStyle.FULL, Context.getThreadContext().getLocale())); pos.setSelected(month.getValue() == new DateTime().getMonthOfYear()); positions.add(pos); } break; case "YEAR": default: final String fromStr = getProperty(_parameter, "From", "-10"); final String toStr = getProperty(_parameter, "To", "+10"); LocalDate start; if (StringUtils.isNumeric(fromStr)) { start = LocalDate.of(Integer.parseInt(fromStr), 1, 1); } else { start = LocalDate.now().plusYears(Integer.parseInt(fromStr)); } final LocalDate end; if (StringUtils.isNumeric(toStr)) { end = LocalDate.of(Integer.parseInt(toStr), 1, 1); } else { end = LocalDate.now().plusYears(Integer.parseInt(toStr)); } while (start.isBefore(end)) { final DropDownPosition pos = getDropDownPosition(_parameter, start.getYear(), start.getYear()); pos.setSelected(start.getYear() == new DateTime().getYear()); positions.add(pos); start = start.plusYears(1); } break; } final Return ret = new Return(); ret.put(ReturnValues.VALUES, positions); return ret; }
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();/* www . j a va 2 s. 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 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();//from w w w .j a va2s . c om 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 getMessageListShouldReturnLimitMessagesWithDefaultValueWhenLimitIsNotGiven() 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()); ComposedMessageId message3 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags()); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test4\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\", {}, \"#0\"]]").when() .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(), message2.getMessageId().serialize(), message3.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 w w . ja v a 2 s .com*/ 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())); }