code: /*
   * Copyright (c) 2022 Airbyte, Inc., all rights reserved.
   */
  
  package io.airbyte.integrations.source.mysql;
  
  import com.google.common.collect.ImmutableMap;
  import io.airbyte.commons.json.Jsons;
  import io.airbyte.db.Database;
  import io.airbyte.db.factory.DSLContextFactory;
  import io.airbyte.db.factory.DatabaseDriver;
  import io.airbyte.db.jdbc.JdbcUtils;
  import io.airbyte.integrations.source.mysql.MySqlSource.ReplicationMethod;
  import io.airbyte.integrations.standardtest.source.TestDestinationEnv;
  import org.jooq.DSLContext;
  import org.jooq.SQLDialect;
  import org.testcontainers.containers.MySQLContainer;
  
  public class MySqlSslSourceAcceptanceTest extends MySqlSourceAcceptanceTest {
  
    @Override
    protected void setupEnvironment(final TestDestinationEnv environment) throws Exception {
      container = new MySQLContainer<>("mysql:8.0");
      container.start();
  
      var sslMode = ImmutableMap.builder()
          .put(JdbcUtils.MODE_KEY, "required")
          .build();
  
      config = Jsons.jsonNode(ImmutableMap.builder()
          .put(JdbcUtils.HOST_KEY, container.getHost())
          .put(JdbcUtils.PORT_KEY, container.getFirstMappedPort())
          .put(JdbcUtils.DATABASE_KEY, container.getDatabaseName())
          .put(JdbcUtils.USERNAME_KEY, container.getUsername())
          .put(JdbcUtils.PASSWORD_KEY, container.getPassword())
          .put(JdbcUtils.SSL_KEY, true)
          .put(JdbcUtils.SSL_MODE_KEY, sslMode)
          .put("replication_method", ReplicationMethod.STANDARD)
          .build());
  
      try (final DSLContext dslContext = DSLContextFactory.create(
          config.get(JdbcUtils.USERNAME_KEY).asText(),
          config.get(JdbcUtils.PASSWORD_KEY).asText(),
          DatabaseDriver.MYSQL.getDriverClassName(),
          String.format("jdbc:mysql://%s:%s/%s",
              config.get(JdbcUtils.HOST_KEY).asText(),
              config.get(JdbcUtils.PORT_KEY).asText(),
              config.get(JdbcUtils.DATABASE_KEY).asText()),
          SQLDialect.MYSQL)) {
        final Database database = new Database(dslContext);
  
        database.query(ctx -> {
          ctx.fetch("CREATE TABLE id_and_name(id INTEGER, name VARCHAR(200));");
          ctx.fetch(
              "INSERT INTO id_and_name (id, name) VALUES (1,'picard'),  (2, 'crusher'), (3, 'vash');");
          ctx.fetch("CREATE TABLE starships(id INTEGER, name VARCHAR(200));");
          ctx.fetch(
              "INSERT INTO starships (id, name) VALUES (1,'enterprise-d'),  (2, 'defiant'), (3, 'yamato');");
          return null;
        });
      }
    }
  
  }
  