@Test public void shouldConvert() throws Exception { RequestMap expectedMap = new RequestMap(); expectedMap.putMap(new HashMap<String, String>() {{ put("item[1].id", "1"); put("item[1].description", "description1"); put("item[1].amount", "99.99"); put("item[1].quantity", "7"); put("item[1].weight", "123"); put("item[1].shippingCost", "99.99"); put("item[2].id", "2"); put("item[2].description", "description2"); put("item[2].amount", "99.99"); put("item[2].quantity", "7"); put("item[2].weight", "123"); put("item[2].shippingCost", "99.99"); }}); RequestMap map = mapConverter.convert(items); assertEquals(expectedMap, map); }
@Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { String index = String.format("item[%d]", i); requestMap.putString(index.concat(".id"), item.getId()); requestMap.putString(index.concat(".description"), item.getDescription()); requestMap.putCurrency(index.concat(".amount"), item.getAmount()); requestMap.putInteger(index.concat(".quantity"), item.getQuantity()); requestMap.putInteger(index.concat(".weight"), item.getWeight()); requestMap.putCurrency(index.concat(".shippingCost"), item.getShippingCost()); i++; } }
PaymentItemsV3MapConverter extends AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { String index = String.format("item[%d]", i); requestMap.putString(index.concat(".id"), item.getId()); requestMap.putString(index.concat(".description"), item.getDescription()); requestMap.putCurrency(index.concat(".amount"), item.getAmount()); requestMap.putInteger(index.concat(".quantity"), item.getQuantity()); requestMap.putInteger(index.concat(".weight"), item.getWeight()); requestMap.putCurrency(index.concat(".shippingCost"), item.getShippingCost()); i++; } } }
PaymentItemsV3MapConverter extends AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { String index = String.format("item[%d]", i); requestMap.putString(index.concat(".id"), item.getId()); requestMap.putString(index.concat(".description"), item.getDescription()); requestMap.putCurrency(index.concat(".amount"), item.getAmount()); requestMap.putInteger(index.concat(".quantity"), item.getQuantity()); requestMap.putInteger(index.concat(".weight"), item.getWeight()); requestMap.putCurrency(index.concat(".shippingCost"), item.getShippingCost()); i++; } }  }
PaymentItemsV3MapConverter extends AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { String index = String.format("item[%d]", i); requestMap.putString(index.concat(".id"), item.getId()); requestMap.putString(index.concat(".description"), item.getDescription()); requestMap.putCurrency(index.concat(".amount"), item.getAmount()); requestMap.putInteger(index.concat(".quantity"), item.getQuantity()); requestMap.putInteger(index.concat(".weight"), item.getWeight()); requestMap.putCurrency(index.concat(".shippingCost"), item.getShippingCost()); i++; } }   }
PaymentItemsV3MapConverter extends AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { String index = String.format("item[%d]", i); requestMap.putString(index.concat(".id"), item.getId()); requestMap.putString(index.concat(".description"), item.getDescription()); requestMap.putCurrency(index.concat(".amount"), item.getAmount()); requestMap.putInteger(index.concat(".quantity"), item.getQuantity()); requestMap.putInteger(index.concat(".weight"), item.getWeight()); requestMap.putCurrency(index.concat(".shippingCost"), item.getShippingCost()); i++; } }    }