Order extends BusinessObject { @Override void setParams() { ParamOption encode = new ParamOption().setEncode(true); tracker.setParam("cmd", orderId); if (turnover > -1.0) { tracker.setParam("roimt", turnover); } if (status > -1) { tracker.setParam("st", status); } tracker.setParam("newcus", newCustomer ? "1" : "0"); if (orderDiscount != null) { double discountTaxFree = orderDiscount.getDiscountTaxFree(); double discountTaxIncluded = orderDiscount.getDiscountTaxIncluded(); String promotionalCode = orderDiscount.getPromotionalCode(); if (discountTaxFree > -1) { tracker.setParam("dscht", discountTaxFree); } if (discountTaxIncluded > -1) { tracker.setParam("dsc", discountTaxIncluded); } if (promotionalCode != null) { tracker.setParam("pcd", promotionalCode, encode); } } if (orderAmount != null) { double amountTaxFree = orderAmount.getAmountTaxFree(); double amountTaxIncluded = orderAmount.getAmountTaxIncluded(); double taxAmount = orderAmount.getTaxAmount(); if (amountTaxFree > -1) { tracker.setParam("mtht", amountTaxFree); } if (amountTaxIncluded > -1) { tracker.setParam("mtttc", amountTaxIncluded); } if (taxAmount > -1) { tracker.setParam("tax", taxAmount); } } if (orderDelivery != null) { double shippingFeesTaxFree = orderDelivery.getShippingFeesTaxFree(); double shippingFeesTaxIncluded = orderDelivery.getShippingFeesTaxIncluded(); String deliveryMethod = orderDelivery.getDeliveryMethod(); if (shippingFeesTaxFree > -1) { tracker.setParam("fpht", shippingFeesTaxFree); } if (shippingFeesTaxIncluded > -1) { tracker.setParam("fp", shippingFeesTaxIncluded); } if (deliveryMethod != null) { tracker.setParam("dl", deliveryMethod, encode); } } if (customVariables != null) { for (OrderCustomVar var : customVariables) { tracker.setParam("o" + var.getVarId(), var.getValue()); } } if (paymentMethod > -1) { tracker.setParam("mp", paymentMethod); } if (confirmationRequired) { tracker.setParam(Hit.HitParam.Tp.stringValue(), "pre1"); } } Order(Tracker tracker); OrderDiscount Discount(); OrderAmount Amount(); OrderDelivery Delivery(); OrderCustomVars CustomVars(); String getOrderId(); double getTurnover(); int getStatus(); boolean isNewCustomer(); int getPaymentMethod(); boolean isConfirmationRequired(); Order setOrderId(String orderId); Order setTurnover(double turnover); Order setStatus(int status); Order setNewCustomer(boolean newCustomer); Order setPaymentMethod(int paymentMethod); Order setConfirmationRequired(boolean confirmationRequired);  }
@Test public void setParamsTest() { order.Amount().set(34.6, 6.7, 8).CustomVars().add(4, "test"); order.setParams(); assertEquals(6, buffer.getVolatileParams().size()); assertEquals(0, buffer.getPersistentParams().size()); assertEquals(1, buffer.getVolatileParams().get("cmd").getValues().size()); assertEquals("", buffer.getVolatileParams().get("cmd").getValues().get(0).execute()); assertEquals(1, buffer.getVolatileParams().get("newcus").getValues().size()); assertEquals("0", buffer.getVolatileParams().get("newcus").getValues().get(0).execute()); assertEquals(1, buffer.getVolatileParams().get("mtht").getValues().size()); assertEquals("34.6", buffer.getVolatileParams().get("mtht").getValues().get(0).execute()); assertEquals(1, buffer.getVolatileParams().get("mtttc").getValues().size()); assertEquals("6.7", buffer.getVolatileParams().get("mtttc").getValues().get(0).execute()); assertEquals(1, buffer.getVolatileParams().get("tax").getValues().size()); assertEquals("8.0", buffer.getVolatileParams().get("tax").getValues().get(0).execute()); assertEquals(1, buffer.getVolatileParams().get("o4").getValues().size()); assertEquals("test", buffer.getVolatileParams().get("o4").getValues().get(0).execute()); }