@Test @DisplayName("remove the messages in `DELIVERED` status") void removeDeliveredMessages() { InboxMessage delivered = delivered(targetOne, type); InboxMessage deliveredToAnotherTarget = delivered(targetTwo, type); InboxMessage catchingUp = catchingUp(targetTwo, type); InboxMessage toDeliver = toDeliver(targetOne, type); Conveyor conveyor = new Conveyor( ImmutableList.of(delivered, deliveredToAnotherTarget, catchingUp, toDeliver), new DeliveredMessages() ); Station station = new CleanupStation(); Station.Result result = station.process(conveyor); assertDeliveredCount(result, 0); assertContainsExactly(conveyor.removals(), delivered, deliveredToAnotherTarget); assertContainsExactly(conveyor.iterator(), catchingUp, toDeliver); }
@Override public final Result process(Conveyor conveyor) { for (InboxMessage message : conveyor) { if (message.getStatus() == InboxMessageStatus.DELIVERED) { Timestamp keepUntil = message.getKeepUntil(); if (keepUntil.equals(Timestamp.getDefaultInstance()) || isInPast(keepUntil)) { conveyor.remove(message); } } } return NOTHING_DELIVERED; }
CleanupStation extends Station { @Override public final Result process(Conveyor conveyor) { for (InboxMessage message : conveyor) { if (message.getStatus() == InboxMessageStatus.DELIVERED) { Timestamp keepUntil = message.getKeepUntil(); if (keepUntil.equals(Timestamp.getDefaultInstance()) || isInPast(keepUntil)) { conveyor.remove(message); } } } return NOTHING_DELIVERED; } }
CleanupStation extends Station { @Override public final Result process(Conveyor conveyor) { for (InboxMessage message : conveyor) { if (message.getStatus() == InboxMessageStatus.DELIVERED) { Timestamp keepUntil = message.getKeepUntil(); if (keepUntil.equals(Timestamp.getDefaultInstance()) || isInPast(keepUntil)) { conveyor.remove(message); } } } return NOTHING_DELIVERED; }  }
CleanupStation extends Station { @Override public final Result process(Conveyor conveyor) { for (InboxMessage message : conveyor) { if (message.getStatus() == InboxMessageStatus.DELIVERED) { Timestamp keepUntil = message.getKeepUntil(); if (keepUntil.equals(Timestamp.getDefaultInstance()) || isInPast(keepUntil)) { conveyor.remove(message); } } } return NOTHING_DELIVERED; }  @Override final Result process(Conveyor conveyor); }
CleanupStation extends Station { @Override public final Result process(Conveyor conveyor) { for (InboxMessage message : conveyor) { if (message.getStatus() == InboxMessageStatus.DELIVERED) { Timestamp keepUntil = message.getKeepUntil(); if (keepUntil.equals(Timestamp.getDefaultInstance()) || isInPast(keepUntil)) { conveyor.remove(message); } } } return NOTHING_DELIVERED; }  @Override final Result process(Conveyor conveyor);  }