Class EntityTestUtil
java.lang.Object
is.codion.framework.domain.entity.test.EntityTestUtil
Utility methods for creating and manipulating Entity instances for testing purposes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Entity
createEntity
(Entities entities, EntityType entityType, Function<AttributeDefinition<?>, Object> valueProvider) static Entity
createRandomEntity
(Entities entities, EntityType entityType, Map<ForeignKey, Entity> referenceEntities) static <T> T
createRandomValue
(AttributeDefinition<T> attributeDefinition, Map<ForeignKey, Entity> referenceEntities) Creates a random value for the given attribute.static void
Randomizes updatable attribute values in the given entity, note that if a foreign key entity is not provided the respective foreign key value in not modified
-
Method Details
-
createRandomEntity
public static Entity createRandomEntity(Entities entities, EntityType entityType, Map<ForeignKey, Entity> referenceEntities) - Parameters:
entities
- the domain model entitiesentityType
- the entityTypereferenceEntities
- entities referenced by the given foreign key- Returns:
- an Entity instance containing randomized values, based on the attribute definitions
-
createEntity
public static Entity createEntity(Entities entities, EntityType entityType, Function<AttributeDefinition<?>, Object> valueProvider) - Parameters:
entities
- the domain model entitiesentityType
- the entityTypevalueProvider
- the value provider- Returns:
- an Entity instance with insertable attributes populated with values provided by the given value provider
-
randomize
public static void randomize(Entities entities, Entity entity, Map<ForeignKey, Entity> foreignKeyEntities) Randomizes updatable attribute values in the given entity, note that if a foreign key entity is not provided the respective foreign key value in not modified- Parameters:
entities
- the domain model entitiesentity
- the entity to randomizeforeignKeyEntities
- the entities referenced via foreign keys
-
createRandomValue
public static <T> T createRandomValue(AttributeDefinition<T> attributeDefinition, Map<ForeignKey, Entity> referenceEntities) Creates a random value for the given attribute.- Type Parameters:
T
- the attribute value type- Parameters:
attributeDefinition
- the attribute definitionreferenceEntities
- entities referenced by the given attribute- Returns:
- a random value
-