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 ib-set-response to WSO2 and assert response parameters")
public class ApiIbSetResponse {

    @TestCase(name = "Call API ib-set-response to WSO2", environments = {TST1, PPE})
    public void postIbSetResponse(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCblToCvm(
                "cvm.cluster/decision/ib-set-response/1.0.0", false,
                "{\n" +
                        "    \"version\": 1,\n" +
                        "    \"clientTimeZone\": \"Europe/Prague\",\n" +
                        "    \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                        "    \"inputs\": {\n" +
                        "        \"cif\": \"9000949039\",\n" +
                        "        \"userId\": 1234,\n" +
                        "        \"channelId\": \"IBS\",\n" +
                        "        \"actionType\": \"VIEW\",\n" +
                        "        \"bannerId\": [\n" +
                        "            2000002\n" +
                        "        ],\n" +
                        "        \"locationId\": [\n" +
                        "            2000001\n" +
                        "        ],\n" +
                        "        \"treatmentTrackingCd\": [\n" +
                        "            \"389004\"\n" +
                        "        ],\n" +
                        "        \"responseTrackingCd\": \"111770101\"\n" +
                        "    }\n" +
                        "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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