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

import com.fasterxml.jackson.databind.JsonNode;
import cz.moneta.test.dsl.Harness;
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 web-mortgages-retention-trigger to WSO2 and assert response parameters")
public class ApiWebMortgagesRetentionTrigger {

    public static final String WEB_MORTGAGES_RETENTION_TRIGGER_PATH = "cvm.cluster/web-mortgages-retention-trigger/1.0.0";

    @TestCase(name = "Call API web-mortgages-retention-trigger to WSO2", environments = {TST1, PPE})
    public void postWebMortgagesRetentionTrigger(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(WEB_MORTGAGES_RETENTION_TRIGGER_PATH, false,
                        "{\n" +
                                "  \"version\": 1,\n" +
                                "  \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                                "  \"clientTimeZone\": \"Europe/Prague\",\n" +
                                "  \"inputs\": {\n" +
                                "    \"configurationEventName\": \"CC\",\n" +
                                "    \"firstName\": \"Markéta\",\n" +
                                "    \"lastName\": \"S Other\",\n" +
                                "    \"mobilePhone\": \"+420731955939\",\n" +
                                "    \"email\": \"marketa@mikesovi.com\",\n" +
                                "    \"mortgagesCompany\": \"WHB\",\n" +
                                "    \"reason\": \"REPAY_MORTGAGE_EARLY\",\n" +
                                "    \"mortgageID\": \"90000000\",\n" +
                                "    \"payOffDate\": \"2021-08-16\",\n" +
                                "    \"originFinancialMeans\": \"OTHER\",\n" +
                                "    \"bankRefinancing\": \"OTHER\",\n" +
                                "    \"operationId\": \"T_0000965810101\",\n" +
                                "    \"RC\": \"9361283074\"\n" +
                                "  }\n" +
                                "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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

}

