package cz.moneta.test.sandbox.connectiontests.jenkinsapi;

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 cz.moneta.test.harness.endpoints.nasdb.NasDbEndpoint;
import cz.moneta.test.harness.endpoints.ods.OdsEndpoint;
import cz.moneta.test.harness.endpoints.testautomationdb.TestAutomationDbEndpoint;
import cz.moneta.test.harness.endpoints.udebs.UdebsEndpoint;
import org.jooq.Record;
import org.jooq.Result;
import org.junit.jupiter.api.Assertions;

@TestScenario(name = "Check Environment Database Connections")
public class DatabaseConnectionTest {

    @TestCase(name = "Check Harness DB Connection")
    public void testHarnessDbConnection(Harness harness) {
        Result<Record> result = harness.getEndpoint(TestAutomationDbEndpoint.class).executeSql("SELECT 1");
        Assertions.assertTrue(result.isNotEmpty());
    }

    @TestCase(name = "Check ODS DB Connection", environments = {Environment.TST1, Environment.PPE, Environment.FVE})
    public void testOdsDbConnection(Harness harness) {
        Result<Record> result = harness.getEndpoint(OdsEndpoint.class).executeSql("SELECT 1 FROM DUAL");
        Assertions.assertTrue(result.isNotEmpty());
    }

    @TestCase(name = "Check UDEBS DB Connection", environments = {Environment.TST1, Environment.PPE, Environment.FVE})
    public void testUdebsDbConnection(Harness harness) {
        Result<Record> result = harness.getEndpoint(UdebsEndpoint.class).executeSql("SELECT 1 FROM DUAL");
        Assertions.assertTrue(result.isNotEmpty());
    }

    @TestCase(name = "Check NAS DB Connection", environments = {Environment.TST1, Environment.PPE})
    public void testNasDbConnection(Harness harness) {
        Result<Record> result = harness.getEndpoint(NasDbEndpoint.class).executeSql("SELECT 1 FROM DUAL");
        Assertions.assertTrue(result.isNotEmpty());
    }

    @TestCase(name = "Check Hypos DB Connection", environments = {Environment.TST1, Environment.PPE, Environment.FVE})
    public void testHyposDbConnection(Harness harness) {
        Result<Record> result = harness.getEndpoint(HyposDbEndpoint.class).executeSql("SELECT 1");
        Assertions.assertTrue(result.isNotEmpty());
    }

}

