@Test public void testAddProduct() throws Exception { Product product = new Product.Builder("name", "sku", 0).build(); Product product2 = new Product.Builder("name 2", "sku 2", 0).build(); CommerceEvent event = new CommerceEvent.Builder(Product.ADD_TO_CART, product).addProduct(product2).build(); assertEquals("name 2", event.getProducts().get(1).getName()); final AndroidUtils.Mutable<String> errorMessage = new AndroidUtils.Mutable<String>(null); Logger.setLogHandler(new Logger.DefaultLogHandler() { @Override public void log(MParticle.LogLevel priority, Throwable error, String messages) { if (priority == MParticle.LogLevel.ERROR) { errorMessage.value = messages; } } }); new CommerceEvent.Builder(Promotion.VIEW, new Promotion().setId("whatever")).addProduct(product2).build(); assertNotNull("Should have logged Error", errorMessage.value); errorMessage.value = null; new CommerceEvent.Builder(new Impression("name", product)).addProduct(product2).build(); assertNotNull("Should have loggedError", errorMessage.value); errorMessage.value = null; }
@Nullable public List<Product> getProducts() { if (productList == null) { return null; } return Collections.unmodifiableList(productList); }
CommerceEvent extends BaseEvent { @Nullable public List<Product> getProducts() { if (productList == null) { return null; } return Collections.unmodifiableList(productList); } }
CommerceEvent extends BaseEvent { @Nullable public List<Product> getProducts() { if (productList == null) { return null; } return Collections.unmodifiableList(productList); } private  CommerceEvent(Builder builder); private  CommerceEvent(); }
CommerceEvent extends BaseEvent { @Nullable public List<Product> getProducts() { if (productList == null) { return null; } return Collections.unmodifiableList(productList); } private  CommerceEvent(Builder builder); private  CommerceEvent(); @Override @NonNull String toString(); @Nullable String getScreen(); @Nullable Boolean getNonInteraction(); @Nullable String getProductAction(); @Nullable Integer getCheckoutStep(); @Nullable String getCheckoutOptions(); @Nullable String getProductListName(); @Nullable String getProductListSource(); @Nullable TransactionAttributes getTransactionAttributes(); @Nullable List<Product> getProducts(); @Nullable String getPromotionAction(); @Nullable List<Promotion> getPromotions(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Nullable List<Impression> getImpressions(); @Nullable String getCurrency(); @Nullable String getEventName(); @Override BaseMPMessageBuilder getMessage(); }
CommerceEvent extends BaseEvent { @Nullable public List<Product> getProducts() { if (productList == null) { return null; } return Collections.unmodifiableList(productList); } private  CommerceEvent(Builder builder); private  CommerceEvent(); @Override @NonNull String toString(); @Nullable String getScreen(); @Nullable Boolean getNonInteraction(); @Nullable String getProductAction(); @Nullable Integer getCheckoutStep(); @Nullable String getCheckoutOptions(); @Nullable String getProductListName(); @Nullable String getProductListSource(); @Nullable TransactionAttributes getTransactionAttributes(); @Nullable List<Product> getProducts(); @Nullable String getPromotionAction(); @Nullable List<Promotion> getPromotions(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Nullable List<Impression> getImpressions(); @Nullable String getCurrency(); @Nullable String getEventName(); @Override BaseMPMessageBuilder getMessage();  }