I have a JUnit test which does a basic check of the repository layer which deletes an entry from the db.
I am using @DatabaseSetup annotation to provide initial configuration and using @ExpectedDatabase to verify the contents of DB post the deletion.
Following is the code
@Test
@ExpectedDatabase(
table = "OBJECT_ALIAS",
value = "classpath:dbunit/data/object_alias_deleted_2115_ALIAS_5.xml")
public void testDeleteObjectAlias() {
ObjectAlias objectAlias = new ObjectAlias(2115, 5, "NewAlias");
objectAliasRepository.deleteObjectAlias(objectAlias);
//objectAliasRepository.findByPartyNo(5); //runs a select query on DB
}
The above test fails but if I uncomment the commented line, the test passes.
I am using eclipseLink as a JPA provider.
What causes this behaviour?