Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Move examples from rosetta translate to translate demo

Hugo Hills edited this page Jul 20, 2022 · 14 revisions

This page contains instructions on how to migrate rosetta-translate unit tests to translate-demo examples. A few utilities have been created to help.

1. Create empty input files for a translate-demo example

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: ExampleTemplateGenerator run configuration should have working dir of $MODULE_DIR$
  • Template (or empty) xml, xsd, rosetta and md files will be created in a folder structure inside the inputs folder

2. Copy unit test files from rosetta-translate

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.

2.1 Copy rosetta code

  • 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 named Root in the template.
  • Once copied into translate-demo inputs folder:
    • Format code (intending, naming etc)
    • Update synonyms source to template value (e.g. change Bank_A to SINGLE_CARDINALITY_EXAMPLE_4)

2.2 Copy xsd content

  • In rosetta-translate copy the unit test xsd content excluding other schema tag into translate-demo xsd template

2.3 Copy xml content

  • In rosetta-translate copy the unit test xml content into translate-demo xml template
  • Clean up old element schema attributes

2.4 Write short description of test into empty md file

3. Generate examples from inputs folder

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$

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

4. Commit and push

Clone this wiki locally