2121
2222import com .salesforce .revoman .ReVoman ;
2323import com .salesforce .revoman .input .config .Kick ;
24+ import com .salesforce .revoman .input .json .adapters .CompositeGraphResponse ;
2425import com .salesforce .revoman .integration .core .pq .connect .request .PlaceQuoteInputRepresentation ;
2526import com .salesforce .revoman .integration .core .pq .connect .response .ID ;
2627import com .salesforce .revoman .integration .core .pq .connect .response .PlaceQuoteOutputRepresentation ;
@@ -46,9 +47,9 @@ class PQE2EWithSMTest {
4647 private static final Logger LOGGER = LoggerFactory .getLogger (PQE2EWithSMTest .class );
4748 private static final List <String > PQ_TEMPLATE_PATHS =
4849 List .of (
49- "pm-templates/pq/user-creation-and-setup-pq.postman_collection.json" ,
50+ "pm-templates/pq/[sm] user-creation-with-ps -and-setup-pq.postman_collection.json" ,
5051 "pm-templates/pq/pre-salesRep.postman_collection.json" ,
51- "pm-templates/pq/pq-sm .postman_collection.json" );
52+ "pm-templates/pq/[sm] pq .postman_collection.json" );
5253 private static final String PQ_ENV_PATH = "pm-templates/pq/pq-env.postman_environment.json" ;
5354 private static final String PQ_URI_PATH = "commerce/quotes/actions/place" ;
5455 private static final String COMPOSITE_GRAPH_URI_PATH = "composite/graph" ;
@@ -71,13 +72,22 @@ void revUpPQ() {
7172 .customDynamicVariable ( // <5>
7273 "$quantity" , ignore -> String .valueOf (Random .Default .nextInt (10 ) + 1 ))
7374 .haltOnFailureOfTypeExcept (
74- HTTP_STATUS , afterAllStepsContainingHeader ("ignoreForFailure" )) // <6>
75+ HTTP_STATUS ,
76+ afterAllStepsContainingHeader ("ignoreHTTPStatusUnsuccessful" )) // <6>
7577 .requestConfig ( // <7>
7678 unmarshallRequest (
7779 beforeAllStepsWithURIPathEndingWith (PQ_URI_PATH ),
7880 PlaceQuoteInputRepresentation .class ,
7981 adapter (PlaceQuoteInputRepresentation .class )))
80- .hooks ( // <8>
82+ .responseConfig ( // <8>
83+ unmarshallResponse (
84+ afterAllStepsWithURIPathEndingWith (PQ_URI_PATH ),
85+ PlaceQuoteOutputRepresentation .class ),
86+ unmarshallResponse (
87+ afterAllStepsWithURIPathEndingWith (COMPOSITE_GRAPH_URI_PATH ),
88+ CompositeGraphResponse .class ,
89+ CompositeGraphResponse .ADAPTER ))
90+ .hooks ( // <9>
8191 pre (
8292 beforeAllStepsWithURIPathEndingWith (PQ_URI_PATH ),
8393 (step , requestInfo , rundown ) -> {
@@ -91,21 +101,20 @@ HTTP_STATUS, afterAllStepsContainingHeader("ignoreForFailure")) // <6>
91101 post (
92102 afterAllStepsWithURIPathEndingWith (PQ_URI_PATH ),
93103 (stepReport , ignore ) -> {
94- validatePQResponse (stepReport ); // <9 >
104+ validatePQResponse (stepReport ); // <10 >
95105 LOGGER .info (
96106 "Waiting in PostHook of the Step: {}, for the Quote's Asynchronous processing to finish" ,
97107 stepReport .step .displayName );
98108 // ! CAUTION 10/09/23 gopala.akshintala: This can be flaky until
99109 // polling is implemented
100110 Thread .sleep (5000 );
101111 }),
112+ post (
113+ afterAllStepsWithURIPathEndingWith (COMPOSITE_GRAPH_URI_PATH ),
114+ (stepReport , ignore ) -> validateCompositeGraphResponse (stepReport )),
102115 post (
103116 afterStepName ("query-quote-and-related-records" ),
104117 (ignore , rundown ) -> assertAfterPQCreate (rundown .mutableEnv )))
105- .responseConfig ( // <10>
106- unmarshallResponse (
107- afterAllStepsWithURIPathEndingWith (PQ_URI_PATH ),
108- PlaceQuoteOutputRepresentation .class ))
109118 .customAdaptersForMarshalling (new IDAdapter ()) // <11>
110119 .insecureHttp (true ) // <12>
111120 .off ()); // Kick-off
@@ -125,6 +134,12 @@ private static void validatePQResponse(StepReport stepReport) {
125134 assertThat (successRespProp ).isEqualTo (!stepReport .step .isInFolder (SYNC_ERROR_FOLDER_NAME ));
126135 }
127136
137+ private static void validateCompositeGraphResponse (StepReport stepReport ) {
138+ final var graphResponse =
139+ stepReport .responseInfo .get ().<CompositeGraphResponse >getTypedTxnObj ().getGraphs ().get (0 );
140+ assertThat (graphResponse .isSuccessful ()).isTrue ();
141+ }
142+
128143 private static void assertAfterPQCreate (PostmanEnvironment <Object > env ) {
129144 // Quote: LineItemCount, quoteCalculationStatus
130145 assertThat (env ).containsEntry ("lineItemCount" , 10 );
@@ -154,6 +169,7 @@ private enum PricingPref {
154169 }
155170 }
156171
172+ // * NOTE 10 Mar 2024 gopala.akshintala: Custom Type Adapter
157173 static class IDAdapter {
158174 @ FromJson
159175 ID fromJson (String id ) {
0 commit comments