random-value-suppliers

Template repo to speed up creating new library projects

Лицензия

Лицензия

Группа

Группа

com.github.michaelruocco
Идентификатор

Идентификатор

random-value-suppliers
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

pom.sha512
Описание

Описание

random-value-suppliers
Template repo to speed up creating new library projects
Ссылка на сайт

Ссылка на сайт

https://github.com/michaelruocco/random-value-suppliers
Система контроля версий

Система контроля версий

https://github.com/michaelruocco/random-value-suppliers

Скачать random-value-suppliers

Зависимости

runtime (2)

Идентификатор библиотеки Тип Версия
org.apache.commons : commons-text jar 1.9
org.apache.commons : commons-lang3 jar 3.11

Модули Проекта

Данный проект не имеет модулей.

Library Template

Build codecov Codacy Badge BCH compliance Quality Gate Status Technical Debt Coverage Lines of Code Maven Central License: MIT

Overview

This library contains some small utilities for generating random values in a testable way.

UUIDs

If you need to generate a UUID value you can of course just call UUID.randomUUID() and this works fine. However, when you are testing you cannot easily determine what the value will be. This library aims to help with that by providing the UuidGenerator interface, in normal execution the RandomUuidGenerator can be used to provide a random UUID, this is ultimately just calls UUID.randomUUID(). when testing you can use NonRandomUuidGenerator instead, by default it will cycle around 5 fixed UUID values each time it is called, if you require more than 5 distinct values you can pass in your own list of fixed UUID values instead if you wish.

Numeric Strings

For generic string values a similar NumericStringGenerator interface has been created, the generate method takes a single argument which determines the length of the numeric string to be returned. If you do not need to vary the length of the string value you can wrap the generated inside the FixedLengthNumericStringGenerator class. There are two implementations of NumericStringGenerator the first is RandomNumericStringGenerator which unsurprisingly will generate a string containing random digits of the specified length. When testing you can use IncrementingNumericStringGenerator this will return predictable results by returning an incrementing value starting from 1. So if you pass a length of 5, the first 3 calls would return "00001", "00002", "00003".

Examples

The unit tests for each of the classes listed above demonstrate each of the classes above and how they can be used.

Useful Commands

// cleans build directories
// prints currentVersion
// formats code
// builds code
// runs tests
// checks for gradle issues
// checks dependency versions
./gradlew clean currentVersion dependencyUpdates lintGradle spotlessApply build

Версии библиотеки

Версия
0.1.0