package cz.moneta.test.system.hyposdb;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.endpoints.hypos.hyposdb.HyposDbEndpoint;
import org.jooq.Record;
import org.jooq.Result;
import org.junit.jupiter.api.Assertions;

@TestScenario(name = "Test Hypos DB connection")
public class TestDatabaseConnection {

    @TestCase(name = "Get SQL Server version", environments = {Environment.TST1, Environment.PPE, Environment.EDU, Environment.FVE})
    public void getSqlServerVersion(Harness harness){
        String sqlSelect = "SELECT @@VERSION";
        Result<Record> sqlResult = harness.getEndpoint(HyposDbEndpoint.class).executeSql(sqlSelect);
        harness.log("SQL server version: " + sqlResult.formatXML());

        Assertions.assertTrue(sqlResult.format().contains("Microsoft SQL Server"));
    }

}
