package cz.moneta.test.dsl.util.task.cvm.wso2;

import com.fasterxml.jackson.databind.JsonNode;
import cz.moneta.test.dsl.Harness;

import java.util.Optional;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class CvmWso2Tasks {

    private Harness harness;

    public CvmWso2Tasks(Harness harness) {
        this.harness = harness;
    }

    public void assertResponseOutputs(JsonNode outputs) {
        assertNotNull("Not found output in response", outputs);

        String replyType = Optional.ofNullable(outputs.findValue("REPLY_TYPE"))
                .map(JsonNode::textValue)
                .orElse(Optional.ofNullable(outputs.findValue("replyType"))
                        .map(JsonNode::textValue)
                        .orElse(""));

        assertTrue("Not found REPLY_TYPE with value STANDARD or NORMAL: " + replyType,
                replyType.contains("STANDARD") || replyType.contains("NORMAL"));
    }
}
