@@ -207,7 +207,94 @@ public void testSerializationWithBillingInfoUuid() throws Exception {
207207
208208 public void verifyPurchaseWithBillingInfoUuid (final Purchase purchase ) {
209209 assertEquals (purchase .getBillingInfoUuid (), "iiznlrvdt8py" );
210- }
210+ }
211+
212+ @ Test (groups = "fast" )
213+ public void testSerializationWithVertexTransactionType () throws Exception {
214+ final String purchaseData = "<purchase xmlns=\" \" >" +
215+ "<currency>USD</currency>" +
216+ " <collection_method>automatic</collection_method>" +
217+ " <vertex_transaction_type>rental</vertex_transaction_type>" +
218+ " <account>" +
219+ " <account_code>test</account_code>" +
220+ " <billing_info>" +
221+ " <first_name>Benjamin</first_name>" +
222+ " <last_name>Du Monde</last_name>" +
223+ " <address1>400 Alabama St</address1>" +
224+ " <city>San Francisco</city>" +
225+ " <state>CA</state>" +
226+ " <zip>94110</zip>" +
227+ " <country>US</country>" +
228+ " <year type=\" integer\" >2019</year>" +
229+ " <month type=\" integer\" >12</month>" +
230+ " <number>4000-0000-0000-0000</number>" +
231+ " </billing_info>" +
232+ " </account>" +
233+ " <adjustments>" +
234+ " <adjustment>" +
235+ " <unit_amount_in_cents type=\" integer\" >1000</unit_amount_in_cents>" +
236+ " <quantity type=\" integer\" >1</quantity>" +
237+ " <currency>USD</currency>" +
238+ " <product_code>product-code</product_code>" +
239+ " </adjustment>" +
240+ " </adjustments>" +
241+ "</purchase>" ;
242+
243+ // test serialization
244+ final Purchase purchase = xmlMapper .readValue (purchaseData , Purchase .class );
245+ verifyPurchaseWithVertexTransactionType (purchase );
246+
247+ // test deseralization
248+ final Purchase purchaseExpected = xmlMapper .readValue (purchaseData , Purchase .class );
249+ assertEquals (purchase , purchaseExpected );
250+ }
251+
252+ public void verifyPurchaseWithVertexTransactionType (final Purchase purchase ) {
253+ assertEquals (purchase .getVertexTransactionType (), "rental" );
254+ assertEquals (purchase .getCurrency (), "USD" );
255+ assertEquals (purchase .getCollectionMethod (), "automatic" );
256+ }
257+
258+ @ Test (groups = "fast" )
259+ public void testSerializationToXmlWithVertexTransactionType () throws Exception {
260+ // Create purchase object programmatically and verify it serializes correctly to XML
261+ final Purchase purchase = new Purchase ();
262+ purchase .setCurrency ("USD" );
263+ purchase .setCollectionMethod ("automatic" );
264+ purchase .setVertexTransactionType ("lease" );
265+
266+ final Account account = new Account ();
267+ account .setAccountCode ("test-account" );
268+ purchase .setAccount (account );
269+
270+ // Serialize to XML string
271+ final String xml = xmlMapper .writeValueAsString (purchase );
272+
273+ // Verify the XML contains the vertex_transaction_type element
274+ assert xml .contains ("<vertex_transaction_type>lease</vertex_transaction_type>" ) :
275+ "Serialized XML should contain vertex_transaction_type element" ;
276+ assert xml .contains ("<collection_method>automatic</collection_method>" );
277+ assert xml .contains ("<currency>USD</currency>" );
278+ }
279+
280+ @ Test (groups = "fast" )
281+ public void testVertexTransactionTypeAllValidValues () throws Exception {
282+ // Test all valid values: sale, rental, lease
283+ final String [] validValues = {"sale" , "rental" , "lease" };
284+
285+ for (String value : validValues ) {
286+ final Purchase purchase = new Purchase ();
287+ purchase .setVertexTransactionType (value );
288+ assertEquals (purchase .getVertexTransactionType (), value ,
289+ "Should correctly set and get value: " + value );
290+
291+ // Verify serialization/deserialization round-trip
292+ final String xml = xmlMapper .writeValueAsString (purchase );
293+ final Purchase deserializedPurchase = xmlMapper .readValue (xml , Purchase .class );
294+ assertEquals (deserializedPurchase .getVertexTransactionType (), value ,
295+ "Should correctly deserialize value: " + value );
296+ }
297+ }
211298
212299 @ Test (groups = "fast" )
213300 public void testHashCodeAndEquality () throws Exception {
0 commit comments