package cz.moneta.test.regression.backoffice.exevido.api;

import com.fasterxml.jackson.databind.node.ObjectNode;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.JiraTestCase;
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.AfterEach;

import static cz.moneta.test.dsl.util.task.ufo.cb.CommercialTasks.JIRA_COMMENT_STORE_KEY;
import static cz.moneta.test.harness.annotations.Environment.TST1;


@TestScenario(name = "Exevido Post Outgoing Message")
public class ApiOutgoingMessage {

    ObjectNode objectNode;
    String inputData;

    @TestCase(name = "Exevido Post Outgoing Message", environments = {TST1})
    @JiraTestCase(id = "BOC-T8658")
    public void messageOutgoing(Harness harness) {
        RawRestRequest.Response response = harness.tasks().wso2().restRequest().prepareRequestFromUfo("/t/backoffice.cluster/exe-message-outgoing/v1")
                .withPayloadFromFile("regression/exevido/api/outgoingMessage.json")
                .post();
        inputData = response.getPayload();
        objectNode = response
                .andAssertStatus(200)
                .mapResponseIntoObject(ObjectNode.class);
    }

    @AfterEach
    protected void teardown(Harness harness) {
        harness.store(JIRA_COMMENT_STORE_KEY,
                "\nVstup: " + inputData + "\nVýstup: \n " + objectNode.toPrettyString());
    }
}

