package cz.moneta.test.regression.backoffice.exevido.api;

import com.fasterxml.jackson.databind.node.ObjectNode;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenarioWithOrder;
import cz.moneta.test.harness.support.rest.RawRestRequest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Order;

import static cz.moneta.test.dsl.util.task.ufo.cb.CommercialTasks.JIRA_COMMENT_STORE_KEY;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenarioWithOrder(name = "Api Exevido")
public class ApiExevido {
    ObjectNode objectNode;
    String inputData;

    @Order(1)
    @TestCase(name = "GET_REQSTRS_EXEBINF_001", environments = {TST1})
    @JiraTestCase(id = "BOC-T8759")
    public void GET_REQSTRS_EXEBINF_001(Harness harness) {
        RawRestRequest.Response response = harness.tasks().wso2().restRequest().prepareRequestFromUfo("/t/backoffice.cluster/GET_REQSTRS_EXEBINF_001/001")
                .withPayload("{ICO : 25515560}")
                .post();
        inputData = response.getPayload();
        objectNode = response
                .andAssertStatus(200)
                .mapResponseIntoObject(ObjectNode.class);
    }

    @Order(2)
    @TestCase(name = "GET_EXE_LIV_MIN_EXE", environments = {TST1})
    @JiraTestCase(id = "BOC-T8760")
    public void GET_EXE_LIV_MIN_EXE(Harness harness) {
        RawRestRequest.Response response = harness.tasks().wso2().restRequest().prepareRequestFromUfo("/t/backoffice.cluster/EXEVIDO/GET_EXE_LIV_MIN_EXE/001")
                .withPayload("{\n" + "\"INBANK\": 1,\n" + "\"INTYP\": 6,\n" + "\"INACCT\": 163374090\n" + "} ")
                .post();
        inputData = response.getPayload();
        objectNode = response
                .andAssertStatus(200)
                .mapResponseIntoObject(ObjectNode.class);
    }

    @AfterEach
    protected void teardown(Harness harness) {
        harness.store(JIRA_COMMENT_STORE_KEY,
                "\nVstup: \n" + inputData + "\nVýstup: \n " + objectNode.toPrettyString());

    }
}

