-
Notifications
You must be signed in to change notification settings - Fork 1
Move examples from rosetta translate to translate demo
This page contains instructions on how to migrate rosetta-translate unit tests to translate-demo examples. A few utilities have been created to help.
The data used to create examples in translate-demo are stored in a folder src/test/resources/example-generation/inputs. Within that folder the examples are organised into category folder (e.g. single-cardinality) and example name folder (e.g. example 4).
- Decide on categoryName (e.g. single-cardinality) and exampleSuffix (e.g. 4, used in the example name, example-4)
- In Intellij, open utility class
ExampleTemplateGenerator, set categoryName and exampleSuffix, run the main- Note:
ExampleTemplateGeneratorrun configuration should have working dir of$MODULE_DIR$
- Note:
- Template (or empty) xml, xsd, rosetta and md files will be created in a folder structure inside the inputs folder
The rosetta-translate project has many unit tests that can be migrated into translate-demo examples. Choose a unit test (based on the provided spreadsheet), and copy over the files into the template files created in step 1.
Rosetta, xml, xsd files can be found in rosetta-translate, inside the folder /rosetta-translate/src/test/resources/xml.
- Find the relevant unit test in
rosetta-translate. - Copy the unit test rosetta code, excluding the top level element (e.g.
Top4), as this is namedRootin the template. - Once copied into
translate-demoinputs folder:- Format code (intending, naming etc)
- Update synonyms source to template value (e.g. change
Bank_AtoSINGLE_CARDINALITY_EXAMPLE_4)
- In rosetta-translate copy the unit test xsd content excluding other schema tag into translate-demo xsd template
- In rosetta-translate copy the unit test xml content into translate-demo xml template
- Clean up old element schema attributes
3.1 Copy inputs to correct folder structure and generate config and unit tests.
- In translate-demo, open ExampleGenerator, and run to create full examples from inputs folder.
- Note: ExampleTemplateGenerator run configuration should have working dir of
$MODULE_DIR$
- Note: ExampleTemplateGenerator run configuration should have working dir of
3.2 Generate rosetta
- Run maven plugins "resources:copy-resources xtext:generate -f pom.xml"
- Code should now compile
3.3 Run unit tests and generate expectations by running all tests with update flags set
- Set up run all unit tests configuration with env vars:
- TEST_WRITE_BASE_PATH=/Users/hugohills/dev/github/rosetta-models/translate-demo/rosetta-source/src/main/resources;WRITE_EXPECTATIONS=true;CREATE_EXPECTATION_FILES=true