test_class.file: server/src/test/java/io/spine/server/delivery/CleanupStationTest.java
test_class.identifier: CleanupStationTest
test_class.superclass: extends AbstractStationTest
test_case.body: @Test
      @DisplayName("keep the messages in `DELIVERED` status if they have `keep_until` in future" +
              "and remove `DELIVERED` messages if their `keep_until` is in the past")
      void considerKeepUntilWhenRemoving() {
          InboxMessage deliveredKeepTillFuture = keepUntil(
                  delivered(targetOne, type), add(currentTime(), fromSeconds(10))
          );
          InboxMessage deliveredKeepUntilPastTime = keepUntil(
                  delivered(targetTwo, type), subtract(currentTime(), fromSeconds(5))
          );
          Conveyor conveyor = new Conveyor(
                  ImmutableList.of(deliveredKeepTillFuture, deliveredKeepUntilPastTime),
                  new DeliveredMessages()
          );
  
          Station station = new CleanupStation();
          Station.Result result = station.process(conveyor);
          assertDeliveredCount(result, 0);
  
          assertContainsExactly(conveyor.removals(),
                                // expected:
                                deliveredKeepUntilPastTime);
  
          assertContainsExactly(conveyor.iterator(),
                                // expected:
                                deliveredKeepTillFuture);
      }
test_case.class_method_signature: CleanupStationTest.considerKeepUntilWhenRemoving()
test_case.full_signature: @Test @DisplayName("keep the messages in `DELIVERED` status if they have `keep_until` in future" + "and remove `DELIVERED` messages if their `keep_until` is in the past") void considerKeepUntilWhenRemoving()
test_case.identifier: considerKeepUntilWhenRemoving
test_case.invocations: keepUntil delivered add currentTime fromSeconds keepUntil delivered subtract currentTime fromSeconds of process assertDeliveredCount assertContainsExactly removals assertContainsExactly iterator
test_case.modifiers: @Test @DisplayName("keep the messages in `DELIVERED` status if they have `keep_until` in future" + "and remove `DELIVERED` messages if their `keep_until` is in the past")
test_case.parameters: ()
test_case.return: void
test_case.signature: void considerKeepUntilWhenRemoving()
focal_class.declarator: NO_ERRORS = DeliveryErrors.newBuilder()
                                                                    .build()
focal_class.modifier: private static final
focal_class.original_string: private static final DeliveryErrors NO_ERRORS = DeliveryErrors.newBuilder()
                                                                    .build();
focal_class.type: DeliveryErrors
focal_class.var_name: NO_ERRORS
focal_class.declarator: NOTHING_DELIVERED = new Result(0, NO_ERRORS)
focal_class.modifier: private static final
focal_class.original_string: private static final Result NOTHING_DELIVERED = new Result(0, NO_ERRORS);
focal_class.type: Result
focal_class.var_name: NOTHING_DELIVERED
focal_class.file: server/src/main/java/io/spine/server/delivery/CleanupStation.java
focal_class.identifier: CleanupStation
focal_class.class_method_signature: CleanupStation.process(Conveyor conveyor)
focal_class.full_signature: @Override public final Result process(Conveyor conveyor)
focal_class.identifier: process
focal_class.modifiers: @Override public final
focal_class.parameters: (Conveyor conveyor)
focal_class.return: Result
focal_class.signature: Result process(Conveyor conveyor)
focal_class.class_method_signature: CleanupStation.isInPast(Timestamp keepUntil)
focal_class.full_signature: private static boolean isInPast(Timestamp keepUntil)
focal_class.identifier: isInPast
focal_class.modifiers: private static
focal_class.parameters: (Timestamp keepUntil)
focal_class.return: boolean
focal_class.signature: boolean isInPast(Timestamp keepUntil)
focal_class.superclass: extends Station
focal_method.body: @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;
      }
focal_method.class_method_signature: CleanupStation.process(Conveyor conveyor)
focal_method.full_signature: @Override public final Result process(Conveyor conveyor)
focal_method.identifier: process
focal_method.invocations: getStatus getKeepUntil equals getDefaultInstance isInPast remove
focal_method.modifiers: @Override public final
focal_method.parameters: (Conveyor conveyor)
focal_method.return: Result
focal_method.signature: Result process(Conveyor conveyor)