InMemoryCRUDRepository

open class InMemoryCRUDRepository<I : Serializable, E : CRUDEntity<I>, CM : CRUDCreateModel, TestData : CRUDTestData<I, E, *, CM, *, TestData>>(testData: TestData) : CRUDRepository<I, E> (source)

In-memory implementation of CRUDRepository for testing

Parameters

I

Id type of the data

E

Entity type of the data which is a CRUDEntity

CM

Create model type of the data which is a CRUDCreateModel

TestData

Test data type of the data which is a CRUDTestData

Constructors

Link copied to clipboard

Properties

Link copied to clipboard

Map of entities by their ids, accessible for tests

Functions

Link copied to clipboard
fun clear()

Clears the repository for testing, there will be no entities left after this.

Link copied to clipboard
open override fun findAllByDeletedAtIsNull(pageable: Pageable): Page<E>

Finds all entities for given pagination and deletion flag

Link copied to clipboard
open override fun findByIdAndDeletedAtIsNull(id: I): E?

Finds an entity with given id and deletion flag

Link copied to clipboard
open override fun flush()

Flushes the changes to the database

Link copied to clipboard
fun reset()

Reset the repository for testing, there will be the initial entities after this.

Link copied to clipboard
open override fun save(entity: E): E

Saves given entity, used when creating a new entity

Link copied to clipboard
open override fun update(entity: E): Int

Updates given entity if it is at set version using optimistic locking