@@ -110,7 +110,7 @@ void invalidPlanId() {
110110 .toString ();
111111 final var response = request .post ("/getSimulationResults" , RequestOptions .create ().setData (data ));
112112 assertEquals (404 , response .status ());
113- assertEquals ("no such plan" , getBody (response ).getString ("message" ));
113+ assertEquals ("No plan exists with id `-1` " , getBody (response ).getString ("message" ));
114114 }
115115
116116 @ Test
@@ -184,7 +184,6 @@ class ResourceSamples {
184184 @ Test
185185 void invalidPlanId () {
186186 // Returns a 404 if the PlanId is invalid
187- // message is "no such plan"
188187 final String data = Json .createObjectBuilder ()
189188 .add ("action" , Json .createObjectBuilder ().add ("name" , "resource_samples" ))
190189 .add ("input" , Json .createObjectBuilder ().add ("planId" , -1 ))
@@ -194,7 +193,7 @@ void invalidPlanId() {
194193 .toString ();
195194 final var response = request .post ("/resourceSamples" , RequestOptions .create ().setData (data ));
196195 assertEquals (404 , response .status ());
197- assertEquals ("no such plan" , getBody (response ).getString ("message" ));
196+ assertEquals ("No plan exists with id `-1` " , getBody (response ).getString ("message" ));
198197 }
199198
200199 @ Test
@@ -259,13 +258,12 @@ void invalidPlanId() {
259258 .toString ();
260259 final var response = request .post ("/constraintViolations" , RequestOptions .create ().setData (data ));
261260 assertEquals (404 , response .status ());
262- assertEquals ("no such plan" , getBody (response ).getString ("message" ));
261+ assertEquals ("No plan exists with id `-1` " , getBody (response ).getString ("message" ));
263262 }
264263
265264 @ Test
266265 void invalidSimDatasetId () throws IOException {
267266 // Returns a 404 if the SimDatasetId is invalid
268- // Message is an "input mismatch exception"
269267 hasura .awaitSimulation (planId );
270268 final String data = Json .createObjectBuilder ()
271269 .add ("action" , Json .createObjectBuilder ().add ("name" , "check_constraints" ))
@@ -279,15 +277,17 @@ void invalidSimDatasetId() throws IOException {
279277 .toString ();
280278 final var response = request .post ("/constraintViolations" , RequestOptions .create ().setData (data ));
281279 assertEquals (404 , response .status ());
282- final var expectedResponse = Json .createObjectBuilder ()
283- .add ("message" , "input mismatch exception" )
284- .add (
285- "extensions" , Json .createObjectBuilder ()
286- .add (
287- "cause" ,
288- "simulation dataset with id `-1` does not exist" ))
289- .build ();
290- assertEquals (expectedResponse , getBody (response ));
280+
281+ final var body = getBody (response );
282+ final var extensions = body .getJsonObject ("extensions" );
283+ // Check the message field
284+ final var expectedMessage = "simulation dataset with id `-1` does not exist" ;
285+ assertEquals (expectedMessage , body .getString ("message" ));
286+
287+ // Check the extensions
288+ assertEquals ("INPUT_MISMATCH_EXCEPTION" , extensions .getString ("type" ));
289+ assertEquals (expectedMessage , extensions .getString ("message" ));
290+ assertEquals ("aerie_merlin" , extensions .getString ("service" ));
291291 }
292292
293293 @ Test
@@ -303,7 +303,6 @@ void incorrectSimDatasetId() throws IOException {
303303 final int simDatasetId = hasura .awaitSimulation (secondPlanId ).simDatasetId ();
304304
305305 // Returns a 404 because the simDataset belonged to a different plan
306- // Message is 'simulation dataset mismatch exception'
307306 final String data = Json .createObjectBuilder ()
308307 .add ("action" , Json .createObjectBuilder ().add ("name" , "check_constraints" ))
309308 .add (
@@ -316,13 +315,19 @@ void incorrectSimDatasetId() throws IOException {
316315 .toString ();
317316 final var response = request .post ("/constraintViolations" , RequestOptions .create ().setData (data ));
318317 assertEquals (404 , response .status ());
319- final var expectedCause =
320- "Simulation Dataset with id `" + simDatasetId + "` does not belong to Plan with id `" + planId + "`" ;
321- final var expectedResponse = Json .createObjectBuilder ()
322- .add ("message" , "simulation dataset mismatch exception" )
323- .add ("extensions" , Json .createObjectBuilder ().add ("cause" , expectedCause ))
324- .build ();
325- assertEquals (expectedResponse , getBody (response ));
318+
319+ // Check the response
320+ final var body = getBody (response );
321+ final var extensions = body .getJsonObject ("extensions" );
322+
323+ // Check the message field
324+ final var expectedMessage = "Simulation Dataset with id `" + simDatasetId + "` does not belong to Plan with id `" + planId + "`" ;
325+ assertEquals (expectedMessage , body .getString ("message" ));
326+
327+ // Check the extensions object
328+ assertEquals ("SIM_DATASET_MISMATCH_EXCEPTION" , extensions .getString ("type" ));
329+ assertEquals (expectedMessage , extensions .getString ("message" ));
330+ assertEquals ("aerie_merlin" , extensions .getString ("service" ));
326331 } finally {
327332 hasura .deletePlan (secondPlanId );
328333 }
@@ -358,12 +363,19 @@ void noSimDatasets() {
358363 .toString ();
359364 final var response = request .post ("/constraintViolations" , RequestOptions .create ().setData (data ));
360365 assertEquals (404 , response .status ());
361- final var expectedCause = "plan with id " + planId + " has not yet been simulated at its current revision" ;
362- final var expectedBody = Json .createObjectBuilder ()
363- .add ("message" , "input mismatch exception" )
364- .add ("extensions" , Json .createObjectBuilder ().add ("cause" , expectedCause ))
365- .build ();
366- assertEquals (expectedBody , getBody (response ));
366+
367+ // Check the response
368+ final var body = getBody (response );
369+ final var extensions = body .getJsonObject ("extensions" );
370+
371+ // Check the message field
372+ final var expectedMessage = "plan with id " + planId + " has not yet been simulated at its current revision" ;
373+ assertEquals (expectedMessage , body .getString ("message" ));
374+
375+ // Check the extensions object
376+ assertEquals ("INPUT_MISMATCH_EXCEPTION" , extensions .getString ("type" ));
377+ assertEquals (expectedMessage , extensions .getString ("message" ));
378+ assertEquals ("aerie_merlin" , extensions .getString ("service" ));
367379 }
368380
369381 @ Test
@@ -434,7 +446,7 @@ void invalidMissionModelId() {
434446 .toString ();
435447 final var response = request .post ("/refreshModelParameters" , RequestOptions .create ().setData (data ));
436448 assertEquals (404 , response .status ());
437- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
449+ assertEquals ("No mission model exists with id `-1` " , getBody (response ).getString ("message" ));
438450 }
439451
440452 @ Test
@@ -474,7 +486,7 @@ void invalidMissionModelId() {
474486 .toString ();
475487 final var response = request .post ("/refreshActivityTypes" , RequestOptions .create ().setData (data ));
476488 assertEquals (404 , response .status ());
477- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
489+ assertEquals ("No mission model exists with id `-1` " , getBody (response ).getString ("message" ));
478490 }
479491
480492 @ Test
@@ -502,7 +514,6 @@ class RefreshResourceTypes {
502514 @ Test
503515 void invalidMissionModelId () {
504516 // Returns a 404 if the MissionModelId is invalid
505- // message is "no such mission model"
506517 final String data = Json .createObjectBuilder ()
507518 .add (
508519 "event" , Json .createObjectBuilder ()
@@ -514,7 +525,7 @@ void invalidMissionModelId() {
514525 .toString ();
515526 final var response = request .post ("/refreshResourceTypes" , RequestOptions .create ().setData (data ));
516527 assertEquals (404 , response .status ());
517- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
528+ assertEquals ("No mission model exists with id `-1` " , getBody (response ).getString ("message" ));
518529 }
519530
520531 @ Test
@@ -542,7 +553,6 @@ class ValidateActivityArguments {
542553 @ Test
543554 void invalidMissionModelId () {
544555 // Returns a 404 if the MissionModelId is invalid
545- // message is "no such mission model"
546556 final String data = Json .createObjectBuilder ()
547557 .add ("action" , Json .createObjectBuilder ().add ("name" , "validateActivityArguments" ))
548558 .add (
@@ -556,7 +566,10 @@ void invalidMissionModelId() {
556566 .toString ();
557567 final var response = request .post ("/validateActivityArguments" , RequestOptions .create ().setData (data ));
558568 assertEquals (404 , response .status ());
559- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
569+ final var body = getBody (response );
570+ assertEquals ("No mission model exists with id `-1`" , body .getString ("message" ));
571+ assertTrue (body .containsKey ("extensions" ));
572+ assertEquals ("NO_SUCH_MISSION_MODEL" , body .getJsonObject ("extensions" ).getString ("type" ));
560573 }
561574
562575 @ Test
@@ -585,7 +598,6 @@ class ValidateModelArguments {
585598 @ Test
586599 void invalidMissionModelId () {
587600 // Returns a 404 if the MissionModelId is invalid
588- // message is "no such mission model"
589601 final String data = Json .createObjectBuilder ()
590602 .add ("action" , Json .createObjectBuilder ().add ("name" , "validateModelArguments" ))
591603 .add (
@@ -598,7 +610,7 @@ void invalidMissionModelId() {
598610 .toString ();
599611 final var response = request .post ("/validateModelArguments" , RequestOptions .create ().setData (data ));
600612 assertEquals (404 , response .status ());
601- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
613+ assertEquals ("No mission model exists with id `-1` " , getBody (response ).getString ("message" ));
602614 }
603615
604616 @ Test
@@ -636,7 +648,7 @@ void invalidPlanId() {
636648 .toString ();
637649 final var response = request .post ("/validatePlan" , RequestOptions .create ().setData (data ));
638650 assertEquals (404 , response .status ());
639- assertEquals ("no such plan" , getBody (response ).getString ("message" ));
651+ assertEquals ("No plan exists with id `-1` " , getBody (response ).getString ("message" ));
640652 }
641653
642654 @ Test
@@ -674,7 +686,7 @@ void invalidMissionModelId() {
674686 .toString ();
675687 final var response = request .post ("/getModelEffectiveArguments" , RequestOptions .create ().setData (data ));
676688 assertEquals (404 , response .status ());
677- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
689+ assertEquals ("No mission model exists with id `-1` " , getBody (response ).getString ("message" ));
678690 }
679691
680692 @ Test
@@ -733,7 +745,7 @@ void invalidMissionModelId() {
733745 .toString ();
734746 final var response = request .post ("/getActivityEffectiveArgumentsBulk" , RequestOptions .create ().setData (data ));
735747 assertEquals (404 , response .status ());
736- assertEquals ("no such mission model" , getBody (response ).getString ("message" ));
748+ assertEquals ("No mission model exists with id `-1` " , getBody (response ).getString ("message" ));
737749 }
738750
739751 @ Test
@@ -818,7 +830,7 @@ void invalidPlanId() {
818830 .toString ();
819831 final var response = request .post ("/addExternalDataset" , RequestOptions .create ().setData (data ));
820832 assertEquals (404 , response .status ());
821- assertEquals ("no such plan" , getBody (response ).getString ("message" ));
833+ assertEquals ("No plan exists with id `-1` " , getBody (response ).getString ("message" ));
822834 }
823835
824836 @ Test
@@ -885,7 +897,7 @@ void invalidDatasetId() {
885897 .toString ();
886898 final var response = request .post ("/extendExternalDataset" , RequestOptions .create ().setData (data ));
887899 assertEquals (404 , response .status ());
888- assertEquals ("no such plan dataset" , getBody (response ).getString ("message" ));
900+ assertEquals ("No plan dataset exists with id `-1` " , getBody (response ).getString ("message" ));
889901 }
890902
891903 @ Test
0 commit comments