@Test
void triggersEventsOnNewDelinquents() {

    final Investment i1 = getDelinquentInvestment(1);
    when(zonky.getInvestment(eq(i1.getId()))).thenReturn(i1);
    final Investment i10 = getDelinquentInvestment(10);
    when(zonky.getInvestment(eq(i10.getId()))).thenReturn(i10);
    final Investment i30 = getDelinquentInvestment(30);
    when(zonky.getInvestment(eq(i30.getId()))).thenReturn(i30);
    final Investment i60 = getDelinquentInvestment(60);
    when(zonky.getInvestment(eq(i60.getId()))).thenReturn(i60);
    final Investment i90 = getDelinquentInvestment(90);
    when(zonky.getInvestment(eq(i90.getId()))).thenReturn(i90);
    final Investment defaulted = getDefaultedInvestment();
    when(zonky.getInvestment(eq(defaulted.getId()))).thenReturn(defaulted);
    when(zonky.getDelinquentInvestments()).thenReturn(Stream.of(i1));
    // run test
    payload.accept(tenant); // nothing will happen here, as this is the initializing run
    when(zonky.getDelinquentInvestments()).thenReturn(Stream.of(i10, i30, i60, i90, defaulted));
    final Loan fresh = MockLoanBuilder.fresh();
    when(zonky.getLoan(anyInt())).thenReturn(fresh);
    payload.accept(tenant); // the new delinquencies will show up now
    assertThat(getEventsRequested())
        .extracting(e -> (Object) e.getClass()
            .getInterfaces()[0])
        .containsOnly(LoanNoLongerDelinquentEvent.class, LoanDefaultedEvent.class,
                LoanDelinquent10DaysOrMoreEvent.class, LoanDelinquent30DaysOrMoreEvent.class,
                LoanDelinquent60DaysOrMoreEvent.class, LoanDelinquent90DaysOrMoreEvent.class);
}