Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
GtanSndil committed Dec 16, 2024
1 parent cfe44f9 commit 62b398a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ void getAllCodesLists_shouldReturnList() throws RmesException, JsonProcessingExc

@Test
void getCodesListWithCodeWithStatutValidation_shouldReturnExpectedCodeList() throws RmesException, JsonProcessingException {
JSONObject mockJSON_requete1 = new JSONObject(CodeListUtilsTest.CODELIST_WITH_STATUT_VALIDATION);
JSONArray mockJSON_requete2 = new JSONArray(CodeListUtilsTest.CODES);
JSONArray mockJSON_requete3 = new JSONArray(ResponseUtilsTest.EMPTY_JSON_ARRAY);
JSONObject mockJSON1 = new JSONObject(CodeListUtilsTest.CODELIST_WITH_STATUT_VALIDATION);
JSONArray mockJSON2 = new JSONArray(CodeListUtilsTest.CODES);
JSONArray mockJSON3 = new JSONArray(ResponseUtilsTest.EMPTY_JSON_ARRAY);
String mockString = new String(CodeListUtilsTest.CODELIST_GRAPH);
JSONArray mockJSON_requete4 = new JSONArray(ResponseUtilsTest.EMPTY_JSON_ARRAY);
when(repoGestion.getResponseAsObject("getCodesList.ftlh")).thenReturn(mockJSON_requete1);
when(repoGestion.getResponseAsArray("getCodes.ftlh")).thenReturn(mockJSON_requete2);
when(repoGestion.getResponseAsArray("getCodeLevel.ftlh")).thenReturn(mockJSON_requete3);
JSONArray mockJSON4 = new JSONArray(ResponseUtilsTest.EMPTY_JSON_ARRAY);
when(repoGestion.getResponseAsObject("getCodesList.ftlh")).thenReturn(mockJSON1);
when(repoGestion.getResponseAsArray("getCodes.ftlh")).thenReturn(mockJSON2);
when(repoGestion.getResponseAsArray("getCodeLevel.ftlh")).thenReturn(mockJSON3);
when(config.getCodelistGraph()).thenReturn(mockString);
when(repoGestion.getResponseAsArray("getMatch.ftlh")).thenReturn(mockJSON_requete4);
when(repoGestion.getResponseAsArray("getMatch.ftlh")).thenReturn(mockJSON4);
assertThat(MAPPER.readTree(codeListImpl.getCodesList("1"))).isEqualTo(MAPPER.readTree(CodeListUtilsTest.CODELIST_WITH_STATUT_VALIDATION_EXPECTED.toString()));
}

Expand Down Expand Up @@ -120,6 +120,6 @@ void getCodesListForDatasetTest() throws RmesException, JsonProcessingException
when(repoGestion.getResponseAsObject("getCodesListForDataset.ftlh")).thenReturn(mockJSON1);
when(repoGestion.getResponseAsArray("getCodes.ftlh")).thenReturn(mockJSON2);
when(repoGestion.getResponseAsArray("getCodeLevel.ftlh")).thenReturn(mockJSON2);
assertThat(MAPPER.readTree(codeListImpl.getCodesListForDataset("1"))).isEqualTo(MAPPER.readTree(CodeListUtilsTest.CODES_FOR_DATASET_EXPECTED.toString()));
assertThat(MAPPER.readTree(codeListImpl.getCodesListForDataset("1"))).isEqualTo(MAPPER.readTree(CodeListUtilsTest.CODES_FOR_DATASET_EXPECTED));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,5 @@ public class CodeListUtilsTest {
""";
public static final String CODES = "[{\"code\":\"B\",\"prefLabelLg1\":\"Quotidienne \\u2013 jours ouvrés\",\"prefLabelLg2\":\"Quotidienne \\u2013 jours ouvrés\",\"uri\":\"http://bauhaus/codes/frequence/B\"},{\"code\":\"Q\",\"prefLabelLg1\":\"Trimestrielle\",\"prefLabelLg2\":\"Trimestrielle\",\"uri\":\"http://bauhaus/codes/frequence/Q\"},{\"code\":\"L\",\"prefLabelLg1\":\"Infra-annuelle\",\"prefLabelLg2\":\"Infra-annuelle\",\"uri\":\"http://bauhaus/codes/frequence/L\"},{\"code\":\"A\",\"prefLabelLg1\":\"Annuelle\",\"prefLabelLg2\":\"Annuelle\",\"uri\":\"http://bauhaus/codes/frequence/A\"},{\"code\":\"M\",\"prefLabelLg1\":\"Mensuelle\",\"prefLabelLg2\":\"Mensuelle\",\"uri\":\"http://bauhaus/codes/frequence/M\"},{\"code\":\"S\",\"prefLabelLg1\":\"Semestrielle\",\"prefLabelLg2\":\"Semestrielle\",\"uri\":\"http://bauhaus/codes/frequence/S\"},{\"code\":\"P\",\"prefLabelLg1\":\"Ponctuelle ou apériodique\",\"prefLabelLg2\":\"Ponctuelle ou apériodique\",\"uri\":\"http://bauhaus/codes/frequence/P\"},{\"code\":\"I\",\"prefLabelLg1\":\"Bisannuelle\",\"prefLabelLg2\":\"Bisannuelle\",\"uri\":\"http://bauhaus/codes/frequence/I\"},{\"code\":\"N\",\"prefLabelLg1\":\"Toutes les minutes\",\"prefLabelLg2\":\"Toutes les minutes\",\"uri\":\"http://bauhaus/codes/frequence/N\"},{\"code\":\"C\",\"prefLabelLg1\":\"Continue\",\"prefLabelLg2\":\"Continue\",\"uri\":\"http://bauhaus/codes/frequence/C\"},{\"code\":\"T\",\"prefLabelLg1\":\"Bimestrielle\",\"prefLabelLg2\":\"Bimestrielle\",\"uri\":\"http://bauhaus/codes/frequence/T\"},{\"code\":\"W\",\"prefLabelLg1\":\"Hebdomadaire\",\"prefLabelLg2\":\"Hebdomadaire\",\"uri\":\"http://bauhaus/codes/frequence/W\"},{\"code\":\"D\",\"prefLabelLg1\":\"Quotidienne\",\"prefLabelLg2\":\"Quotidienne\",\"uri\":\"http://bauhaus/codes/frequence/D\"},{\"code\":\"H\",\"prefLabelLg1\":\"Toutes les heures\",\"prefLabelLg2\":\"Toutes les heures\",\"uri\":\"http://bauhaus/codes/frequence/H\"},{\"code\":\"U\",\"prefLabelLg1\":\"Pluriannuelle\",\"prefLabelLg2\":\"Pluriannuelle\",\"uri\":\"http://bauhaus/codes/frequence/U\"},{\"code\":\"A3\",\"prefLabelLg1\":\"Triannuelle\",\"prefLabelLg2\":\"Triannuelle\",\"uri\":\"http://bauhaus/codes/frequence/A3\"}]";
public static final String CODES_FOR_DATASET_EXPECTED = "{\"codes\":[],\"statutValidation\":\"Provisoire, jamais publiée\",\"id\":\"CL_TEST\",\"label\":[{\"langue\":\"fr\",\"contenu\":\"Fréquence\"},{\"langue\":\"en\",\"contenu\":\"Frequency\"}]}";
// public static final String MATCH = "[{\"match\":\"1\", \"matchNotation\":\"1\"}]";
public static final String EMPTY_ARRAY = "[]";
}

0 comments on commit 62b398a

Please sign in to comment.