Class EntityTestUtil


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

      • 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 property definitions
      • createEntity

        public static Entity createEntity​(Entities entities,
                                          EntityType entityType,
                                          Function<Property<?>,​Object> valueProvider)
        Parameters:
        entities - the domain model entities
        entityType - the entityType
        valueProvider - the value provider
        Returns:
        an Entity instance initialized with values provided by the given value provider
      • randomize

        public static void randomize​(Entities entities,
                                     Entity entity,
                                     Map<ForeignKey,​Entity> foreignKeyEntities)
        Randomizes the 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​(Property<T> property,
                                              Map<ForeignKey,​Entity> referenceEntities)
        Creates a random value for the given property.
        Type Parameters:
        T - the property type
        Parameters:
        property - the property
        referenceEntities - entities referenced by the given property
        Returns:
        a random value