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 RTRD_HELLO to WSO2 and assert response parameters")
public class ApiRtrdHello {

    @TestCase(name = "Call API RTRD_HELLO to WSO2", environments = {TST1, PPE})
    public void getRtrdDigitalchannelsLoanCalculatorCalculation(Harness harness) {
        String tokenCvmSrt = harness.tasks().wso2().authorization().getToken("CVM_SRT");

        JsonNode message = harness.withWso2()
                .prepareRequest()
                .withPath("/t/cvm.cluster/rtrd/hello/001")
                .withHeader("Authorization", tokenCvmSrt)
                .withHeader("Accept", "application/json")
                .get()
                .andAssertStatus(200)
                .extract("message");

        Assertions.assertTrue(message != null && "Hello from RTRD".equals(message.textValue()), "Not found hello message output in response");
    }
}