Loading a collection of entities from a set of files
You can load entities that are defined in XML or JSON by using the test driver createFileEntitySource (DataFormat format, String path) and loadEntities(Iterator<Entity> entities) methods.
About this task
To retrieve XML data from your system, you can use the REST API. Alternatively, you can create JSON representations of entities that you want to load.
You can specify a name pattern to select the files that you want to be converted. When you create the EntitySource, you can specify a regular expression, such as .*entity, to select the files that you want from a directory. For more information about regular expressions, see the Java™ Tutorials Lesson: Regular Expressions.
You can also configure the EntitySource implementation to take a specific action when an entity type is not recognized. The skipUnrecognizedEntities flag defines the failure behavior. If you set skipUnrecognizedEntities to true, the entities that are not recognized are skipped and the other recognized entities continue to load. If you set it to false and a file contains an entity that is not recognized, an exception is thrown and no other entities are loaded.