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 org.junit.jupiter.api.Disabled;

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 ib-udc-calc-trigger to WSO2 and assert response parameters")
public class ApiIbUdcCalcTrigger {

    @TestCase(name = "Call API ib-udc-calc-trigger to WSO2", environments = {TST1, PPE})
    @Disabled
    public void postIbUdcCalcTrigger(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "cvm.cluster/ib-udc-calc-trigger/1.0.0", false,
                "{\n" +
                        "    \"version\": 1,\n" +
                        "    \"clientTimeZone\": \"Europe/Prague\",\n" +
                        "    \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                        "    \"inputs\": {\n" +
                        "        \"clientCif\": \"" + harness.getConfig("cvm.client.cif") + "\",\n" +
                        "        \"userId\": " + harness.getConfig("cvm.client.userid") + ",\n" +
                        "        \"channelId\": \"IB\",\n" +
                        "        \"eventTimeStamp\": \"" + DateUtils.getFormattedTodayDateTimeForWso2() + "\",\n" +
                        "        \"consolidationTotalLoanAmount\": 456.45,\n" +
                        "        \"consolidationInstalment\": 21.36,\n" +
                        "        \"consolidationInstalmentLength\": 24,\n" +
                        "        \"consolidationRpsn\": 7.99,\n" +
                        "        \"financialObligationAmounts\": [\n" +
                        "            1235\n" +
                        "        ],\n" +
                        "        \"financialObligationTypes\": [\n" +
                        "            \"CREDIT_CARD\"\n" +
                        "        ],\n" +
                        "        \"formLastStepPage\": \"step1\"\n" +
                        "    }\n" +
                        "}\n" +
                        "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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

