Annotation Interface FillDatabase


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Inherited @ExtendWith(BloviateExtension.class) public @interface FillDatabase
Declaratively fills a test database with Bloviate-generated data before each test.

Apply this to a test class (or an individual test method) together with a field marked FillSource that exposes the target DataSource or Connection. The schema must already exist — Bloviate fills the tables it discovers — so create it first (init script, Flyway/Liquibase, a Testcontainers withInitScript(...), etc.).

@FillDatabase(rows = 50, seed = 42)
class OrdersTest {

    @FillSource
    DataSource dataSource = ...; // schema already created

    @Test
    void hasData() throws Exception { ... }
}

The annotation is meta-annotated with ExtendWith, so adding @ExtendWith(BloviateExtension.class) separately is unnecessary. A method-level @FillDatabase overrides a class-level one for that test.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The JDBC batch size used for INSERTs.
    long
    The number of rows to generate per table.
    long
    The base seed for reproducible generation.
  • Element Details

    • rows

      long rows
      The number of rows to generate per table.
      Returns:
      the number of rows to generate per table (the default row count); defaults to 100
      Default:
      100L
    • batchSize

      int batchSize
      The JDBC batch size used for INSERTs.
      Returns:
      the JDBC batch size used for INSERTs; defaults to 1000
      Default:
      1000
    • seed

      long seed
      The base seed for reproducible generation. The same schema filled with the same seed always produces identical data; change it for a different but equally reproducible dataset.
      Returns:
      the base seed; defaults to 0
      Default:
      0L