Skip to content

Commit

Permalink
refactor(test): validator-plugin-dgpr - update model using a JSON mod…
Browse files Browse the repository at this point in the history
…el for tests (refs #351)
  • Loading branch information
mborne committed Aug 8, 2024
1 parent b06d637 commit ed23bdf
Show file tree
Hide file tree
Showing 55 changed files with 2,876 additions and 2,125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import fr.ign.validator.dgpr.error.DgprErrorCodes;
import fr.ign.validator.error.CoreErrorCodes;
import fr.ign.validator.error.ValidatorError;
import fr.ign.validator.io.JsonModelReader;
import fr.ign.validator.io.ModelReader;
import fr.ign.validator.io.XmlModelReader;
import fr.ign.validator.model.DocumentModel;
import fr.ign.validator.plugin.PluginManager;
import fr.ign.validator.report.InMemoryReportBuilder;
Expand Down Expand Up @@ -57,9 +57,9 @@ private Context createContext(File documentPath) throws Exception {

private DocumentModel getDocumentModel(String documentModelName) throws Exception {
File documentModelPath = new File(
getClass().getResource("/config/" + documentModelName + "/files.xml").getPath()
getClass().getResource("/config/" + documentModelName + "/files.json").getPath()
);
ModelReader loader = new XmlModelReader();
ModelReader loader = new JsonModelReader();
DocumentModel documentModel = loader.loadDocumentModel(documentModelPath);
documentModel.setName(documentModelName);
return documentModel;
Expand Down Expand Up @@ -224,18 +224,14 @@ public void testDocumentNotOk() throws Exception {
/*
* Validation unicite et relation
*/
Assert.assertEquals(2, report.getErrorsByCode(CoreErrorCodes.ATTRIBUTE_NOT_UNIQUE).size());
Assert.assertEquals(1, report.getErrorsByCode(CoreErrorCodes.ATTRIBUTE_NOT_UNIQUE).size());
ValidatorError error50 = report.getErrorsByCode(CoreErrorCodes.ATTRIBUTE_NOT_UNIQUE).get(0);
ValidatorError error51 = report.getErrorsByCode(CoreErrorCodes.ATTRIBUTE_NOT_UNIQUE).get(1);
Assert.assertEquals(
"La valeur 'ZE_2' est présente 2 fois pour le champ 'ID_ZONE' de la table 'N_prefixTri_ECOUL_S_ddd'.",
error50
.getMessage()
);
Assert.assertEquals(
"La valeur 'SIEXT' est présente 2 fois pour le champ 'ID_SI_EXT' de la table 'N_prefixTri_ENJEU_CRISE_L_ddd'.",
error51.getMessage()
);


Assert.assertEquals(5, report.getErrorsByCode(CoreErrorCodes.ATTRIBUTE_REFERENCE_NOT_FOUND).size());
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
{
"id": "48cbe0573f476664353c7bd681f5f2e6",
"name": "covadis_di_2018",
"title": "covadis_di_2018",
"constraints": {
"folderName": "covadis_di_2018"
},
"files": [
{
"id": "0e7c86cd915a7415cefc53ea9a407c6f",
"name": "N_prefixTri_CARTE_INOND_S_ddd",
"path": "N_.*_CARTE_INOND_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "ERROR",
"tableModel": "./types/N_prefixTri_CARTE_INOND_S_ddd.json"
},
{
"id": "7c97fa921538c84cc7fbd91438c6bba1",
"name": "N_prefixTri_CARTE_RISQ_S_ddd",
"path": "N_.*_CARTE_RISQ_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "ERROR",
"tableModel": "./types/N_prefixTri_CARTE_RISQ_S_ddd.json"
},
{
"id": "6e52a672e8fdcdd94bb05c5348b50a0d",
"name": "N_prefixTri_CHAMP_VIT_P_ddd",
"path": "N_.*_CHAMP_VIT_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_CHAMP_VIT_P_ddd.json"
},
{
"id": "3a4280fa81164b503e34c18ad27ea983",
"name": "N_prefixTri_COMMUNE_S_ddd",
"path": "N_.*_COMMUNE_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "ERROR",
"tableModel": "./types/N_prefixTri_COMMUNE_S_ddd.json"
},
{
"id": "5f6a3a2ddcf817c2ad6fa011a19086ef",
"name": "N_prefixTri_COTE_VIT_DEB_P_ddd",
"path": "N_.*_COTE_VIT_DEB_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_COTE_VIT_DEB_P_ddd.json"
},
{
"id": "cdebef0459bb55ea438eaabd81507042",
"name": "N_prefixTri_ECOUL_S_ddd",
"path": "N_.*_ECOUL_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ECOUL_S_ddd.json"
},
{
"id": "021c6604a641341149e735fc5a8effe9",
"name": "N_prefixTri_ENJEU_CRISE_L_ddd",
"path": "N_.*_ENJEU_CRISE_L_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_CRISE_L_ddd.json"
},
{
"id": "d9eed1c0ac1e5fe34707b8f27a009e1b",
"name": "N_prefixTri_ENJEU_CRISE_P_ddd",
"path": "N_.*_ENJEU_CRISE_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_CRISE_P_ddd.json"
},
{
"id": "bd0ec953d2abdef1f6b1162317ff455e",
"name": "N_prefixTri_ENJEU_DCE_S_ddd",
"path": "N_.*_ENJEU_DCE_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_DCE_S_ddd.json"
},
{
"id": "a7e563e428d621dcff52a9be7f632dfb",
"name": "N_prefixTri_ENJEU_ECO_S_ddd",
"path": "N_.*_ENJEU_ECO_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_ECO_S_ddd.json"
},
{
"id": "73aff52a9bbf6ae952e8558551c3d6a9",
"name": "N_prefixTri_ENJEU_IED_P_ddd",
"path": "N_.*_ENJEU_IED_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_IED_P_ddd.json"
},
{
"id": "b6994affac1341487569541b0f17a5d0",
"name": "N_prefixTri_ENJEU_IPPC_P_ddd",
"path": "N_.*_ENJEU_IPPC_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_IPPC_P_ddd.json"
},
{
"id": "6c6d5bad08e5f02b5751a0e3d2b04e82",
"name": "N_prefixTri_ENJEU_PATRIM_P_ddd",
"path": "N_.*_ENJEU_PATRIM_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_PATRIM_P_ddd.json"
},
{
"id": "2020f026513bae8cc51a0b968cb84c17",
"name": "N_prefixTri_ENJEU_PATRIM_S_ddd",
"path": "N_.*_ENJEU_PATRIM_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_PATRIM_S_ddd.json"
},
{
"id": "857dd96adbd090301e82c842120c99a5",
"name": "N_prefixTri_ENJEU_RAPPORT_ddd",
"path": "N_.*_ENJEU_RAPPORT_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "ERROR",
"tableModel": "./types/N_prefixTri_ENJEU_RAPPORT_ddd.json"
},
{
"id": "2234886dac757579eef0a63242009ba2",
"name": "N_prefixTri_ENJEU_STEU_P_ddd",
"path": "N_.*_ENJEU_STEU_P_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ENJEU_STEU_P_ddd.json"
},
{
"id": "1e2cafc2097fb78aa2d537a37710e651",
"name": "N_prefixTri_INONDABLE_suffixInond_S_ddd",
"path": "N_.*_INONDABLE.{0,20}_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "ERROR",
"tableModel": "./types/N_prefixTri_INONDABLE_suffixInond_S_ddd.json"
},
{
"id": "697103129ce2c43441108a1a24c3fe2c",
"name": "N_prefixTri_ISO_COTE_L_ddd",
"path": "N_.*_ISO_COTE_L_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ISO_COTE_L_ddd.json"
},
{
"id": "3a2919cd29f71c7bd128338d81e673e9",
"name": "N_prefixTri_ISO_DEB_S_ddd",
"path": "N_.*_ISO_DEB_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ISO_DEB_S_ddd.json"
},
{
"id": "2e6ba626adad1741fa1c93a1bce976e8",
"name": "N_prefixTri_ISO_HT_suffixIsoHt_S_ddd",
"path": "N_.*_ISO_HT.{0,20}_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "WARN",
"tableModel": "./types/N_prefixTri_ISO_HT_suffixIsoHt_S_ddd.json"
},
{
"id": "cea63601540c8f2efe96a0cdce2a87fc",
"name": "N_prefixTri_OUV_PROTEC_L_ddd",
"path": "N_.*_OUV_PROTEC_L_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_OUV_PROTEC_L_ddd.json"
},
{
"id": "4c35064b6f886e6be9cbb5a2bcfc790e",
"name": "N_prefixTri_QUARTIER_S_ddd",
"path": "N_.*_QUARTIER_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_QUARTIER_S_ddd.json"
},
{
"id": "272aca26b80f291e7619b676b67d2090",
"name": "N_prefixTri_REL_HYDRO_INOND_ddd",
"path": "N_.*_REL_HYDRO_INOND_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_REL_HYDRO_INOND_ddd.json"
},
{
"id": "d8bb8e3af88bc50545c31e93245c412f",
"name": "N_prefixTri_SOUST_INOND_S_ddd",
"path": "N_.*_SOUST_INOND_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_SOUST_INOND_S_ddd.json"
},
{
"id": "08651fdaeca64491459a6b84c2bc7ed3",
"name": "N_prefixTri_SURALEA_S_ddd",
"path": "N_.*_SURALEA_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_SURALEA_S_ddd.json"
},
{
"id": "78025b58452cdde41cb38b9c862f40e2",
"name": "N_prefixTri_TRI_S_ddd",
"path": "N_.*_TRI_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "ERROR",
"tableModel": "./types/N_prefixTri_TRI_S_ddd.json"
},
{
"id": "ea8bfabc1da69aed45cb8766cde19c62",
"name": "N_prefixTri_ZONE_PROTEG_S_ddd",
"path": "N_.*_ZONE_PROTEG_S_([0-9]{3}|02[aA]|02[bB])",
"type": "table",
"mandatory": "OPTIONAL",
"tableModel": "./types/N_prefixTri_ZONE_PROTEG_S_ddd.json"
},
{
"id": "f107d77b75049a44284d3a0f6d6e411f",
"name": "prefixTri_SIG_DI",
"description": "repertoire",
"path": ".*_SIG_DI",
"type": "directory",
"mandatory": "OPTIONAL"
}
],
"codes": []
}
Loading

0 comments on commit ed23bdf

Please sign in to comment.