package cz.moneta.test.regression.cvm.api.cvm;

import com.fasterxml.jackson.databind.JsonNode;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.DateUtils;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;

import java.util.UUID;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Call API SAS_RTDM_IB_REJ_APP to WSO2 and assert response parameters")
public class ApiSasRtdmIbRejApp {

    @TestCase(name = "Call API SAS_RTDM_IB_REJ_APP to WSO2", environments = {TST1, PPE})
    public void postSasRtdmIbRejApp(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "cvm.cluster/SAS_RTDM_IB_REJ_APP/1.0.0", false,
                "{\n" +
                        "    \"clientTimeZone\": \"Europe/Prague\",\n" +
                        "    \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                        "    \"version\": 1,\n" +
                        "    \"inputs\": {\n" +
                        "        \"applicationState\": \"10\",\n" +
                        "        \"applicationKey\": " + harness.getConfig("cvm.application.key") + ",\n" +
                        "        \"applicationLoanAmount\": 100000,\n" +
                        "        \"channelId\": \"IBS\",\n" +
                        "        \"clientCif\": \"" + harness.getConfig("cvm.client.cif") + "\",\n" +
                        "        \"eventTimeStamp\": \"" + DateUtils.getFormattedTodayDateTimeForWso2() + "\",\n" +
                        "        \"uniPtKey\": null,\n" +
                        "        \"birthNumber\": null,\n" +
                        "        \"productClass\": \"50\",\n" +
                        "        \"subtypeId\": \"\",\n" +
                        "        \"typeId\": \"Sc\"\n" +
                        "    }\n" +
                        "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

        harness.tasks().cvm().cvmWso2().assertResponseOutputs(outputs);

    }
}