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 web-building-savings-trigger to WSO2 and assert response parameters")
public class ApiWebBuildingSavingsTrigger {

    @TestCase(name = "Call API web-building-savings-trigger to WSO2", environments = {TST1, PPE})
    public void postWebBuildingSavingsTrigger(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "cvm.cluster/web-building-savings-trigger/1.0.0", false,
                "{\n" +
                        "    \"version\": 1,\n" +
                        "    \"clientTimeZone\": \"Europe/Prague\",\n" +
                        "    \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                        "    \"inputs\": {\n" +
                        "        \"configurationEventName\": \"ERROR/OPAKOVANI_MOZNE/CC\",\n" +
                        "        \"firstName\": \"Tomik\",\n" +
                        "        \"lastName\": \"Chlupatejsi\",\n" +
                        "        \"email\": \"volani.cc@neexistujicidomana.com\",\n" +
                        "        \"phoneNumber\": \"777763549\",\n" +
                        "        \"marketing\": true,\n" +
                        "        \"unsecuredCommunication\": false,\n" +
                        "        \"birthNumber\": \"8812210022\",\n" +
                        "        \"cif\": null,\n" +
                        "        \"clientCheckWFID\": \"456def\",\n" +
                        "        \"screenID\": \"identity_check\",\n" +
                        "        \"exitResult\": \"OPAKOVANI_MOZNE\",\n" +
                        "        \"exitDescription\": \"nejaka chyba\",\n" +
                        "        \"eventTimeStamp\": \"" + DateUtils.getFormattedTodayDateTimeForWso2() + "\"\n" +
                        "    }\n" +
                        "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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

