-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from OP-TED/check-view-templates-labels
Add check on labels references in view templates index (TEDEFO-3877)
- Loading branch information
Showing
14 changed files
with
213 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/eu/europa/ted/eforms/sdk/analysis/fact/ViewTemplatesIndexFact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package eu.europa.ted.eforms.sdk.analysis.fact; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import eu.europa.ted.eforms.sdk.analysis.domain.view.index.TedefoViewTemplateIndex; | ||
import eu.europa.ted.eforms.sdk.analysis.domain.view.index.TedefoViewTemplatesIndex; | ||
|
||
public class ViewTemplatesIndexFact implements SdkComponentFact<String> { | ||
|
||
private final TedefoViewTemplatesIndex viewTemplatesIndex; | ||
|
||
public ViewTemplatesIndexFact(TedefoViewTemplatesIndex viewTemplatesIndex) { | ||
this.viewTemplatesIndex = viewTemplatesIndex; | ||
} | ||
|
||
public Set<String> getLabelIds() { | ||
return viewTemplatesIndex.getViewTemplates().stream() | ||
.map(TedefoViewTemplateIndex::getLabelId) | ||
.collect(Collectors.toSet()); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return StringUtils.EMPTY; | ||
} | ||
|
||
@Override | ||
public String getTypeName() { | ||
return "viewTemplatesIndex"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/resources/eu/europa/ted/eforms/sdk/analysis/drools/viewTemplatesRules.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package eu.europa.ted.eforms.sdk.analysis.drools; | ||
|
||
unit SdkUnit; | ||
|
||
rule "View templates index references existing labels" | ||
when | ||
$labelId : /viewTemplatesIndex[ $v: this ]/labelIds | ||
not (exists /labels[ id == $labelId ]) | ||
then | ||
results.add(new ValidationResult($v, "Referenced label " + $labelId + " does not exist", ValidationStatusEnum.ERROR)); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/translations.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"files" : [ { | ||
"assetType" : "view", | ||
"twoLetterCode" : "en", | ||
"threeLetterCode" : "eng", | ||
"filename" : "view_en.xml" | ||
} ], | ||
"languages" : [ { | ||
"description" : "English", | ||
"twoLetterCode" : "en", | ||
"threeLetterCode" : "eng" | ||
} ] | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/translations/view_en.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | ||
<properties> | ||
<comment>view in English. File generated from metadata database.</comment> | ||
<entry key="view|name|1">View template for notice subtype 1</entry> | ||
<entry key="view|name|2">View template for notice subtype 2</entry> | ||
<entry key="view|name|summary">View template for notice summary</entry> | ||
</properties> |
33 changes: 33 additions & 0 deletions
33
src/test/resources/eforms-sdk-tests/tedefo-3877/invalid/view-templates/view-templates.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"ublVersion" : "2.3", | ||
"sdkVersion" : "1.6.0", | ||
"metadataDatabase" : { | ||
"version" : "1.5.29", | ||
"createdOn" : "2023-01-24T11:03:12" | ||
}, | ||
"viewTemplates" : [ { | ||
"id" : "1", | ||
"filename" : "1.efx", | ||
"description" : "Default", | ||
"_noticeSubtypeIds" : [ "1" ], | ||
"_label" : "view|name|1" | ||
}, { | ||
"id" : "2", | ||
"filename" : "2.efx", | ||
"description" : "Default", | ||
"_noticeSubtypeIds" : [ "2" ], | ||
"_label" : "view|name|2BAD" | ||
}, { | ||
"id" : "3", | ||
"filename" : "3.efx", | ||
"description" : "Default", | ||
"_noticeSubtypeIds" : [ "3" ], | ||
"_label" : "view|name|3" | ||
} , { | ||
"id" : "summary", | ||
"filename" : "summary.efx", | ||
"description" : "The summary view works for all notices", | ||
"_noticeSubtypeIds" : [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "CEI", "T01", "T02", "X01", "X02" ], | ||
"_label" : "view|name|summary" | ||
} ] | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/translations.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"files" : [ { | ||
"assetType" : "view", | ||
"twoLetterCode" : "en", | ||
"threeLetterCode" : "eng", | ||
"filename" : "view_en.xml" | ||
} ], | ||
"languages" : [ { | ||
"description" : "English", | ||
"twoLetterCode" : "en", | ||
"threeLetterCode" : "eng" | ||
} ] | ||
} |
9 changes: 9 additions & 0 deletions
9
src/test/resources/eforms-sdk-tests/tedefo-3877/valid/translations/view_en.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | ||
<properties> | ||
<comment>view in English. File generated from metadata database.</comment> | ||
<entry key="view|name|1">View template for notice subtype 1</entry> | ||
<entry key="view|name|2">View template for notice subtype 2</entry> | ||
<entry key="view|name|3">View template for notice subtype 3</entry> | ||
<entry key="view|name|summary">View template for notice summary</entry> | ||
</properties> |
33 changes: 33 additions & 0 deletions
33
src/test/resources/eforms-sdk-tests/tedefo-3877/valid/view-templates/view-templates.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"ublVersion" : "2.3", | ||
"sdkVersion" : "1.6.0", | ||
"metadataDatabase" : { | ||
"version" : "1.5.29", | ||
"createdOn" : "2023-01-24T11:03:12" | ||
}, | ||
"viewTemplates" : [ { | ||
"id" : "1", | ||
"filename" : "1.efx", | ||
"description" : "Default", | ||
"_noticeSubtypeIds" : [ "1" ], | ||
"_label" : "view|name|1" | ||
}, { | ||
"id" : "2", | ||
"filename" : "2.efx", | ||
"description" : "Default", | ||
"_noticeSubtypeIds" : [ "2" ], | ||
"_label" : "view|name|2" | ||
}, { | ||
"id" : "3", | ||
"filename" : "3.efx", | ||
"description" : "Default", | ||
"_noticeSubtypeIds" : [ "3" ], | ||
"_label" : "view|name|3" | ||
} , { | ||
"id" : "summary", | ||
"filename" : "summary.efx", | ||
"description" : "The summary view works for all notices", | ||
"_noticeSubtypeIds" : [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "CEI", "T01", "T02", "X01", "X02" ], | ||
"_label" : "view|name|summary" | ||
} ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/test/resources/eu/europa/ted/eforms/sdk/analysis/cucumber/tedefo-3877.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@tedefo-3877 | ||
Feature: View Templates Index - Labels validation | ||
TEDEFO-3877: Τhe labels referenced in the view-templates.json file should exist | ||
Test files under under "src/test/resources/eforms-sdk-tests/tedefo-3877" | ||
|
||
Background: | ||
Given The following rules | ||
| View templates index references existing labels | | ||
|
||
Scenario: All referenced labels exist | ||
Given A "tedefo-3877" folder with "valid" files | ||
When I load the view templates index | ||
And I load all labels | ||
And I execute validation | ||
Then I should get 0 SDK validation errors | ||
|
||
Scenario Outline: Some referenced labels do not exist | ||
Given A "tedefo-3877" folder with "invalid" files | ||
When I load the view templates index | ||
And I load all labels | ||
And I execute validation | ||
Then Rule "<expected rule>" should have been fired | ||
Then I should get 2 SDK validation errors | ||
|
||
Examples: | ||
| expected rule | | ||
| View templates index references existing labels | |