Creating new 'data on demand' for testing entities
We saw in the previous recipe that the test
integration
command and testAutomatically
argument of the entity
command result in the generation of an integration test and seed data for an entity. In situations where you're creating your own integration tests, you may still want to use the Roo-generated seed data for an entity. So, you are writing your custom integration test class but using a Roo-generated 'data on demand' class. This is where the dod
command of Spring Roo comes into the picture.
Getting ready
Exit the Roo shell and delete the contents of the C:\roo-cookbook\ch02-recipes
directory.
Execute the ch02_jsr303_fields.roo
script. It creates a flight-app
Roo project and sets up Hibernate as the persistence provider using the persistence
setup
command. The script also creates a Flight
entity, which has FlightKey
as its composite primary key class, and adds fields to the Flight
and FlightKey
classes. If you are using a different database...