package cz.moneta.test.system.xyzmo;

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.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Assertions;

@TestScenario(name = "tessts various Xyzmo scenarios")
public class SignpadTest {

    @TestCase(name = "attepts to start a xyzmo session")
    public void startXyzmoSession(Harness harness) {
        Pair<String, String> workstepAndTokenIds = harness.tasks()
                .xyzmo()
                .startSession();

        RawRestRequest.Response signDocument = harness.tasks()
                .xyzmo()
                .signDocument(workstepAndTokenIds.getLeft());

        RawRestRequest.Response setTaskResult = harness.tasks()
                .xyzmo()
                .setTaskResult(workstepAndTokenIds.getLeft());

        RawRestRequest.Response finishWorkstep = harness.tasks()
                .xyzmo()
                .finishWorkstep(workstepAndTokenIds.getRight());

        RawRestRequest.Response sessionStatus = harness.tasks()
                .xyzmo()
                .getSessionStatus(workstepAndTokenIds.getRight());

        Assertions.assertNotNull(sessionStatus);
    }

    @TestCase(name = "attepts to start a xyzmo session")
    public void getWorkstepId(Harness harness) {
        Pair<String, String> workstepAndTokenIds = harness.tasks()
                .xyzmo()
                .startSession();

        String workstepId = harness.tasks()
                .xyzmo()
                .getWorkstepId(workstepAndTokenIds.getRight());

        Assertions.assertEquals(workstepAndTokenIds.getLeft(), workstepId);
    }
}
