io.sitoolkit.rdg:sit-rdg-maven-plugin

SI-Toolkit Random Data Generator

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

io.sitoolkit.rdg
ArtifactId

ArtifactId

sit-rdg-maven-plugin
Last Version

Last Version

1.0.0-beta.1
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

SI-Toolkit Random Data Generator

Download sit-rdg-maven-plugin

How to add to project

<plugin>
    <groupId>io.sitoolkit.rdg</groupId>
    <artifactId>sit-rdg-maven-plugin</artifactId>
    <version>1.0.0-beta.1</version>
</plugin>

Dependencies

compile (4)

Group / Artifact Type Version
io.sitoolkit.rdg : sit-rdg-core jar 1.0.0-beta.1
org.apache.maven : maven-plugin-api jar 3.3.9
org.apache.maven : maven-core jar 3.3.9
org.apache.maven : maven-compat jar 3.3.9

provided (3)

Group / Artifact Type Version
org.apache.maven : maven-artifact jar 3.3.9
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5
org.projectlombok : lombok jar 1.18.10

test (4)

Group / Artifact Type Version
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
junit : junit jar 4.12
org.hamcrest : hamcrest-all jar 1.3
org.hamcrest : java-hamcrest jar 2.0.0.0

Project Modules

There are no modules declared in this project.

Random Data Generator

Random Data Generator (sit-rdg) is a tool to generate data set for TEST. sit-rdg analyzes DDL and DML script file and resolve DB schema from them, i.e. tables, columns, relations, and generate csv files per table.

Required Software

  • Java
  • Maven (Optional)

How to Use

  1. Download sit-rdg-xxx.jar or put pom.xml in your workspace directory.
  2. Put DDL and DML scripts used in your application in the input directory. (input/*.sql)
  3. Execute sit-rdg.
  4. Then csv files are generated in the output directory. (output/*.csv)
- workspace
    sit-rdg-xxx.jar          |
    pom.xml                  |-- 1.

  - input
      create-table_1.sql     |
      create-table_2.sql     |
      select-some.sql        |-- 2.
        :

      schema.json  
      generator-config.json

  - output
      table_1.csv            |
      table_2.csv            |-- 4.
        :

You can specify the behavior of sit-rdg in detail using following 2 files.

  • schema.json
    • Metadata of DB schema which is the result of analysis of *.sql
    • This files are generated by sit-rdg, but you can modify it or create from scratch.
  • generator-config.json
    • Specification of data generation

You can execute sit-rtg with the following 2 ways.

  • Java Command
  • Maven Plugin

Java Command

Exeucte the following commands in your workspace.

curl -o sit-rdg-core-1.0.0-beta.2.jar https://repo.maven.apache.org/maven2/io/sitoolkit/rdg/sit-rdg-core/1.0.0-beta.2/sit-rdg-core-1.0.0-beta.2.jar

java -jar sit-rdg-core-1.0.0-beta.2.jar

Maven

Put pom.xml in your workspace and execute mvn command.

  • pom.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>your-group-id</groupId>
  <artifactId>your-artifact-id</artifactId>
  <version>1.0.0-beta.2</version>

  <build>

    <defaultGoal>sit-rdg:run</defaultGoal>

    <plugins>
      <plugin>
        <groupId>io.sitoolkit.rdg</groupId>
        <artifactId>sit-rdg-maven-plugin</artifactId>
        <version>1.0.0-beta.2</version>
      </plugin>
    </plugins>

  </build>

</project>
mvn

generator-config.json

{
  "scale": "1/10",
  "defaultRowCount": 100,
  "schemaConfigs": [
    {
      "schemaName": "",
      "tableConfigs": [
        {
          "tableName": "TABLE_1",
          "columnConfigs": [
            {
              "columnName": "COLUMN_1",

             // See -Data Generation Specification-
              "spec": {
                "type": "sequence",
                "start": 0,
                "end": 9,
                "step": 1
              } 
            }
          ]
        }
      ]
    }
  ]
}

Data Generation Specification

sequence

Spec: sequence is to generate sequencial value per generation.

{
  "type": "sequence",
  "start": 0,  // start value of sequence (default 0)
  "end": 9,    // end value of sequence (defalut Long.MAX_VALUE)
  "step": 1    // increment value per generation of sequence (default 1)
               // if sequence value is over the end value, the value is reset to start
}

range

Spec: range is to generate values between specified range.

{
  "type": "range",
  "ranges": [
    // this range generates 0, 1, 2 with 40% probability
    {
      "min": 0,
      "max": 2,
      "step": 1,
      "ratio": 0.2
    },
    // this range generates 3, 6, 9 with 60% probability
    {
      "min": 3,
      "max": 9,
      "step": 3,
      "ratio": 0.3
    }
  ]
}
{
  "type": "choice",
  "values": [
    {
      "value": "01",
      "ratio": 0.3
    },
    {
      "value": "02",
      "ratio": 0.2
    }
  ]
}
io.sitoolkit.rdg

SI-Toolkit

Tools for smart system development

Versions

Version
1.0.0-beta.1
0.9