@@ -450,6 +450,56 @@ public void testSendConsumptionData() throws APIException, IOException {
450
450
client .sendConsumptionData ("49571273" , consumptionRequest );
451
451
}
452
452
453
+ @ Test
454
+ public void testSendConsumptionDataWithNullAppAccountToken () throws APIException , IOException {
455
+ AppStoreServerAPIClient client = getAppStoreServerAPIClient ("" , request -> {
456
+ Assertions .assertEquals ("PUT" , request .method ());
457
+ Assertions .assertEquals ("/inApps/v1/transactions/consumption/49571273" , request .url ().encodedPath ());
458
+ RequestBody body = request .body ();
459
+ Assertions .assertNotNull (body );
460
+ Assertions .assertEquals (expectedMediaType , body .contentType ());
461
+ Buffer buffer = new Buffer ();
462
+ try {
463
+ body .writeTo (buffer );
464
+ } catch (IOException e ) {
465
+ throw new RuntimeException (e );
466
+ }
467
+ Map <String , Object > root ;
468
+ try {
469
+ root = new ObjectMapper ().readValue (buffer .readUtf8 (), Map .class );
470
+ } catch (JsonProcessingException e ) {
471
+ throw new RuntimeException (e );
472
+ }
473
+ Assertions .assertTrue ((Boolean ) root .get ("customerConsented" ));
474
+ Assertions .assertEquals (1 , ((Number ) root .get ("consumptionStatus" )).intValue ());
475
+ Assertions .assertEquals (2 , ((Number ) root .get ("platform" )).intValue ());
476
+ Assertions .assertFalse ((Boolean ) root .get ("sampleContentProvided" ));
477
+ Assertions .assertEquals (3 , ((Number ) root .get ("deliveryStatus" )).intValue ());
478
+ Assertions .assertEquals ("" , root .get ("appAccountToken" ));
479
+ Assertions .assertEquals (4 , ((Number ) root .get ("accountTenure" )).intValue ());
480
+ Assertions .assertEquals (5 , ((Number ) root .get ("playTime" )).intValue ());
481
+ Assertions .assertEquals (6 , ((Number ) root .get ("lifetimeDollarsRefunded" )).intValue ());
482
+ Assertions .assertEquals (7 , ((Number ) root .get ("lifetimeDollarsPurchased" )).intValue ());
483
+ Assertions .assertEquals (4 , ((Number ) root .get ("userStatus" )).intValue ());
484
+ Assertions .assertEquals (3 , ((Number ) root .get ("refundPreference" )).intValue ());
485
+ });
486
+
487
+ ConsumptionRequest consumptionRequest = new ConsumptionRequest ()
488
+ .customerConsented (true )
489
+ .consumptionStatus (ConsumptionStatus .NOT_CONSUMED )
490
+ .platform (Platform .NON_APPLE )
491
+ .sampleContentProvided (false )
492
+ .deliveryStatus (DeliveryStatus .DID_NOT_DELIVER_DUE_TO_SERVER_OUTAGE )
493
+ .accountTenure (AccountTenure .THIRTY_DAYS_TO_NINETY_DAYS )
494
+ .playTime (PlayTime .ONE_DAY_TO_FOUR_DAYS )
495
+ .lifetimeDollarsRefunded (LifetimeDollarsRefunded .ONE_THOUSAND_DOLLARS_TO_ONE_THOUSAND_NINE_HUNDRED_NINETY_NINE_DOLLARS_AND_NINETY_NINE_CENTS )
496
+ .lifetimeDollarsPurchased (LifetimeDollarsPurchased .TWO_THOUSAND_DOLLARS_OR_GREATER )
497
+ .userStatus (UserStatus .LIMITED_ACCESS )
498
+ .refundPreference (RefundPreference .NO_PREFERENCE );
499
+
500
+ client .sendConsumptionData ("49571273" , consumptionRequest );
501
+ }
502
+
453
503
@ Test
454
504
public void testHeaders () throws APIException , IOException {
455
505
AppStoreServerAPIClient client = getClientWithBody ("models/transactionInfoResponse.json" , request -> {
0 commit comments