Library allow you to produce Dummy Objects (POJOs) by using Factories and populate their fields with random values by using Annotations. And then Export them in CSV/JSON/XML/SQL format.
Steps to do:
- Create Dummy (POJO).
- Annotate your Dummy object fields with special Gen annotations.
- Use Factory to populate/produce your Dummy Objects.
- Export your Dummy Objects by using special Exporter.
Maven
<dependency>
<groupId>com.github.goodforgod</groupId>
<artifactId>dummymaker</artifactId>
<version>1.0.3</version>
</dependency>
Gradle
dependencies {
compile 'com.github.goodforgod:dummymaker:1.0.3'
}
You can easily create your own annotations and generators which will be supported by Scanners and Export classes, so it is easy extendable library.
Allow to populate or produce Dummy Objects.
-
GenProduceFactory - allow you to produce new Dummies with populated fields.
-
GenPopulateFactory - allow you to populate fields of already created Dummies.
Allow to export Dummy objects in specific format into file. Also allow to export Dummy objects as a string value.
Constructor parameters available for all exporters.
-
ExportClass - class to export.
-
Path - set path for export file, default directory where app is started.
-
NameStrategy - naming strategy applied to all origin fields (fields which are not @GenRenameExport), default value is DEFAULT.
NamingStrategies
- DEFAULT - origin name, as is.
- UPPER_CASE - name in upper case, like DummyList - DUMMYLIST
- LOW_CASE - name in low case, like DummyList - dummylist
- UNDERSCORED_LOW_CASE - name in upper case, with _ symbol before each capital letter, like DummyList - dummy_list
- UNDERSCORED_UPPER_CASE - name in low case, with _ symbol before each capital letter, like DummyList - dummy_list
- INITIAL_LOW_CASE - origin name, but first letter is low case, like DummyList - dummyList
- WrapTextValues - if true will wrap String values with commas like 'this', default False.
- GenerateHeader - if true will generate CSV header, default False.
- Separator - set CSV format separator, default is ',' comma.
- ExportClassListName - export xml list name value (example: if class is Dummy, default list name will be DummyList).
- dataTypeMap - map with key as a class, and sql data type as string as map value.
DataTypeMap is used to extend your data types to export in sql format.
Allow to declare Dummy fields with generator annotations. Factories will generate values by using their provided methods.
Generate annotations start with Gen prefix (like GenInteger, GenEmail).
-
GenForceExport allow to force export object field, even if it is not generated by GenAnnotation.
-
GenIgnoreExport allow to ignore object's field during export.
-
GenRenameExport allow to rename Dummy export field name or Class Name (Annotate constructor to rename class export name).
-
GenNumerate annotation with option (from) to numerate populated/produced Dummies fields (Works on Integer/Long/String field types).
In this case, field city will be export despite that there is not generator field for it, value will be "Saint-Petersburg". And field id will NOT be export if ignore annotation will have true (default) value.
GenEnumerate annotation will enumerate Dummy field starting from 10. It means if we want to produce 10 Dummy Objects, they will have id from 10 to 19.
GenRenameExport annotation will change field export name.
GenRenameExport annotation will change class export name.
Available GenPopulateFactory/GenProvideFactory. Allow user populate or produce Dummy objects.
It will be useful in case, you have complex created objects and you want just to populate some of their fields.
Is useful in save you have custom writer or need to send it over network.
Examples of exported Dummy object in each format.
public class User {
@GenInteger
public Integer id;
@GenName
public String name;
}
Can be used to import data in Cassandra, Mongo, Neo4j, etc...
Csv exporter can generate header. (Like in example below) This option is available to set during instantiating like others.
name,id
ERASMO,1746885991
HELEN,-625322461
Can be used to import data in Mongo, MySQL, etc...
{
"User": [
{
"name": "GREGORY",
"id": "-2123372253"
},
{
"name": "HAROLD",
"id": "-1637387700"
}
]
}
Can be used to import data in MySQL, SQL Server, etc...
<UserList>
<User>
<name>GREGORY</name>
<id>-2123372253</id>
</User>
<User>
<name>HAROLD</name>
<id>-1637387700</id>
</User>
</UserList>
Don't forget about Primary Key!
Each insert query can contains max 995 rows (Due to 1000 insert row limit in SQL).
CREATE TABLE IF NOT EXISTS user(
name VARCHAR,
id INT,
PRIMARY KEY (id)
);
INSERT INTO user (name, id) VALUES
('GREGORY', -2123372253),
('HAROLD', -1637387700);
1.0.3 - Lots of tests for all functionality, Added DataTypeMap parameter for users in SqlExporter (expandable data type for sql), NamingStrategy for exporters, bug fixes.
1.0.2 - Added special GenRenameExport annotation, export as single string, export values order fix, minor fixes and improvements.
1.0.1 - Added new generator and annotations, special GenEnumerate annotation, other minor fixes (Like SQL export).
1.0.0 - Initial project with core functions.
This project is licensed under the Apache License - see the LICENCE file for details.