InMemoryCRUDRepository

class InMemoryCRUDRepository<I : Serializable, E : CRUDEntity<I, E>, CM : CRUDCreateModel, out Mapper : CRUDTestMapper<I, E, *, CM, *>>(typeName: String, mapper: Mapper, duplicateCheck: BiPredicate<E, E>, initialEntities: E) : 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

Mapper

Mapper type of the data which is a CRUDTestMapper

Constructors

Link copied to clipboard
fun <E : CRUDEntity<I, E>, out Mapper : CRUDTestMapper<I, E, *, CM, *>> InMemoryCRUDRepository(typeName: String, mapper: Mapper, duplicateCheck: BiPredicate<E, E>, vararg initialEntities: E)

Functions

Link copied to clipboard
fun clear()

Clears the repository for testing

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 changes made to the entities, meaning any change will be persisted.

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 updateByVersion(entity: E, version: Int): Int

Updates given entity if it is at given version