/tdk-tc

TDK-Testcontainers integration

Primary LanguageJavaMIT LicenseMIT

TDK-TC

Actions Status: build
Maven Central

Synthesized TDK-Testcontainers integration

This project is a thin client for Synthesized TDK integrated with TestContainers which can be used in order to generate testing data in an empty database.

Usage

  • Use Maven or Gradle to import the most recent version of TDK-TC.

  • Create input and ouptut JdbcDatabaseContainer in the same network, create schema and empty database in the input container, for example:

    @BeforeEach
    void setUp() {
        network = Network.newNetwork();
        input = getContainer("input", true);
        output = getContainer("output", false);
        input.start();
        output.start();
    }

    private PostgreSQLContainer<?> getContainer(String name, boolean init) {
        PostgreSQLContainer<?> result = new PostgreSQLContainer<>("postgres:11.1")
                .withDatabaseName(name)
                .withUsername("user")
                .withPassword("password")
                .withNetwork(network);
        result = init ? result.withInitScript("dbcreate.sql") : result;
        return result;
    }
  • Run the transformation in the following way:

        new SynthesizedTDK(SynthesizedTDK.DEFAULT_IMAGE_NAME)
          // Use this method to alter container image name for the TDK-CLI container
          //.setImageName(...)
          // Use this method to set license key in case you are using paid version of TDK-CLI
          //.setLicense(...)
                .transform(
                    //Input JdbcDatabaseContainer: empty database with schema
                    input,
                    //Output JdbcDatabaseContainer: output database with generated data
                    output,
                        "default_config:\n" +
                                "    mode: \"GENERATION\"\n" +
                                "    target_row_number: 10\n" +
                                "global_seed: 42\n"
                );

See full documentation on workflow configuration in YAML format here.