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;
import static org.junit.jupiter.api.Assertions.assertEquals;

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

    @TestCase(name = "Call API SBA_SAS_RTDM_SetResponse to WSO2", environments = {TST1, PPE})
    public void postSbaSasRtdmSetResponse(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "cvm.cluster/SBA_SetResponse/1.0.0", false,
                        "{\n" +
                                "    \"version\": 1,\n" +
                                "    \"clientTimeZone\": \"Europe/Prague\",\n" +
                                "    \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                                "    \"inputs\": { \n" +
                                "        \"ACTION_TYPE\": \"VIEW\", \n" +
                                "        \"BANNER_ID\": [ 1000045 ], \n" +
                                "        \"CHANNEL_ID\": \"SBA\",\n" +
                                "        \"CIF\": \"" + harness.getConfig("cvm.client.setresponse.cif") + "\", \n" +
                                "        \"RESPONSE_TRACKING_CD\": \"106060101\", \n" +
                                "        \"TREATMENT_TRACKING_CD\": [ \"1353001\" ], \n" +
                                "        \"USER_ID\": 2829314, \n" +
                                "        \"pushOrderId\": [ \"2129\" ] }, \n" +
                                "        \"version\": 1 \n" +
                                "    }\n" +
                                "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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

        assertEquals("OK", outputs.findValue("STATUS").textValue(), "Not found REPLY_TYPE with value STANDARD or NORMAL");

    }
}
