@@ -494,11 +494,26 @@ class AppboyKitTests {
494494 val productBrazeProperties = productArray[0 ]
495495 if (productBrazeProperties is BrazeProperties ) {
496496 val productProperties = productBrazeProperties.properties
497- Assert .assertEquals(productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_TOTAL_AMOUNT ), 22.5 )
498- Assert .assertEquals(productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_PRICE ), 4.5 )
499- Assert .assertEquals(productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_QUANTITY ), 5.0 )
500- Assert .assertEquals(productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_ID ), " sku1" )
501- Assert .assertEquals(productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_NAME ), " product name" )
497+ Assert .assertEquals(
498+ productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_TOTAL_AMOUNT ),
499+ 22.5
500+ )
501+ Assert .assertEquals(
502+ productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_PRICE ),
503+ 4.5
504+ )
505+ Assert .assertEquals(
506+ productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_QUANTITY ),
507+ 5.0
508+ )
509+ Assert .assertEquals(
510+ productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_ID ),
511+ " sku1"
512+ )
513+ Assert .assertEquals(
514+ productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_NAME ),
515+ " product name"
516+ )
502517 Assert .assertEquals(emptyAttributes, productProperties)
503518 }
504519 }
@@ -584,7 +599,7 @@ class AppboyKitTests {
584599 id = " my_promo_1"
585600 creative = " sale_banner_1"
586601 name = " App-wide 50% off sale"
587- position = " dashboard_bottom"
602+ position = " dashboard_bottom"
588603 }
589604 val commerceEvent = CommerceEvent .Builder (Promotion .VIEW , promotion)
590605 .customAttributes(customAttributes)
@@ -604,10 +619,22 @@ class AppboyKitTests {
604619 val promotionBrazeProperties = promotionArray[0 ]
605620 if (promotionBrazeProperties is BrazeProperties ) {
606621 val promotionProperties = promotionBrazeProperties.properties
607- Assert .assertEquals(promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_ID ), " my_promo_1" )
608- Assert .assertEquals(promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_NAME ), " App-wide 50% off sale" )
609- Assert .assertEquals(promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_POSITION ), " dashboard_bottom" )
610- Assert .assertEquals(promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_CREATIVE ), " sale_banner_1" )
622+ Assert .assertEquals(
623+ promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_ID ),
624+ " my_promo_1"
625+ )
626+ Assert .assertEquals(
627+ promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_NAME ),
628+ " App-wide 50% off sale"
629+ )
630+ Assert .assertEquals(
631+ promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_POSITION ),
632+ " dashboard_bottom"
633+ )
634+ Assert .assertEquals(
635+ promotionProperties.remove(CommerceEventUtils .Constants .ATT_PROMOTION_CREATIVE ),
636+ " sale_banner_1"
637+ )
611638 Assert .assertEquals(emptyAttributes, promotionProperties)
612639 }
613640 }
@@ -697,7 +724,10 @@ class AppboyKitTests {
697724 val impressionBrazeProperties = impressionArray[0 ]
698725 if (impressionBrazeProperties is BrazeProperties ) {
699726 val impressionProperties = impressionBrazeProperties.properties
700- Assert .assertEquals(impressionProperties.remove(" Product Impression List" ), " Suggested Products List" )
727+ Assert .assertEquals(
728+ impressionProperties.remove(" Product Impression List" ),
729+ " Suggested Products List"
730+ )
701731 val productArray = impressionProperties.remove(AppboyKit .PRODUCT_KEY )
702732 Assert .assertTrue(productArray is Array <* >)
703733 if (productArray is Array <* >) {
@@ -725,11 +755,19 @@ class AppboyKitTests {
725755 productProperties.remove(CommerceEventUtils .Constants .ATT_PRODUCT_PRICE ),
726756 4.5
727757 )
728- val brazeProductCustomAttributesDictionary = productProperties.remove(AppboyKit .CUSTOM_ATTRIBUTES_KEY )
758+ val brazeProductCustomAttributesDictionary =
759+ productProperties.remove(AppboyKit .CUSTOM_ATTRIBUTES_KEY )
729760 if (brazeProductCustomAttributesDictionary is BrazeProperties ) {
730- val customProductAttributesDictionary = brazeProductCustomAttributesDictionary.properties
731- Assert .assertEquals(customProductAttributesDictionary.remove(" key1" ), " value1" )
732- Assert .assertEquals(customProductAttributesDictionary.remove(" key #2" ), " value #3" )
761+ val customProductAttributesDictionary =
762+ brazeProductCustomAttributesDictionary.properties
763+ Assert .assertEquals(
764+ customProductAttributesDictionary.remove(" key1" ),
765+ " value1"
766+ )
767+ Assert .assertEquals(
768+ customProductAttributesDictionary.remove(" key #2" ),
769+ " value #3"
770+ )
733771 Assert .assertEquals(emptyAttributes, customProductAttributesDictionary)
734772 }
735773 Assert .assertEquals(emptyAttributes, productProperties)
@@ -797,6 +835,66 @@ class AppboyKitTests {
797835// Assert.assertEquals(0, properties.size.toLong())
798836// }
799837
838+ // @Test
839+ // fun testLogCommerceEvent() {
840+ // val kit = MockAppboyKit()
841+ //
842+ // val product: Product = Product.Builder("La Enchilada", "13061043670", 12.5)
843+ // .quantity(1.0)
844+ // .build()
845+ //
846+ // val txAttributes = TransactionAttributes()
847+ // .setRevenue(product.getTotalAmount())
848+ //
849+ // kit.configuration = MockKitConfiguration()
850+ // val customAttributes: MutableMap<String, String> = HashMap()
851+ // customAttributes["currentLocationLongitude"] = "2.1811267"
852+ // customAttributes["country"] = "ES"
853+ // customAttributes["deliveryLocationLatitude"] = "41.4035798"
854+ // customAttributes["appVersion"] = "5.201.0"
855+ // customAttributes["city"] = "BCN"
856+ // customAttributes["deviceId"] = "1104442582"
857+ // customAttributes["platform"] = "android"
858+ // customAttributes["isAuthorized"] = "true"
859+ // customAttributes["productSelectionOrigin"] = "Catalogue"
860+ // customAttributes["currentLocationLatitude"] = "41.4035798"
861+ // customAttributes["collectionId"] = "1180889389"
862+ // customAttributes["multiplatformVersion"] = "1.0.288"
863+ // customAttributes["deliveryLocationTimestamp"] = "1675344636685"
864+ // customAttributes["productId"] = "13061043670"
865+ // customAttributes["storeAddressId"] = "300482"
866+ // customAttributes["currentLocationAccuracy"] = "19.278"
867+ // customAttributes["productAddedOrigin"] = "Item Detail Add to Order"
868+ // customAttributes["deliveryLocationLongitude"] = "2.1811267"
869+ // customAttributes["currentLocationTimestamp"] = "1675344636685"
870+ // customAttributes["dynamicSessionId"] = "67f8fb8d-8d14-4f0e-bf1a-73fb8e6eed95"
871+ // customAttributes["deliveryLocationAccuracy"] = "19.278"
872+ // customAttributes["categoryId"] = "1"
873+ // customAttributes["isSponsored"] = "false"
874+ //
875+ // val commerceEvent: CommerceEvent = CommerceEvent.Builder(Product.ADD_TO_CART, product)
876+ // .currency("EUR")
877+ // .customAttributes(customAttributes)
878+ // .transactionAttributes(txAttributes)
879+ // .build()
880+ // kit.logEvent(commerceEvent)
881+ //
882+ // val braze = Braze
883+ // val events = braze.events
884+ // Assert.assertEquals(1, events.size.toLong())
885+ // val event = events.values.iterator().next()
886+ // Assert.assertNotNull(event.properties)
887+ // val properties = event.properties
888+ //
889+ // Assert.assertEquals(properties.remove("Name"), "La Enchilada")
890+ // Assert.assertEquals(properties.remove("Total Product Amount"), "12.5")
891+ // Assert.assertEquals(properties.remove("Id"), "13061043670")
892+ // for (item in customAttributes) {
893+ // Assert.assertTrue(properties.containsKey(item.key))
894+ // Assert.assertTrue(properties.containsValue(item.value))
895+ // }
896+ // }
897+
800898// @Test
801899// fun testEventStringTypeNotEnabled() {
802900// val kit = MockAppboyKit()
0 commit comments