Skip to content

Commit

Permalink
Updated unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rousso committed Oct 11, 2022
1 parent 5d4f003 commit 8816402
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/test/java/eu/europa/ted/efx/EfxTemplateTranslatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,42 +197,42 @@ void testShorthandBtLabelReference_MissingLabelType() {
@Test
void testShorthandIndirectLabelReferenceForIndicator() {
assertEquals(
"declare block01 = { label(concat('indicator', '|', 'when', '-', ../IndicatorField/normalize-space(text()), '|', 'BT-00-Indicator')) }\nfor-each(/*/PathNode/TextField).call(block01)",
"declare block01 = { label(for $item in ../IndicatorField return concat('indicator', '|', 'when', '-', $item, '|', 'BT-00-Indicator')) }\nfor-each(/*/PathNode/TextField).call(block01)",
translate("{BT-00-Text} #{BT-00-Indicator}"));
}

@Test
void testShorthandIndirectLabelReferenceForCode() {
assertEquals(
"declare block01 = { label(concat('code', '|', 'name', '|', 'main-activity', '.', ../CodeField/normalize-space(text()))) }\nfor-each(/*/PathNode/TextField).call(block01)",
"declare block01 = { label(for $item in ../CodeField return concat('code', '|', 'name', '|', 'main-activity', '.', $item)) }\nfor-each(/*/PathNode/TextField).call(block01)",
translate("{BT-00-Text} #{BT-00-Code}"));
}

@Test
void testShorthandIndirectLabelReferenceForInternalCode() {
assertEquals(
"declare block01 = { label(concat('code', '|', 'name', '|', 'main-activity', '.', ../InternalCodeField/normalize-space(text()))) }\nfor-each(/*/PathNode/TextField).call(block01)",
"declare block01 = { label(for $item in ../InternalCodeField return concat('code', '|', 'name', '|', 'main-activity', '.', $item)) }\nfor-each(/*/PathNode/TextField).call(block01)",
translate("{BT-00-Text} #{BT-00-Internal-Code}"));
}

@Test
void testShorthandIndirectLabelReferenceForCodeAttribute() {
assertEquals(
"declare block01 = { label(concat('code', '|', 'name', '|', 'main-activity', '.', ../CodeField/@attribute)) }\nfor-each(/*/PathNode/TextField).call(block01)",
"declare block01 = { label(for $item in ../CodeField/@attribute return concat('code', '|', 'name', '|', 'main-activity', '.', $item)) }\nfor-each(/*/PathNode/TextField).call(block01)",
translate("{BT-00-Text} #{BT-00-CodeAttribute}"));
}

@Test
void testShorthandIndirectLabelReferenceForCodeAttribute_WithSameAttributeInContext() {
assertEquals(
"declare block01 = { label(concat('code', '|', 'name', '|', 'main-activity', '.', ../@attribute)) }\nfor-each(/*/PathNode/CodeField/@attribute).call(block01)",
"declare block01 = { label(for $item in ../@attribute return concat('code', '|', 'name', '|', 'main-activity', '.', $item)) }\nfor-each(/*/PathNode/CodeField/@attribute).call(block01)",
translate("{BT-00-CodeAttribute} #{BT-00-CodeAttribute}"));
}

@Test
void testShorthandIndirectLabelReferenceForCodeAttribute_WithSameElementInContext() {
assertEquals(
"declare block01 = { label(concat('code', '|', 'name', '|', 'main-activity', '.', ./@attribute)) }\nfor-each(/*/PathNode/CodeField).call(block01)",
"declare block01 = { label(for $item in ./@attribute return concat('code', '|', 'name', '|', 'main-activity', '.', $item)) }\nfor-each(/*/PathNode/CodeField).call(block01)",
translate("{BT-00-Code} #{BT-00-CodeAttribute}"));
}

Expand Down Expand Up @@ -287,7 +287,7 @@ void testShorthandLabelReferenceFromContext_WithNodeContext() {
@Test
void testShorthandIndirectLabelReferenceFromContextField() {
assertEquals(
"declare block01 = { label(concat('code', '|', 'name', '|', 'main-activity', '.', ./normalize-space(text()))) }\nfor-each(/*/PathNode/CodeField).call(block01)",
"declare block01 = { label(for $item in . return concat('code', '|', 'name', '|', 'main-activity', '.', $item)) }\nfor-each(/*/PathNode/CodeField).call(block01)",
translate("{BT-00-Code} #value"));
}

Expand All @@ -308,7 +308,7 @@ void testShorthandFieldValueReferenceFromContextField() {
@Test
void testShorthandFieldValueReferenceFromContextField_WithText() {
assertEquals(
"declare block01 = { text('blah ')label(concat('code', '|', 'name', '|', 'main-activity', '.', ./normalize-space(text())))text(' ')text('blah ')eval(.)text(' ')text('blah') }\nfor-each(/*/PathNode/CodeField).call(block01)",
"declare block01 = { text('blah ')label(for $item in . return concat('code', '|', 'name', '|', 'main-activity', '.', $item))text(' ')text('blah ')eval(.)text(' ')text('blah') }\nfor-each(/*/PathNode/CodeField).call(block01)",
translate("{BT-00-Code} blah #value blah $value blah"));
}

Expand Down

0 comments on commit 8816402

Please sign in to comment.