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

import com.fasterxml.jackson.databind.JsonNode;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.DateUtils;
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.Disabled;

import java.util.List;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@TestScenario(name = "Call API basic-registers-duplicity-event to WSO2 and assert response parameters")
@Disabled("Subscription does not exist")
public class ApiBasicRegistersDuplicityEvent {

    public static final String BASIC_REGISTERS_DUPLICITY_EVENT_PATH = "cvm.cluster/basic-registers-duplicity-event/1.0.0";

    @TestCase(name = "Call API basic-registers-duplicity-event to WSO2", environments = {TST1, PPE})
    public void postBasicRegistersDuplicityEvent(Harness harness) {
        RawRestRequest.Response response = harness.tasks().wso2().restRequest().prepareRequestFromCblToCvm(
                        BASIC_REGISTERS_DUPLICITY_EVENT_PATH, false,
                        "{\n" +
                                "  \"uniptKey\": \"34456666\",\n" +
                                "  \"business\": \"GEMCB\",\n" +
                                "  \"instPtSrcSysID\": \"ICB01\",\n" +
                                "  \"eventTimeStamp\": \"" + DateUtils.getFormattedTodayDateTimeForWso2() + "\"\n" +
                                "}")
                .postExtended()
                .andAssertStatus(200);

        JsonNode body = response.extract("");
        List<Object> activityIds = response.getHeader("activityId");

        assertNotNull(body, "Not found output in response");
        assertEquals(1, activityIds.size(), "API should return activityId header");
    }
}

