CRUDTestData

abstract class CRUDTestData<I : Serializable, E : CRUDEntity<I>, M : CRUDModel<I>, CM : CRUDCreateModel, UM : CRUDUpdateModel, TestData : CRUDTestData<I, E, M, CM, UM, TestData>>(typeName: String)(source)

Test data provider and mapper to convert between models and entities in tests

Parameters

I

Id type of the data

M

Model type of the data which is a CRUDModel

E

Entity type of the data which is a CRUDEntity

CM

Create model type of the data which is a CRUDCreateModel

UM

Update model type of the data which is a CRUDUpdateModel

TestData

Test data type of the data which is a CRUDTestData, meant to be the concrete type that extends this class

typeName

Type name of the data

Constructors

Link copied to clipboard
fun CRUDTestData(typeName: String)

Properties

Link copied to clipboard

Instant provider to use in tests

Link copied to clipboard
abstract val moreTestEntities: Array<E>

More test entities if needed

Link copied to clipboard

Instance of a InMemoryCRUDRepository containing test entities

Link copied to clipboard
abstract val testEntity1: E

First test entity

Link copied to clipboard
abstract val testEntity2: E

Second test entity

Link copied to clipboard
abstract val testEntity3: E

Third test entity

Functions

Link copied to clipboard
abstract fun areDuplicates(e1: E, e2: E): Boolean

Check if two entities are duplicates, this should reflect your unique constraint on the DB

Link copied to clipboard
abstract fun copy(entity: E): E

Copies an entity

Link copied to clipboard
abstract fun entityToCreateModel(entity: E): CM

Mapper to convert from given entity to create model

Link copied to clipboard

Mapper to convert from given entity to update model with some modifications

Link copied to clipboard

Mapper to convert from given entity to update model with no modifications

Link copied to clipboard
fun now(): Instant

Now instant to use in tests

Link copied to clipboard
abstract fun randomId(): I

Function to generate a random id