MultiDataWriter implements DataWriter<T> { @Override public Future<Boolean> isOutOfDate() { return comparators.map(c -> c.isOutOfDate()) .foldLeft((acc, next) -> acc.zip(next, (v1, v2) -> v1 || v2)) .orElse(Future.ofResult(false)); }  @Override Future<T> loadAndGet(); @Override Future<Void> saveAndIncrement(T data); @Override Future<Boolean> isOutOfDate();  }
@Test public void isOutOfDateReturnsFalseIfSecondOnlyIsFalse() { dataWriter1.setOutofdate(true); dataWriter2.setOutofdate(false); boolean outofdate = writer.isOutOfDate() .orElse(null); assertThat(outofdate, equalTo(true)); }
@Test public void isOutOfDateReturnsFalseIfFirstOnlyIsFalse() { dataWriter1.setOutofdate(false); dataWriter2.setOutofdate(true); boolean outofdate = writer.isOutOfDate() .orElse(null); assertThat(outofdate, equalTo(true)); }
@Test public void isOutOfDateReturnsFalseIfBothAreFalse() { dataWriter1.setOutofdate(false); dataWriter2.setOutofdate(false); boolean outofdate = writer.isOutOfDate() .orElse(null); assertThat(outofdate, equalTo(false)); }
@Test public void isOutOfDateReturnsTrueIfBothAreTrue() { dataWriter1.setOutofdate(true); dataWriter2.setOutofdate(true); boolean outofdate = writer.isOutOfDate() .orElse(null); assertThat(outofdate, equalTo(true)); }
@Test public void isOutofDateWorksEmpty() { boolean outofdate = empty.isOutOfDate() .orElse(null); assertThat(outofdate, equalTo(false)); }