package cz.moneta.test.system.cagw;

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;

@TestScenario(name = "Example of CA API GW test")
public class CaGwExampleTest {

    String entityId = "10027415";

    @TestCase(name = "Example of CA API GW test")
    public void testCaApiGw(Harness harness) {
        String attempts = harness.withCaGw().api().v1().external().service().voicebot().prepareVoicePasswordDetail()
                .withAuthorizationBearer(harness.tasks().caGw().authorization().getVoicebotToken())
                .entityId(entityId)
                .send()
                .getAttempts();

        Assertions.assertEquals("0", attempts);
    }

    @TestCase(name = "Exaple of CA API GW test with alternative way of writing")
    public void testVoicePasswordDetail(Harness harness) {
        harness.withCaGw().prepareRequest()
                .withPath("/api/v1/external/service/voicebot/voice_password_detail")
                .withHeader("Authorization", harness.tasks().caGw().authorization().getVoicebotToken())
                .withHeader("Content-Type", "application/json")
                .withPayload("{}")
                .addField("entityId", entityId)
                .post()
                .andAssertStatus(200)
                .andAssertFieldValue("attempts", "0");
    }

}
