@@ -435,7 +435,7 @@ public void invokeHandler_InProgress_returnsInProgress(final String requestDataP
435435 @ ParameterizedTest
436436 @ CsvSource ({ "create.with-callback-context.request.json,CREATE" , "update.with-callback-context.request.json,UPDATE" ,
437437 "delete.with-callback-context.request.json,DELETE" })
438- public void reInvokeHandler_InProgress_returnsInProgress (final String requestDataPath , final String actionAsString )
438+ public void reInvokeHandler_InProgress_returnsInProgressWithContext (final String requestDataPath , final String actionAsString )
439439 throws IOException {
440440 final Action action = Action .valueOf (actionAsString );
441441 final TestModel model = TestModel .builder ().property1 ("abc" ).property2 (123 ).build ();
@@ -445,8 +445,55 @@ public void reInvokeHandler_InProgress_returnsInProgress(final String requestDat
445445 // interval >= 1 minute is scheduled
446446 // against CloudWatch. Shorter intervals are able to run locally within same
447447 // function context if runtime permits
448- final ProgressEvent <TestModel , TestContext > pe = ProgressEvent .<TestModel , TestContext >builder ()
449- .status (OperationStatus .IN_PROGRESS ).callbackDelaySeconds (60 ).resourceModel (model ).build ();
448+ final ProgressEvent <TestModel ,
449+ TestContext > pe = ProgressEvent .<TestModel , TestContext >builder ().status (OperationStatus .IN_PROGRESS )
450+ .callbackDelaySeconds (60 ).resourceModel (model )
451+ .callbackContext (TestContext .builder ().contextPropertyA ("Value" ).build ()).build ();
452+ wrapper .setInvokeHandlerResponse (pe );
453+
454+ wrapper .setTransformResponse (resourceHandlerRequest );
455+
456+ try (final InputStream in = loadRequestStream (requestDataPath ); final OutputStream out = new ByteArrayOutputStream ()) {
457+ wrapper .processRequest (in , out );
458+
459+ // verify initialiseRuntime was called and initialised dependencies
460+ verifyInitialiseRuntime ();
461+
462+ // all metrics should be published, once for a single invocation
463+ verify (providerMetricsPublisher ).publishInvocationMetric (any (Instant .class ), eq (action ));
464+ verify (providerMetricsPublisher ).publishDurationMetric (any (Instant .class ), eq (action ), anyLong ());
465+ verify (providerMetricsPublisher ).publishExceptionByErrorCodeAndCountBulkMetrics (any (Instant .class ), eq (action ),
466+ any ());
467+
468+ // validation failure metric should not be published
469+ verifyNoMoreInteractions (providerMetricsPublisher );
470+
471+ // verify that NO model validation occurred for CREATE/UPDATE
472+ verifyNoMoreInteractions (validator );
473+
474+ // verify output response
475+ verifyHandlerResponse (out , ProgressEvent .<TestModel , TestContext >builder ().status (OperationStatus .IN_PROGRESS )
476+ .resourceModel (TestModel .builder ().property1 ("abc" ).property2 (123 ).build ()).build ());
477+ }
478+ }
479+
480+ @ ParameterizedTest
481+ @ CsvSource ({ "create.without-callback-context.request.json,CREATE" , "update.without-callback-context.request.json,UPDATE" })
482+ public void reInvokeHandler_InProgress_returnsInProgressWithoutContext (final String requestDataPath ,
483+ final String actionAsString )
484+ throws IOException {
485+ final Action action = Action .valueOf (actionAsString );
486+ final TestModel model = TestModel .builder ().property1 ("abc" ).property2 (123 ).build ();
487+
488+ // an InProgress response is always re-scheduled.
489+ // If no explicit time is supplied, a 1-minute interval is used, and any
490+ // interval >= 1 minute is scheduled
491+ // against CloudWatch. Shorter intervals are able to run locally within same
492+ // function context if runtime permits
493+ final ProgressEvent <TestModel ,
494+ TestContext > pe = ProgressEvent .<TestModel , TestContext >builder ().status (OperationStatus .IN_PROGRESS )
495+ .callbackDelaySeconds (60 ).resourceModel (model )
496+ .callbackContext (TestContext .builder ().contextPropertyA ("Value" ).build ()).build ();
450497 wrapper .setInvokeHandlerResponse (pe );
451498
452499 wrapper .setTransformResponse (resourceHandlerRequest );
@@ -467,9 +514,7 @@ public void reInvokeHandler_InProgress_returnsInProgress(final String requestDat
467514 verifyNoMoreInteractions (providerMetricsPublisher );
468515
469516 // verify that model validation occurred for CREATE/UPDATE
470- if (action == Action .CREATE || action == Action .UPDATE ) {
471- verify (validator ).validateObject (any (JSONObject .class ), any (JSONObject .class ));
472- }
517+ verify (validator ).validateObject (any (JSONObject .class ), any (JSONObject .class ));
473518
474519 // verify output response
475520 verifyHandlerResponse (out , ProgressEvent .<TestModel , TestContext >builder ().status (OperationStatus .IN_PROGRESS )
0 commit comments