All Projects → smartcat-labs → ranger

smartcat-labs / ranger

Licence: Apache-2.0 license
Ranger is contextual data generator used to make sensible data for integration tests or to play with it in the database

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
shell
77523 projects

Projects that are alternatives of or similar to ranger

Generatedata
A powerful, feature-rich, random test data generator.
Stars: ✭ 1,883 (+3091.53%)
Mutual labels:  data-generation, test-data, data-generator
Bogus
📇 A simple and sane fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Stars: ✭ 5,083 (+8515.25%)
Mutual labels:  test-data, data-generator
random-jpa
Create random test data for JPA/Hibernate entities.
Stars: ✭ 23 (-61.02%)
Mutual labels:  test-data, data-generator
hypothesis-graphql
Generate arbitrary queries matching your GraphQL schema, and use them to verify your backend implementation.
Stars: ✭ 32 (-45.76%)
Mutual labels:  data-generation
datamaker
Data generator command-line tool and library. Create JSON, CSV, XML data from templates.
Stars: ✭ 23 (-61.02%)
Mutual labels:  data-generation
Data Augmentation Review
List of useful data augmentation resources. You will find here some not common techniques, libraries, links to github repos, papers and others.
Stars: ✭ 785 (+1230.51%)
Mutual labels:  data-generation
Stream data
Data generation and property-based testing for Elixir. 🔮
Stars: ✭ 597 (+911.86%)
Mutual labels:  data-generation
genalog
Genalog is an open source, cross-platform python package allowing generation of synthetic document images with custom degradations and text alignment capabilities.
Stars: ✭ 234 (+296.61%)
Mutual labels:  data-generation
Regexp Examples
Generate strings that match a given regular expression
Stars: ✭ 483 (+718.64%)
Mutual labels:  data-generation
Deepconvsep
Deep Convolutional Neural Networks for Musical Source Separation
Stars: ✭ 424 (+618.64%)
Mutual labels:  data-generation
Gratis
GRATIS: GeneRAting TIme Series with diverse and controllable characteristics
Stars: ✭ 51 (-13.56%)
Mutual labels:  data-generation
Mockneat
MockNeat is a Java 8+ library that facilitates the generation of arbitrary data for your applications.
Stars: ✭ 410 (+594.92%)
Mutual labels:  data-generation
Autofillr
A browser extension that fills registration forms with randomly but consistently generated fake data.
Stars: ✭ 17 (-71.19%)
Mutual labels:  data-generation
Awesome Ai Ml Dl
Awesome Artificial Intelligence, Machine Learning and Deep Learning as we learn it. Study notes and a curated list of awesome resources of such topics.
Stars: ✭ 831 (+1308.47%)
Mutual labels:  data-generation
DeepEcho
Synthetic Data Generation for mixed-type, multivariate time series.
Stars: ✭ 44 (-25.42%)
Mutual labels:  data-generation
Copulas
A library to model multivariate data using copulas.
Stars: ✭ 149 (+152.54%)
Mutual labels:  data-generation
synth
The Declarative Data Generator
Stars: ✭ 958 (+1523.73%)
Mutual labels:  data-generation
Sdv
Synthetic Data Generation for tabular, relational and time series data.
Stars: ✭ 360 (+510.17%)
Mutual labels:  data-generation
Pydbgen
Random dataframe and database table generator
Stars: ✭ 191 (+223.73%)
Mutual labels:  data-generation
Wakefield
Generate random data sets
Stars: ✭ 208 (+252.54%)
Mutual labels:  data-generation

Build Status Download

Ranger

Ranger is a Java open source library that allows developers to quickly and in a simple manner define and create large number of objects whose attributes have randomly selected values from the configured set.

Two main purposes of Ranger are:

  • create unit and integration test data based on defined rules
  • data source for Berserker

Ranger can be also used as data source for a custom tool of your choice.

Quick guide

Quick guide provides a way to have running Ranger example within 5 minutes from which you can start and build solution for your own needs. Please take a look at API documentation for more details what can be acomplished with Ranger.

Repository

Artifact can be fetched from bintray. Add following <repository> element to your <repositories> section in pom.xml:

<repository>
  <id>bintray-smartcat-labs-maven</id>
  <name>bintray</name>
  <url>https://dl.bintray.com/smartcat-labs/maven</url>
</repository>

Dependency

Add the <dependency> element to your <dependencies> section in pom.xml with specific version.ranger you need:

<dependency>
  <groupId>io.smartcat</groupId>
  <artifactId>ranger</artifactId>
  <version>${version.ranger}</version>
</dependency>

Similarly, dependency can be added to any other build tool supporting maven dependencies.

Code

Copy the code and run it.

Example.java

import static io.smartcat.ranger.BuilderMethods.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import io.smartcat.ranger.ObjectGenerator;
import io.smartcat.ranger.ObjectGeneratorBuilder;

public class Example {

    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    public static void main(String[] args) throws ParseException {
        ObjectGenerator<Address> address = new ObjectGeneratorBuilder()
                .prop("city", random("New York", "Washington", "San Francisco"))
                .prop("street", random("2nd St", "5th Avenue", "21st St", "Main St"))
                .prop("houseNumber", random(range(1, 55))).build(Address.class);

        Date januaryFifth1985 = DATE_FORMAT.parse("1985-01-05");
        Date decemberTwentySecond2000 = DATE_FORMAT.parse("2000-12-22");

        ObjectGenerator<User> user = new ObjectGeneratorBuilder()
              .prop("id", circular(range(1L, 2_000_000L), 1L))
              .prop("username", string("{}{}", random("aragorn", "johnsnow", "mike", "batman"), random(range(1, 100))))
              .prop("firstName", random("Peter", "Rodger", "Michael"))
              .prop("lastName", random("Smith", "Cooper", "Stark", "Grayson", "Atkinson", "Durant"))
              .prop("birthDate", random(range(januaryFifth1985, decemberTwentySecond2000)))
              .prop("maried", false)
              .prop("accountBalance", random(range(0.0d, 10_000.0d)))
              .prop("address", address).build(User.class);

        for (int i = 0; i < 100; i++) {
            System.out.println(user.next());
        }
    }

    private static class Address {

        public String city;
        public String street;
        public long houseNumber;

        @Override
        public String toString() {
            return "Address [city=" + city + ", street=" + street + ", houseNumber=" + houseNumber + "]";
        }
    }

    private static class User {

        public long id;
        public String username;
        public String firstName;
        public String lastName;
        public Date birthDate;
        public boolean maried;
        public Double accountBalance;
        public Address address;

        @Override
        public String toString() {
            return "User [id=" + id + ", username=" + username + ", firstName=" + firstName + ", lastName=" + lastName
                    + ", birthDate=" + birthDate + ", maried=" + maried + ", accountBalance=" + accountBalance
                    + ", address=" + address + "]";
        }
    }
}

Why?

Totally random test data is not so useful:

Random users table

  • It is hard to make it by certain rules
  • It is hard to reason about it
  • It does not reflect production data values nor distribution

What we can do is use contextual data generator and create users whose attribute values make sense in the domain context. We can also say, for example, that 70% of created users should be females. The table will then look like this:

Context users table

How it works?

Ranger builds a tree of dependent value generators based on user configuration (either Java API or YAML configuration). Then it uses that tree to construct map with generated values. If type is not specified by builder or configuration parser, Map<String, Object> is return type. If type is specified, Jackson library is used to convert map to specified type. All rules and limitations of Jackson apply here also.

API

Ranger supports two ways of configuring generator. Java API and YAML Configuration.

Examples

All examples are located at src/example/java.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].