All Projects → atomfinger → toUUID

atomfinger / toUUID

Licence: Apache-2.0 license
Simple integer to UUID generator for unit and integration tests written in Java or Kotlin

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to toUUID

Movieapp
🎬 MovieApp is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Modularization, BLoC, Dependency Injection, Dynamic Theme, Cache, Shimmer, Testing, Flavor, CI/CD, etc.
Stars: ✭ 117 (+875%)
Mutual labels:  unit-testing, integration-testing
Truth
Fluent assertions for Java and Android
Stars: ✭ 2,359 (+19558.33%)
Mutual labels:  unit-testing, testing-library
Dockertest
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work.
Stars: ✭ 2,254 (+18683.33%)
Mutual labels:  unit-testing, integration-testing
Testing Workshop
A workshop for learning how to test JavaScript applications
Stars: ✭ 1,276 (+10533.33%)
Mutual labels:  unit-testing, integration-testing
Hexagonal-architecture-ASP.NET-Core
App generator API solution template which is built on Hexagnonal Architecture with all essential feature using .NET Core
Stars: ✭ 57 (+375%)
Mutual labels:  unit-testing, integration-testing
Unit Threaded
Advanced unit test framework for D
Stars: ✭ 100 (+733.33%)
Mutual labels:  unit-testing, integration-testing
Systemwrapper
.NET library for easier testing of system APIs.
Stars: ✭ 153 (+1175%)
Mutual labels:  unit-testing, integration-testing
Java Dns Cache Manipulator
🌏 A simple 0-dependency thread-safe Java™ lib/tool for setting dns programmatically without touching host file, make unit/integration test portable.
Stars: ✭ 557 (+4541.67%)
Mutual labels:  unit-testing, integration-testing
toster
DSL framework for testing Android apps
Stars: ✭ 31 (+158.33%)
Mutual labels:  unit-testing, testing-library
Dntframeworkcore
Lightweight and Extensible Infrastructure for Building Web Applications - Web Application Framework
Stars: ✭ 208 (+1633.33%)
Mutual labels:  unit-testing, integration-testing
Redux Saga Test Plan
Test Redux Saga with an easy plan.
Stars: ✭ 1,135 (+9358.33%)
Mutual labels:  unit-testing, integration-testing
springboot-junit5-mockito2
Show case for how to use junit 5 and mockito 2 for unit testing and integration test in spring boot 2
Stars: ✭ 18 (+50%)
Mutual labels:  unit-testing, integration-testing
Aspnetcore Tests Sample
A project to help demonstrate how to do unit, integration and acceptance tests with an web api project using ASP.NET Core and Angular 7 front end.
Stars: ✭ 40 (+233.33%)
Mutual labels:  unit-testing, integration-testing
Automation Arsenal
Curated list of popular Java and Kotlin frameworks, libraries and tools related to software testing, quality assurance and adjacent processes automation.
Stars: ✭ 105 (+775%)
Mutual labels:  unit-testing, integration-testing
Quixote
CSS unit and integration testing
Stars: ✭ 788 (+6466.67%)
Mutual labels:  unit-testing, integration-testing
Android Client
An android client for the MifosX platform
Stars: ✭ 150 (+1150%)
Mutual labels:  unit-testing, integration-testing
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+31316.67%)
Mutual labels:  unit-testing, integration-testing
Codeception
Full-stack testing PHP framework
Stars: ✭ 4,401 (+36575%)
Mutual labels:  unit-testing, integration-testing
Onion Architecture Asp.net Core
WhiteApp API solution template which is built on Onion Architecture with all essential feature using .NET 5!
Stars: ✭ 196 (+1533.33%)
Mutual labels:  unit-testing, integration-testing
pythonista-chromeless
Serverless selenium which dynamically execute any given code.
Stars: ✭ 31 (+158.33%)
Mutual labels:  unit-testing, integration-testing

Main CI Maven Central

A tiny library for generating UUIDs in automated tests for Java and Kotlin


Table of contents:

Install

Maven

<dependency>
    <groupId>io.github.atomfinger</groupId>
    <artifactId>atomfinger-touuid</artifactId>
    <version>1.0.1</version>
    <scope>test</scope>
</dependency>

Gradle

(Using the Maven Central Repository)

testCompile group: 'io.github.atomfinger', name: 'atomfinger-touuid', version: '1.0.1'

Examples

Java

toUUID is first and foremost a Kotlin project. Still, one of the goals was to keep it free for any unnecessary dependencies, which is why Java users should use the UUIDs class to avoid having to deal with any extra dependencies.

UUID from a single integer:

import static io.github.atomfinger.touuid.UUIDs.*;

UUID uuid = toUUID(1);
System.out.println(uuid.toString());
//Output:
//00000000-0000-0000-0000-000000000001

UUID from a list of integers:

import static io.github.atomfinger.touuid.UUIDs.*;

List<UUID> uuids = toUUIDs(Arrays.asList(1, 2, 3, 4, 5));
uuids.forEach((it) -> System.out.println(it.toString()));
//Output:
//00000000-0000-0000-0000-000000000001
//00000000-0000-0000-0000-000000000002
//00000000-0000-0000-0000-000000000003
//00000000-0000-0000-0000-000000000004
//00000000-0000-0000-0000-000000000005

UUID from varargs:

import static io.github.atomfinger.touuid.UUIDs.*;

List<UUID> uuids = toUUIDs(1, 2, 3, 4, 5);
uuids.forEach((it) -> System.out.println(it.toString()));
//Output:
//00000000-0000-0000-0000-000000000001
//00000000-0000-0000-0000-000000000002
//00000000-0000-0000-0000-000000000003
//00000000-0000-0000-0000-000000000004
//00000000-0000-0000-0000-000000000005

UUID from range of integers:

import static io.github.atomfinger.touuid.UUIDs.*;

List<UUID> uuids = toUUIDsFromRange(1, 5);
uuids.forEach((it) -> System.out.println(it.toString()));
//Output:
//00000000-0000-0000-0000-000000000001
//00000000-0000-0000-0000-000000000002
//00000000-0000-0000-0000-000000000003
//00000000-0000-0000-0000-000000000004
//00000000-0000-0000-0000-000000000005

Kotlin

Kotlin has access to all the feature Java has, but also has the addition of extension functions.

Generate based on an integer:

val uuid = 1.toUuid()
println(uuid.toString())
//Output:
//00000000-0000-0000-0000-000000000001

Generate from a list of integers:

val uuids = listOf(1, 2, 3, 4, 5).toUuids()
uuids.forEach { println(it.toString()) }
//Output:
//00000000-0000-0000-0000-000000000001
//00000000-0000-0000-0000-000000000002
//00000000-0000-0000-0000-000000000003
//00000000-0000-0000-0000-000000000004
//00000000-0000-0000-0000-000000000005

Generate based on a range of integers:

val uuids = (1..5).toUuids()
uuids.forEach { println(it.toString()) }
//Output:
//00000000-0000-0000-0000-000000000001
//00000000-0000-0000-0000-000000000002
//00000000-0000-0000-0000-000000000003
//00000000-0000-0000-0000-000000000004
//00000000-0000-0000-0000-000000000005

Generate based on a sequence of integers:

val uuids = uuids().take(5)
uuids.forEach { println(it.toString()) }
//Output:
//00000000-0000-0000-0000-000000000001
//00000000-0000-0000-0000-000000000002
//00000000-0000-0000-0000-000000000003
//00000000-0000-0000-0000-000000000004
//00000000-0000-0000-0000-000000000005

Why toUUID?

Check out the writeup on why toUUID() is worth it

How toUUID works

toUUID takes the integer and puts it at the back of the UUID. Which is why the number:
1
turns into the UUID:
00000000-0000-0000-0000-000000000001.

Here's some more examples:

Number input UUID output
2 00000000-0000-0000-0000-000000000002
5 00000000-0000-0000-0000-000000000005
10 00000000-0000-0000-0000-000000000010
55 00000000-0000-0000-0000-000000000055
100 00000000-0000-0000-0000-000000000100
100000 00000000-0000-0000-0000-000000100000

⚠️ Never use toUUID in production code ⚠️

toUUID is not a replacement for how one normally generates UUIDs in production code. There are a few versions of UUID which all have different algorithms attached to them, and this library bypasses all that. While toUUID generates technically valid UUIDs it does not create a UUID which is suitable for production (even if a random number is passed).

toUUID is to be used in automated testing or to generate a repeatable set of human-readable UUIDs.

Demo projects

Both Kotlin and Java has demo projects:

How to build

.toUUID is a standard Maven application:

  1. Clone project
  2. Run mvn clean install in the project folder

Requirements:

  • Java 1.8 or higher
  • the Kotlin compiler

Contact

you can contact me through my website or the social links found on said website. Don't hesitate to ask if there are any questions :)

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].