package cz.moneta.test.regression.backoffice.ufooperations.jenkinstests;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.task.ufo.operations.OperationsTasks;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.AfterEach;

import static cz.moneta.test.dsl.ufo.operations.ufoOperations.TRA740_S001_CreateNewTransferPaymentOrderPage.ID_PAYMENT_ORDER_KEY;
import static cz.moneta.test.dsl.util.task.ufo.cb.CommercialTasks.JIRA_COMMENT_STORE_KEY;

@TestScenario
public class CreatePaymentOrder {

    @TestCase(name = "Create Payment Order", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "BOC-T8317")
    public void createPaymentOrder(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        OperationsTasks operationsTasksTasks = harness.tasks().ufo().operations();
        String accountNumberPayer = harness.getConfig("ufo.operations.account-number");
        String accountNumberRecipient = harness.getConfig("ufo.operations.account-number-recipient");
        String amount = "100";

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasksTasks.login().withCredentialsAndSelectFirstOM(credentials))
                .then(operationsTasksTasks.paymentOrderTasks().createSimpleTransferPaymentOrder(accountNumberPayer, accountNumberRecipient, amount));

    }

    @AfterEach
    protected void teardown(Harness harness) {
        harness.store(JIRA_COMMENT_STORE_KEY,
                "\nUFO Session ID: " + harness.get("reports.tmfj.execution.commentufosessionid", true) +
                        "\nID Transakce: " + harness.get(ID_PAYMENT_ORDER_KEY, true));
    }

}
