CommerceEvent extends BaseEvent { @Nullable public List<Promotion> getPromotions() { if (promotionList == null) { return null; } return Collections.unmodifiableList(promotionList); } 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();  }
@Test public void testAddPromotion() throws Exception { Product product = new Product.Builder("name", "sku", 0).build(); CommerceEvent event = new CommerceEvent.Builder("promo", new Promotion().setId("promo id")).nonInteraction(true).build(); assertEquals("promo id", event.getPromotions().get(0).getId()); 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(Product.ADD_TO_CART, product).nonInteraction(true).addPromotion(new Promotion().setId("promo id")).build(); assertNotNull("Should have logged Error", errorMessage.value); }