-
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.
- Github permissions
- Artifactory / settings.xml permissions
- Check out and mvn build projects:
- Import Eclipse project rosetta-components/rosetta-translate
- Set up Intellij project translate-demo
- Set up Rosetta RC user
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 rosetta 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 example file (e.g.example-4.rosetta):- Format code (intending, naming etc)
- Update synonyms source to template value (e.g. change
Bank_AtoSINGLE_CARDINALITY_EXAMPLE_4)
- Find the relevant unit test xsd in
rosetta-translate. - Copy the unit test xsd content, excluding schema tag into
translate-demoinputs xsd file (e.g.example-4.xsd)
- Find the relevant unit test xml in
rosetta-translate. - Copy the xml content into
translate-demoinputs xml file (e.g.example-4.xml) - Clean up old element schema attributes
- Look at the unit test / example and write a short description in the
translate-demoinputs md file (e.g.example-4.md)
Use the utility to generate the required structure, config file to display the examples in the Rosetta application. The utility also generates unit tests (and expectations) for each example.
- In Intellij, open
ExampleGenerator, and run to create all config and units tests for examples specified in the inputs folder- Note:
ExampleGeneratorrun configuration should have working dir of$MODULE_DIR$
- Note:
- Run maven plugins "resources:copy-resources xtext:generate -f pom.xml" to generate classes
- Note: set up maven command in Intellij run configuration
- Code should now compile, and unit tests should run
- Run unit tests and generate expectations by running all tests with update flags set
- Set up run all unit tests run configuration in Intellij 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
- Unit test json expectations should be created.
- Add all unversioned files and commit and push all changes.