java.lang.Object
is.codion.framework.domain.entity.test.EntityTestUtil

public final class EntityTestUtil extends Object
Utility methods for creating and manipulating Entity instances for testing purposes.
  • Method Details

    • createRandomEntity

      public static Entity createRandomEntity(Entities entities, EntityType entityType, Map<ForeignKey,Entity> referenceEntities)
      Parameters:
      entities - the domain model entities
      entityType - the entityType
      referenceEntities - 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 entities
      entityType - the entityType
      valueProvider - 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 entities
      entity - the entity to randomize
      foreignKeyEntities - 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 definition
      referenceEntities - entities referenced by the given attribute
      Returns:
      a random value