const testcontainerFileForDB = {
    mariadb: 'MariadbTestContainer.java',
    mssql: 'MsSqlTestContainer.java',
    mysql: 'MysqlTestContainer.java',
    postgresql: 'PostgreSqlTestContainer.java',
};
const databaseArtifactForDB = {
    mariadb: {
        jdbc: { groupId: 'org.mariadb.jdbc', artifactId: 'mariadb-java-client' },
        r2dbc: { groupId: 'io.asyncer', artifactId: 'r2dbc-mysql' },
    },
    mssql: {
        jdbc: { groupId: 'com.microsoft.sqlserver', artifactId: 'mssql-jdbc' },
        r2dbc: { groupId: 'io.r2dbc', artifactId: 'r2dbc-mssql' },
    },
    mysql: {
        jdbc: { groupId: 'com.mysql', artifactId: 'mysql-connector-j' },
        r2dbc: { groupId: 'io.asyncer', artifactId: 'r2dbc-mysql' },
    },
    postgresql: {
        jdbc: { groupId: 'org.postgresql', artifactId: 'postgresql' },
        r2dbc: { groupId: 'org.postgresql', artifactId: 'r2dbc-postgresql' },
    },
};
export const getDatabaseDriverForDatabase = (databaseType) => databaseArtifactForDB[databaseType];
export const getH2MavenDefinition = ({ prodDatabaseType, packageFolder, }) => {
    const testcontainerFile = testcontainerFileForDB[prodDatabaseType];
    const excludeContainerPlugin = testcontainerFile
        ? [
            {
                inProfile: 'dev',
                groupId: 'org.apache.maven.plugins',
                artifactId: 'maven-compiler-plugin',
                additionalContent: `
<configuration>
  <testExcludes>
    <testExclude>${packageFolder}config/${testcontainerFile}</testExclude>
  </testExcludes>
</configuration>
`,
            },
        ]
        : [];
    return {
        jdbc: {
            dependencies: [{ inProfile: 'dev', groupId: 'com.h2database', artifactId: 'h2' }],
            plugins: excludeContainerPlugin,
        },
        r2dbc: {
            dependencies: [{ inProfile: 'dev', groupId: 'io.r2dbc', artifactId: 'r2dbc-h2' }],
        },
    };
};
export const getDatabaseTypeMavenDefinition = (databaseType, { inProfile }) => {
    const dependenciesForType = {
        mariadb: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.mariadb.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'mariadb', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.mariadb.r2dbc }],
            },
        },
        mssql: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.mssql.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'mssqlserver', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.mssql.r2dbc }],
            },
        },
        mysql: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.mysql.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'mysql', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.mysql.r2dbc }],
            },
        },
        oracle: {
            jdbc: {
                dependencies: [
                    { inProfile, groupId: 'com.oracle.database.jdbc', artifactId: 'ojdbc8' },
                    { groupId: 'org.testcontainers', artifactId: 'oracle-xe', scope: 'test' },
                ],
            },
            r2dbc: {},
        },
        postgresql: {
            jdbc: {
                dependencies: [
                    { inProfile, ...databaseArtifactForDB.postgresql.jdbc },
                    { groupId: 'org.testcontainers', artifactId: 'postgresql', scope: 'test' },
                ],
            },
            r2dbc: {
                dependencies: [{ inProfile, ...databaseArtifactForDB.postgresql.r2dbc }],
            },
        },
    };
    return dependenciesForType[databaseType];
};
