Overview

Herdwick

The Herdwick is a breed of domestic sheep native to the Lake District of Cumbria in North West England. The name "Herdwick" is derived from the Old Norse herdvyck, meaning sheep pasture.

Herdwick is also a library for easily populating databases with dummy data. It analyses database schema for foreign key references and other constraints to make generation of data as painless as possible.

Build Status

Example

Consider the following database schema:

create table department (
    id serial primary key,
    name varchar(20) not null unique,
);

create table employee (
    id serial primary key,
    department_id int not null references department,
    name varchar(50) not null unique
);

To automatically populate the schema with valid values, you can use the following code:

Populator populator = Populator.forUrlAndCredentials("jdbc:example-url", "login", "password");

populator.populate("department", 50);
populator.populate("employee", 10000);

The populator.populate("department", 50) call will generate 50 random departments whose names will be unique and populator.populate("employee", 10000) will generate 10000 employees randomly assigned to those departments.

Integration with Dalesbred

If you are using Dalesbred, you can construct a new populator using your Database-instance:

Database db = ...
Populator populator = new Populator(db);

Like this you can integrate population with your existing transactions.

Attributions

Image of herdwick used on the website is by hollidaypics on Flickr and is used by CC BY 2.0.