1414import org .junit .jupiter .api .Test ;
1515import org .junit .jupiter .params .ParameterizedTest ;
1616import org .junit .jupiter .params .provider .ValueSource ;
17+ import org .springframework .http .ResponseEntity ;
1718import org .springframework .util .FileSystemUtils ;
1819
1920import java .io .IOException ;
@@ -56,7 +57,7 @@ void readJson_sourceState(String sourceState){
5657 testOKCase (sourceState );
5758 }
5859
59- private void testOKCase (String sourceState ) throws GenesisException , IOException {
60+ private void testOKCase (String sourceState ) throws IOException {
6061 //GIVEN
6162 Files .createDirectories (SOURCE_PATH );
6263 Files .copy (
@@ -217,9 +218,19 @@ void readJson_override_interrogation_id(){
217218 @ ValueSource (strings = {"ceci est une origine beaucoup trop longue" })
218219 @ SneakyThrows
219220 void readJson_sourceState_too_long (String sourceState ){
220- GenesisException genesisException = Assertions .catchThrowableOfType (GenesisException .class , ()->
221- testOKCase (sourceState ));
222- Assertions .assertThat (genesisException .getStatus ()).isEqualTo (400 );
221+ //GIVEN
222+ String fileName = "ok.json" ;
223+ Files .createDirectories (SOURCE_PATH );
224+ Files .copy (
225+ Path .of (TestConstants .TEST_RESOURCES_DIRECTORY ).resolve ("edited_previous" ).resolve (fileName ),
226+ SOURCE_PATH .resolve (fileName ),
227+ StandardCopyOption .REPLACE_EXISTING
228+ );
229+
230+ //WHEN + THEN
231+ ResponseEntity <Object > response = editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , sourceState ,
232+ fileName );
233+ Assertions .assertThat (response .getStatusCode ().value ()).isEqualTo (400 );
223234 }
224235
225236 @ Test
@@ -235,9 +246,8 @@ void readJson_invalid_syntax(){
235246 );
236247
237248 //WHEN + THEN
238- GenesisException genesisException = Assertions .catchThrowableOfType (GenesisException .class , ()->
239- editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , syntaxErrorFileName ));
240- Assertions .assertThat (genesisException .getStatus ()).isEqualTo (400 );
249+ ResponseEntity <Object > response = editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , syntaxErrorFileName );
250+ Assertions .assertThat (response .getStatusCode ().value ()).isEqualTo (400 );
241251 }
242252 @ Test
243253 @ SneakyThrows
@@ -252,9 +262,8 @@ void readJson_not_a_json(){
252262 );
253263
254264 //WHEN + THEN
255- GenesisException genesisException = Assertions .catchThrowableOfType (GenesisException .class , ()->
256- editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , syntaxErrorFileName ));
257- Assertions .assertThat (genesisException .getStatus ()).isEqualTo (400 );
265+ ResponseEntity <Object > response = editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , syntaxErrorFileName );
266+ Assertions .assertThat (response .getStatusCode ().value ()).isEqualTo (400 );
258267 }
259268
260269 @ Test
@@ -270,9 +279,8 @@ void readJson_no_interrogation_id(){
270279 );
271280
272281 //WHEN + THEN
273- GenesisException genesisException = Assertions .catchThrowableOfType (GenesisException .class , ()->
274- editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , fileName ));
275- Assertions .assertThat (genesisException .getStatus ()).isEqualTo (400 );
282+ ResponseEntity <Object > response = editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , fileName );
283+ Assertions .assertThat (response .getStatusCode ().value ()).isEqualTo (400 );
276284 }
277285 @ Test
278286 @ SneakyThrows
@@ -287,9 +295,8 @@ void readJson_only_one_interrogation_id(){
287295 );
288296
289297 //WHEN + THEN
290- GenesisException genesisException = Assertions .catchThrowableOfType (GenesisException .class , ()->
291- editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , fileName ));
292- Assertions .assertThat (genesisException .getStatus ()).isEqualTo (400 );
298+ ResponseEntity <Object > response = editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , fileName );
299+ Assertions .assertThat (response .getStatusCode ().value ()).isEqualTo (400 );
293300 }
294301
295302 @ Test
@@ -305,9 +312,8 @@ void readJson_double_interrogation_id(){
305312 );
306313
307314 //WHEN + THEN
308- GenesisException genesisException = Assertions .catchThrowableOfType (GenesisException .class , ()->
309- editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , fileName ));
310- Assertions .assertThat (genesisException .getStatus ()).isEqualTo (400 );
315+ ResponseEntity <Object > response = editedPreviousResponseController .readJson (QUESTIONNAIRE_ID , Mode .WEB , null , fileName );
316+ Assertions .assertThat (response .getStatusCode ().value ()).isEqualTo (400 );
311317 }
312318
313319 //UTILS
0 commit comments