@@ -65,6 +65,7 @@ public void testDeserialization() throws Exception {
6565 " <liability_gl_account_id>123</liability_gl_account_id>\n " +
6666 " <revenue_gl_account_id>456</revenue_gl_account_id>\n " +
6767 " <performance_obligation_id>789</performance_obligation_id>\n " +
68+ " <tax_service_opt_out type=\" boolean\" >true</tax_service_opt_out>\n " +
6869 " </gift_card>" +
6970 "</gift_cards>" ;
7071
@@ -86,6 +87,7 @@ public void testDeserialization() throws Exception {
8687 Assert .assertEquals (giftCard .getLiabilityGlAccountId (), "123" );
8788 Assert .assertEquals (giftCard .getRevenueGlAccountId (), "456" );
8889 Assert .assertEquals (giftCard .getPerformanceObligationId (), "789" );
90+ Assert .assertEquals (giftCard .getTaxServiceOptOut (), Boolean .TRUE );
8991 Assert .assertNull (giftCard .getCanceledAt ());
9092
9193 final Delivery delivery = giftCard .getDelivery ();
@@ -107,4 +109,55 @@ public void testDeserialization() throws Exception {
107109 Assert .assertEquals (address .getZip (), "94110" );
108110 Assert .assertEquals (address .getPhone (), "555-555-5555" );
109111 }
112+
113+ @ Test (groups = "fast" )
114+ public void testSerializationWithTaxServiceOptOut () throws Exception {
115+ final GiftCard giftCard = new GiftCard ();
116+ giftCard .setProductCode ("gift_card_100" );
117+ giftCard .setCurrency ("USD" );
118+ giftCard .setUnitAmountInCents (10000 );
119+ giftCard .setTaxServiceOptOut (true );
120+
121+ final String xml = xmlMapper .writeValueAsString (giftCard );
122+
123+ Assert .assertTrue (xml .contains ("<product_code>gift_card_100</product_code>" ));
124+ Assert .assertTrue (xml .contains ("<currency>USD</currency>" ));
125+ Assert .assertTrue (xml .contains ("<unit_amount_in_cents>10000</unit_amount_in_cents>" ));
126+ Assert .assertTrue (xml .contains ("<tax_service_opt_out>true</tax_service_opt_out>" ));
127+ }
128+
129+ @ Test (groups = "fast" )
130+ public void testDeserializationWithTaxServiceOptOutFalse () throws Exception {
131+ final String giftCardData =
132+ "<gift_card>" +
133+ " <product_code>gift_card</product_code>\n " +
134+ " <currency>USD</currency> \n " +
135+ " <unit_amount_in_cents type=\" integer\" >2000</unit_amount_in_cents>\n " +
136+ " <tax_service_opt_out type=\" boolean\" >false</tax_service_opt_out>\n " +
137+ "</gift_card>" ;
138+
139+ final GiftCard giftCard = xmlMapper .readValue (giftCardData , GiftCard .class );
140+
141+ Assert .assertEquals (giftCard .getProductCode (), "gift_card" );
142+ Assert .assertEquals (giftCard .getCurrency (), "USD" );
143+ Assert .assertEquals (giftCard .getUnitAmountInCents (), new Integer (2000 ));
144+ Assert .assertEquals (giftCard .getTaxServiceOptOut (), Boolean .FALSE );
145+ }
146+
147+ @ Test (groups = "fast" )
148+ public void testDeserializationWithoutTaxServiceOptOut () throws Exception {
149+ final String giftCardData =
150+ "<gift_card>" +
151+ " <product_code>gift_card</product_code>\n " +
152+ " <currency>USD</currency> \n " +
153+ " <unit_amount_in_cents type=\" integer\" >2000</unit_amount_in_cents>\n " +
154+ "</gift_card>" ;
155+
156+ final GiftCard giftCard = xmlMapper .readValue (giftCardData , GiftCard .class );
157+
158+ Assert .assertEquals (giftCard .getProductCode (), "gift_card" );
159+ Assert .assertEquals (giftCard .getCurrency (), "USD" );
160+ Assert .assertEquals (giftCard .getUnitAmountInCents (), new Integer (2000 ));
161+ Assert .assertNull (giftCard .getTaxServiceOptOut ());
162+ }
110163 }
0 commit comments