use of com.github.robozonky.app.portfolio.Delinquent in project robozonky by RoboZonky.
the class Delinquency method getOlderThan.
/**
* Returns all loans that are presently delinquent.
* @param days Minimum number of days a loan is in delinquency in order to be reported. 0 returns all delinquents.
* @return All loans that are delinquent for more than the given number of days.
*/
private SortedMap<Integer, LocalDate> getOlderThan(final int days) {
final ZoneId zone = Defaults.ZONE_ID;
final ZonedDateTime now = LocalDate.now().atStartOfDay(zone);
return source.get().flatMap(d -> d.getActiveDelinquency().map(Stream::of).orElse(Stream.empty())).filter(d -> d.getPaymentMissedDate().atStartOfDay(zone).plusDays(days).isBefore(now)).collect(Collectors.toMap(d -> d.getParent().getLoanId(), d -> d.getPaymentMissedDate(), (a, b) -> a, TreeMap::new));
}
use of com.github.robozonky.app.portfolio.Delinquent in project robozonky by RoboZonky.
the class DelinquencyTest method something.
@Test
void something() {
final Delinquent delinquent = new Delinquent(1, EPOCH.toLocalDate());
final Supplier<Stream<Delinquent>> supplier = () -> Stream.of(delinquent);
final Delinquency d = new Delinquency(supplier);
final int loanId = delinquent.getLoanId();
assertSoftly(softly -> {
softly.assertThat(d.getAll()).containsOnlyKeys(loanId);
softly.assertThat(d.get10Plus()).containsOnlyKeys(loanId);
softly.assertThat(d.get30Plus()).containsOnlyKeys(loanId);
softly.assertThat(d.get60Plus()).containsOnlyKeys(loanId);
softly.assertThat(d.get90Plus()).containsOnlyKeys(loanId);
});
}
Aggregations