2121package com .adyen ;
2222
2323import static org .junit .Assert .*;
24+ import static org .mockito .ArgumentMatchers .*;
25+ import static org .mockito .ArgumentMatchers .eq ;
26+ import static org .mockito .ArgumentMatchers .isNull ;
27+ import static org .mockito .Mockito .verify ;
2428
29+ import com .adyen .constants .ApiConstants ;
2530import com .adyen .model .nexo .MessageCategoryType ;
2631import com .adyen .model .nexo .MessageClassType ;
2732import com .adyen .model .nexo .MessageHeader ;
4550import java .math .BigDecimal ;
4651import java .util .List ;
4752import org .junit .Test ;
53+ import org .mockito .ArgumentCaptor ;
4854
4955/** Tests for /sync and /async */
5056public class TerminalCloudAPITest extends BaseTest {
@@ -166,6 +172,23 @@ public void syncPaymentRequestSuccess() throws Exception {
166172 paymentResult .getCurrencyConversion ().get (0 ).getConvertedAmount ().getAmountValue ());
167173 assertEquals (
168174 "EUR" , paymentResult .getCurrencyConversion ().get (0 ).getConvertedAmount ().getCurrency ());
175+
176+ final ArgumentCaptor <String > captor = ArgumentCaptor .forClass (String .class );
177+ verify (client .getHttpClient ())
178+ .request (
179+ isNotNull (),
180+ captor .capture (),
181+ any (com .adyen .Config .class ),
182+ eq (true ),
183+ isNull (),
184+ eq (ApiConstants .HttpMethod .POST ),
185+ isNull ());
186+
187+ String requestAsJson = captor .getValue ();
188+ assertTrue (
189+ "SaleToAcquirerData field not found" , requestAsJson .contains ("\" SaleToAcquirerData\" :" ));
190+ assertFalse ("Found null value" , requestAsJson .contains (":null" ));
191+ assertFalse ("Found null value" , requestAsJson .contains (": null" ));
169192 }
170193
171194 /** Test success flow for POST /sync that includes unexpected attributes */
@@ -230,7 +253,9 @@ public void syncInputRequestSuccess() throws Exception {
230253 Client client = createMockClientFromFile ("mocks/terminal-api/input-request-success.json" );
231254 TerminalCloudAPI terminalCloudApi = new TerminalCloudAPI (client );
232255
233- TerminalAPIResponse requestResponse = terminalCloudApi .sync (new TerminalAPIRequest ());
256+ TerminalAPIRequest inputRequest = createTerminalAPIInputRequest ();
257+
258+ TerminalAPIResponse requestResponse = terminalCloudApi .sync (inputRequest );
234259
235260 assertNotNull (requestResponse );
236261 assertNotNull (requestResponse .getSaleToPOIResponse ());
@@ -254,6 +279,24 @@ public void syncInputRequestSuccess() throws Exception {
254279 .getInput ()
255280 .getMenuEntryNumber ()
256281 .length );
282+
283+ final ArgumentCaptor <String > captor = ArgumentCaptor .forClass (String .class );
284+ verify (client .getHttpClient ())
285+ .request (
286+ isNotNull (),
287+ captor .capture (),
288+ any (com .adyen .Config .class ),
289+ eq (true ),
290+ isNull (),
291+ eq (ApiConstants .HttpMethod .POST ),
292+ isNull ());
293+
294+ String requestAsJson = captor .getValue ();
295+ assertTrue ("InputRequest field not found" , requestAsJson .contains ("\" InputRequest\" :" ));
296+ assertTrue (
297+ "PredefinedContent field not found" , requestAsJson .contains ("\" PredefinedContent\" :" ));
298+ assertFalse ("Found null value" , requestAsJson .contains (":null" ));
299+ assertFalse ("Found null value" , requestAsJson .contains (": null" ));
257300 }
258301
259302 /** Mocked response for stored value type for POST /sync */
0 commit comments