Event implements Parcelable, Comparable<Event> { @Nullable public LocalDateTime getLocalEnd() { if (getEnd() == null) { return null; } return DateUtils.toLocalDateTime(getEnd()); } Event(); protected  Event(Parcel in); @Override void writeToParcel(Parcel dest, int flags); @Override int describeContents(); LocalDateTime getLocalStart(); @Nullable LocalDateTime getLocalEnd(); String getTitle(); OffsetDateTime getStart(); @Nullable OffsetDateTime getEnd(); String getLocation(); String getAddress(); boolean hasPreciseLocation(); boolean hasLocation(); String getDescription(); String getUrl(); boolean hasUrl(); String getAssociation(); String getIdentifier(); @Override int compareTo(Event o); @Override boolean equals(Object o); @Override int hashCode(); static final Creator<Event> CREATOR; }
@Test public void shouldReturnNull_whenEndIsNull() { Event event = Utils.generate(Event.class, "end"); assertNull(event.getLocalEnd()); }
@Test public void shouldReturnLocal_whenEndIsNotNull() { OffsetDateTime offsetDateTime = Utils.generate(OffsetDateTime.class); Event event = Utils.generate(Event.class, "end"); Utils.setField(event, "end", offsetDateTime); LocalDateTime localDateTime = event.getLocalEnd(); assertNotNull(localDateTime); assertEquals(DateUtils.toLocalDateTime(offsetDateTime), localDateTime); }