package io.delphi.qa.auto.awsmfrw.managers.helpers.aws;

import com.amazonaws.services.stepfunctions.model.HistoryEvent;
import io.delphi.qa.auto.awsmfrw.managers.helpers.common.IsaAssertions;
import io.delphi.qa.auto.awsmfrw.models.aws.lm.RsAwsLambda;

import java.util.List;
import java.util.stream.Collectors;

public class HlAwsSfAssertions implements IsaAssertions {

  public void assertStateMachineStepsSize(
      RsAwsLambda rsAwsLambda, List<HistoryEvent> historyEventList, int expectedBaseLine) {
    isaAssertTrue(
        historyEventList.size() >= expectedBaseLine,
        String.format(
            "\n- assert status: failed\n- state_machine name: %s\n-type: %s\n",
            rsAwsLambda.getMeta().getSfNames().get(0),
            historyEventList.stream()
                .map(HistoryEvent::getType)
                .filter(o -> o.toLowerCase().endsWith("failed"))
                .collect(Collectors.toList())));
  }
}
