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 branches-client-reservation to WSO2 and assert response parameters")
public class ApiBranchesClientReservation {

    public static final String BRANCHES_CLIENT_RESERVATION_PATH = "cvm.cluster/branches-client-reservation/1.0.0";

    @TestCase(name = "Call API branches-client-reservation to WSO2", environments = {TST1, PPE})
    public void postBranchesClientReservation(Harness harness) {
        JsonNode outputs = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                        BRANCHES_CLIENT_RESERVATION_PATH, false,
                        "{\n" +
                                "  \"correlationId\": \"" + UUID.randomUUID() + "\",\n" +
                                "  \"clientTimeZone\": \"Europe/Prague\",\n" +
                                "  \"version\": 1,\n" +
                                "  \"inputs\": {\n" +
                                "    \"POS_ID\": \"86009260\",\n" +
                                "    \"PRODUCT_CATEGORY\": \"EXP\"\n" +
                                "  }\n" +
                                "}")
                .post()
                .andAssertStatus(201)
                .extract("outputs");

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

