public class EntityTestUnit
extends java.lang.Object
Constructor and Description |
---|
EntityTestUnit(java.lang.String domainClass)
Instantiates a new EntityTestUnit.
|
Modifier and Type | Method and Description |
---|---|
static Entity |
createEntity(Domain domain,
java.lang.String entityId,
ValueProvider<Property,java.lang.Object> valueProvider) |
static Entity |
createRandomEntity(Domain domain,
java.lang.String entityId,
java.util.Map<java.lang.String,Entity> referenceEntities) |
protected void |
doSetUp()
Override to provide specific setup for this test
|
protected void |
doTearDown()
Override to provide specific tear down for this test
|
protected EntityConnection |
getConnection() |
Domain |
getDomain() |
protected User |
getTestUser()
Returns the database user to use when running the tests, this default implementation returns
a user based on the "jminor.unittest.username" and "jminor.unittest.password" system properties.
|
protected EntityConnectionProvider |
initializeConnectionProvider() |
protected Entity |
initializeReferenceEntity(java.lang.String entityId,
java.util.Map<java.lang.String,Entity> foreignKeyEntities)
Initializes a new Entity of the given type, by default this method creates a Entity filled with random values.
|
protected Entity |
initializeTestEntity(java.lang.String entityId,
java.util.Map<java.lang.String,Entity> foreignKeyEntities)
This method should return an instance of the entity specified by
entityId |
protected void |
modifyEntity(Entity testEntity,
java.util.Map<java.lang.String,Entity> foreignKeyEntities)
This method should return
testEntity in a modified state |
static void |
randomize(Domain domain,
Entity entity,
java.util.Map<java.lang.String,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
|
void |
setUp()
Sets up the database connection
|
void |
tearDown()
Tears down the database connection
|
void |
testEntity(java.lang.String entityId)
Runs the insert/update/select/delete tests for the given entityId
|
public EntityTestUnit(java.lang.String domainClass)
domainClass
- the name of the domain model classjava.lang.NullPointerException
- in case domainClass is nullpublic final Domain getDomain()
@BeforeEach public final void setUp()
@AfterEach public final void tearDown()
public final void testEntity(java.lang.String entityId) throws DatabaseException
entityId
- the ID of the entity to testDatabaseException
- in case of an exceptionpublic static Entity createRandomEntity(Domain domain, java.lang.String entityId, java.util.Map<java.lang.String,Entity> referenceEntities)
domain
- the domain modelentityId
- the entity IDreferenceEntities
- entities referenced by the given entity IDpublic static Entity createEntity(Domain domain, java.lang.String entityId, ValueProvider<Property,java.lang.Object> valueProvider)
domain
- the domain modelentityId
- the entity IDvalueProvider
- the value providerpublic static void randomize(Domain domain, Entity entity, java.util.Map<java.lang.String,Entity> foreignKeyEntities)
domain
- the domain modelentity
- the entity to randomizeforeignKeyEntities
- the entities referenced via foreign keysprotected void doSetUp()
protected void doTearDown()
protected EntityConnectionProvider initializeConnectionProvider()
protected User getTestUser()
protected final EntityConnection getConnection()
protected Entity initializeTestEntity(java.lang.String entityId, java.util.Map<java.lang.String,Entity> foreignKeyEntities)
entityId
entityId
- the entityId for which to initialize an entity instanceforeignKeyEntities
- the entities referenced via foreign keysprotected Entity initializeReferenceEntity(java.lang.String entityId, java.util.Map<java.lang.String,Entity> foreignKeyEntities)
entityId
- the entity IDforeignKeyEntities
- the entities referenced via foreign keys