22// SPDX-License-Identifier: Apache-2.0
33package software .amazon .lambda .durable .testing ;
44
5+ import java .time .Duration ;
6+ import java .time .Instant ;
57import java .util .List ;
68import software .amazon .awssdk .services .lambda .model .CallbackDetails ;
9+ import software .amazon .awssdk .services .lambda .model .ChainedInvokeDetails ;
10+ import software .amazon .awssdk .services .lambda .model .ContextDetails ;
711import software .amazon .awssdk .services .lambda .model .ErrorObject ;
812import software .amazon .awssdk .services .lambda .model .Event ;
13+ import software .amazon .awssdk .services .lambda .model .ExecutionDetails ;
914import software .amazon .awssdk .services .lambda .model .Operation ;
1015import software .amazon .awssdk .services .lambda .model .OperationStatus ;
1116import software .amazon .awssdk .services .lambda .model .OperationType ;
1217import software .amazon .awssdk .services .lambda .model .StepDetails ;
1318import software .amazon .awssdk .services .lambda .model .WaitDetails ;
1419import software .amazon .lambda .durable .TypeToken ;
20+ import software .amazon .lambda .durable .execution .ExecutionManager ;
1521import software .amazon .lambda .durable .serde .SerDes ;
1622
1723/** Wrapper for AWS SDK Operation providing convenient access methods. */
@@ -50,6 +56,23 @@ public OperationType getType() {
5056 return operation .type ();
5157 }
5258
59+ /** Returns the operation's subtype */
60+ public String getSubtype () {
61+ return operation .subType ();
62+ }
63+
64+ /** Returns true if the operation has completed (either succeeded or failed). */
65+ public boolean isCompleted () {
66+ return ExecutionManager .isTerminalStatus (operation .status ());
67+ }
68+
69+ /** Returns the duration of the operation */
70+ public Duration getDuration () {
71+ return Duration .between (
72+ operation .startTimestamp (),
73+ operation .endTimestamp () != null ? operation .endTimestamp () : Instant .now ());
74+ }
75+
5376 /** Returns the step details, or null if this is not a step operation. */
5477 public StepDetails getStepDetails () {
5578 return operation .stepDetails ();
@@ -65,6 +88,21 @@ public CallbackDetails getCallbackDetails() {
6588 return operation .callbackDetails ();
6689 }
6790
91+ /** Returns the chained invoke details, or null if this is not a chained invoke operation. */
92+ public ChainedInvokeDetails getChainedInvokeDetails () {
93+ return operation .chainedInvokeDetails ();
94+ }
95+
96+ /** Returns the context details, or null if this operation is not a context. */
97+ public ContextDetails getContextDetails () {
98+ return operation .contextDetails ();
99+ }
100+
101+ /** Returns the execution details, or null if this operation is not an EXECUTION operation. */
102+ public ExecutionDetails getExecutionDetails () {
103+ return operation .executionDetails ();
104+ }
105+
68106 /** Deserializes and returns the step result as the given type. */
69107 public <T > T getStepResult (Class <T > type ) {
70108 return getStepResult (TypeToken .get (type ));
0 commit comments