private static TriggerStateMachine stateMachineForAfterProcessingTime(
      RunnerApi.Trigger.AfterProcessingTime trigger) {
    AfterDelayFromFirstElementStateMachine stateMachine =
        AfterProcessingTimeStateMachine.pastFirstElementInPane();
    for (RunnerApi.TimestampTransform transform : trigger.getTimestampTransformsList()) {
      switch (transform.getTimestampTransformCase()) {
        case ALIGN_TO:
          stateMachine =
              stateMachine.alignedTo(
                  Duration.millis(transform.getAlignTo().getPeriod()),
                  new Instant(transform.getAlignTo().getOffset()));
          break;
        case DELAY:
          stateMachine =
              stateMachine.plusDelayOf(Duration.millis(transform.getDelay().getDelayMillis()));
          break;
        case TIMESTAMPTRANSFORM_NOT_SET:
          throw new IllegalArgumentException(
              String.format("Required field 'timestamp_transform' not set in %s", transform));
        default:
          throw new IllegalArgumentException(
              String.format(
                  "Unknown timestamp transform case: %s", transform.getTimestampTransformCase()));
      }
    }
    return stateMachine;
  }
@Test
  public void testStateMachineForAfterProcessingTime() {
    Duration minutes = Duration.standardMinutes(94);
    Duration hours = Duration.standardHours(13);

    RunnerApi.Trigger trigger =
        RunnerApi.Trigger.newBuilder()
            .setAfterProcessingTime(
                RunnerApi.Trigger.AfterProcessingTime.newBuilder()
                    .addTimestampTransforms(
                        RunnerApi.TimestampTransform.newBuilder()
                            .setDelay(
                                RunnerApi.TimestampTransform.Delay.newBuilder()
                                    .setDelayMillis(minutes.getMillis())))
                    .addTimestampTransforms(
                        RunnerApi.TimestampTransform.newBuilder()
                            .setAlignTo(
                                RunnerApi.TimestampTransform.AlignTo.newBuilder()
                                    .setPeriod(hours.getMillis()))))
            .build();

    AfterDelayFromFirstElementStateMachine machine =
        (AfterDelayFromFirstElementStateMachine)
            TriggerStateMachines.stateMachineForTrigger(trigger);

    assertThat(machine.getTimeDomain(), equalTo(TimeDomain.PROCESSING_TIME));
  }