Faker - halotukozak/PBD GitHub Wiki

Introduction

Faker is a project made in Kotlin with Exposed and kotlin-faker frameworks to generate random data.

Main

Main function is the entry point of the application. It loads the configuration from application.conf file (not included in the repository due to security reasons) and connects to the database. Then it checks if there is consistency between the code and the database. After that it clears the database and assures if it is empty. If everything is fine, it starts inserting data into the database with InsertManager class.

InsertManager

This class is responsible for inserting data into the database. It uses safeTransaction function to ignore Violation of UNIQUE KEY constraint and Violation of PRIMARY KEY constraint exceptions. It is used to prevent throwing exceptions due to duplicated data.

Models

A model is an object that represents a table in the database. It is fully consisted with the schema of the table. Making og the capabilities of Exposed, it is possible to create SQL faster with DAO, what is used with non-relational entities.

FakerUtils

This file contains extensions for Faker library.

  • date returns a random date between startDate and endDate.

  • dateTime returns a random date and time between startTime and endTime.

  • url returns a random URL with domain and slugged path.

  • email returns a random email based on Name (a first name and a last name).

  • subject returns a random subject name from science branches or programming languages.