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 basic-registers-duplicity-trigger to WSO2 and assert response parameters")
public class ApiBasicRegistersDuplicityTrigger {

    public static final String BASIC_REGISTERS_DUPLICITY_TRIGGER_PATH = "cvm.cluster/basic-registers-duplicity-trigger/1.0.0";

    @TestCase(name = "Call API basic-registers-duplicity-trigger to WSO2", environments = {TST1, PPE})
    public void postBasicRegistersDuplicityTrigger(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                        BASIC_REGISTERS_DUPLICITY_TRIGGER_PATH, false,
                        "{\n" +
                                "  \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                                "  \"clientTimeZone\": \"Europe/Prague\",\n" +
                                "  \"version\": 1,\n" +
                                "  \"inputs\": {\n" +
                                "    \"uniptKey\": \"34456666\",\n" +
                                "    \"business\": \"GEMCB\",\n" +
                                "    \"instPtSrcSysID\": \"ICB01\",\n" +
                                "    \"eventTimeStamp\": \"" + DateUtils.getFormattedTodayDateTimeForWso2() + "\",\n" +
                                "    \"configurationEventName\": \"register-duplicity-rem2\"\n" +
                                "  }\n" +
                                "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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

