package cz.moneta.test.regression.cvm.api.digitalchannelssb;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.rest.RawRestRequest;
import org.junit.jupiter.api.Assertions;

import java.util.List;

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

@TestScenario(name = "Call API push-message-send to WSO2 and assert response parameters")
public class ApiPushMessageSend {

    @TestCase(name = "Call API push-message-send to WSO2", environments = {TST1, PPE})
    public void postPushMessageSend(Harness harness) {
        RawRestRequest.Response response = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "digitalchannels.sb/push-message-send/1.0", false,
                "{\n" +
                        "    \"cif\": \"" + harness.getConfig("cvm.client.pushmessagesend.cif") + "\",\n" +
                        "    \"priority\": 1,\n" +
                        "    \"responseTrackingCode\": \"1234\",\n" +
                        "    \"templateId\": 1000045,\n" +
                        "    \"treatmentTrackingCode\": \"1234\"\n" +
                        "}")
                .postExtended()
                .andAssertPresent("pushExtensionId")
                .andAssertPresent("pushOrderId")
                .andAssertStatus(200);

        List<Object> activityIds = response.getHeader("activityId");
        Assertions.assertEquals(1, activityIds.size(), "API should return activityId header");

    }
}