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 wustenrot-credentials-create to WSO2 and assert response parameters")
public class ApiWustenrotCredentialsCreate {

    @TestCase(name = "Call API wustenrot-credentials-create to WSO2", environments = {TST1, PPE})
    public void postWustenrotCredentialsCreate(Harness harness) {
        RawRestRequest.Response response = harness.tasks().wso2().restRequest().prepareRequestFromCvm(
                "digitalchannels.sb/wustenrot-credentials-create/1.0", false,
                "{\n" +
                        "    \"uniPtKey\": " + harness.getConfig("cvm.client.wustenrotcredentials.uniptkey") + "\n" +
                        "}")
                .postExtended()
                .andAssertPresent("password")
                .andAssertPresent("qrContent")
                .andAssertPresent("qrUrl")
                .andAssertStatus(200);

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

    }
}