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

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

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

    @TestCase(name = "Call API SAS_PricingSensitivity_POS to WSO2", environments = {TST1, PPE})
    public void postSasPricingSensitivityPos(Harness harness) {
        JsonNode response = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "cvm.cluster/SAS_PricingSensitivity_POS/001", false,
                "{  \"APP_KEY\": 567899,\n" +
                        "  \"BIRTH_NUMBER\": \"8509021818\",\n" +
                        "  \"IDENTIFICATION_NUMBER\": 0,\n" +
                        "  \"SSO\": \"123015070\",\n" +
                        "  \"BROKER_FLAG\": \"0\",\n" +
                        "  \"FAMILY_INCOME\": 123455880,\n" +
                        "  \"UNIPT_KEY\": 3601656,\n" +
                        "  \"CHANNEL_ID\": \"POS\",\n" +
                        "  \"PRODUCT_CLASS\": \"50\",\n" +
                        "  \"BUS_PROD_TYPE\": \"5005\",\n" +
                        "  \"SALES_BUS_PROD_TYPE\": \"50005\",\n" +
                        "  \"REQ_FINA_AMT\": 78678,\n" +
                        "  \"REQ_INSTL_CNT\": 23,\n" +
                        "  \"MIN_INTRS_RX\": 1.65,\n" +
                        "  \"PRICE_INTRS_RX\": 1.78,\n" +
                        "  \"INCOME\": 98765,\n" +
                        "  \"RBP_GRADE\": \"B\"}")
                .post()
                .andAssertStatus(200)
                .extract("");

        Assertions.assertNotNull(response, "Not found result in response");
        Assertions.assertNotNull(response.findValue("MODEL_ID").textValue(), "Not found MODEL_ID element");
        Assertions.assertNotNull(response.findValue("INTRS_MODIF").textValue(), "Not found INTRS_MODIF element");
        Assertions.assertEquals("OK", response.findValue("result").textValue(), "Not found OK in result in response");
        Assertions.assertEquals("NORMAL", response.findValue("RESPONSE_TYPE").textValue(), "Not found REPLY_TYPE with value NORMAL");

    }
}