package cz.moneta.test.dsl.ib.utils;

import cz.moneta.test.dsl.Harness;
import org.junit.Assert;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class IbUtils {
    private static final String DATE_FORMAT = "dd.MM.yyyy HH:mm:ss";

    public static void verifyTransactionStatus(Harness harness, LocalDateTime testExecutionStartTime, String clientID, String operId, Integer secondsToWait) {
        LocalDateTime plusFiveMinutesDateTime = testExecutionStartTime.plusMinutes(5);
        String fromDateTime = DateTimeFormatter.ofPattern(DATE_FORMAT).format(testExecutionStartTime);
        String toDateTime = DateTimeFormatter.ofPattern(DATE_FORMAT).format(plusFiveMinutesDateTime);
        String transactionStatus = harness.withUdebs()
                .transactionsClient()
                .getLastTransactionStatus(clientID, operId, "15", fromDateTime, toDateTime, secondsToWait, "60");

        Assert.assertEquals("Verify that transaction with operID: " + operId + " is in the correct statusID", "60", transactionStatus);
    }
}