Interface DomainTest.EntityFactory

All Known Implementing Classes:
DefaultEntityFactory
Enclosing class:
DomainTest

public static interface DomainTest.EntityFactory
Handles creating and modifying entities used for testing.
  • Method Summary

    Modifier and Type
    Method
    Description
    entity(ForeignKey foreignKey)
    Initializes an Entity instance to reference via the given foreign key.
    entity(EntityType entityType)
    Initializes the Entity instance on which to run the tests, by default this method creates an instance filled with random values.
    void
    modify(Entity entity)
    Modifies one or more values in entity, for the update test.
  • Method Details

    • entity

      Entity entity(EntityType entityType)
      Initializes the Entity instance on which to run the tests, by default this method creates an instance filled with random values.
      Parameters:
      entityType - the entityType for which to initialize an entity instance for testing
      Returns:
      the entity instance to use for testing the entity type
      Throws:
      DatabaseException - in case of an exception
    • entity

      Optional<Entity> entity(ForeignKey foreignKey)
      Initializes an Entity instance to reference via the given foreign key. The entity returned by this method must exist in the database, so it can either return an entity with a known hard-coded primary key value or return a newly inserted one. By default this method returns a newly inserted Entity populated with random values. Note that this default implementation returns an empty Optional in case the referenced entity type is read-only.
      Parameters:
      foreignKey - the foreign key referencing the entity
      Returns:
      an entity for the given foreign key or an empty Optional if none is required
      Throws:
      DatabaseException - in case of an exception
    • modify

      void modify(Entity entity)
      Modifies one or more values in entity, for the update test. If the entity is not modified, the update test will not be run. The default implementation populates the entity with random values.
      Parameters:
      entity - the entity to modify
      Throws:
      DatabaseException - in case of an exception