@Test public void shouldConvert() throws Exception { RequestMap expectedMap = new RequestMap(); expectedMap.putMap(new HashMap<String, String>() {{ put("itemId1", "1"); put("itemDescription1", "description1"); put("itemAmount1", "99.99"); put("itemQuantity1", "7"); put("itemWeight1", "123"); put("itemShippingCost1", "99.99"); put("itemId2", "2"); put("itemDescription2", "description2"); put("itemAmount2", "99.99"); put("itemQuantity2", "7"); put("itemWeight2", "123"); put("itemShippingCost2", "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) { requestMap.putString(String.format("itemId%d", i), item.getId()); requestMap.putString(String.format("itemDescription%d", i), item.getDescription()); requestMap.putCurrency(String.format("itemAmount%d", i), item.getAmount()); requestMap.putInteger(String.format("itemQuantity%d", i), item.getQuantity()); requestMap.putInteger(String.format("itemWeight%d", i), item.getWeight()); requestMap.putCurrency(String.format("itemShippingCost%d", i), item.getShippingCost()); i++; } }
PaymentItemsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { requestMap.putString(String.format("itemId%d", i), item.getId()); requestMap.putString(String.format("itemDescription%d", i), item.getDescription()); requestMap.putCurrency(String.format("itemAmount%d", i), item.getAmount()); requestMap.putInteger(String.format("itemQuantity%d", i), item.getQuantity()); requestMap.putInteger(String.format("itemWeight%d", i), item.getWeight()); requestMap.putCurrency(String.format("itemShippingCost%d", i), item.getShippingCost()); i++; } } }
PaymentItemsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { requestMap.putString(String.format("itemId%d", i), item.getId()); requestMap.putString(String.format("itemDescription%d", i), item.getDescription()); requestMap.putCurrency(String.format("itemAmount%d", i), item.getAmount()); requestMap.putInteger(String.format("itemQuantity%d", i), item.getQuantity()); requestMap.putInteger(String.format("itemWeight%d", i), item.getWeight()); requestMap.putCurrency(String.format("itemShippingCost%d", i), item.getShippingCost()); i++; } }  }
PaymentItemsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { requestMap.putString(String.format("itemId%d", i), item.getId()); requestMap.putString(String.format("itemDescription%d", i), item.getDescription()); requestMap.putCurrency(String.format("itemAmount%d", i), item.getAmount()); requestMap.putInteger(String.format("itemQuantity%d", i), item.getQuantity()); requestMap.putInteger(String.format("itemWeight%d", i), item.getWeight()); requestMap.putCurrency(String.format("itemShippingCost%d", i), item.getShippingCost()); i++; } }   }
PaymentItemsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentItem>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentItem> items) { int i = 1; for (PaymentItem item : items) { requestMap.putString(String.format("itemId%d", i), item.getId()); requestMap.putString(String.format("itemDescription%d", i), item.getDescription()); requestMap.putCurrency(String.format("itemAmount%d", i), item.getAmount()); requestMap.putInteger(String.format("itemQuantity%d", i), item.getQuantity()); requestMap.putInteger(String.format("itemWeight%d", i), item.getWeight()); requestMap.putCurrency(String.format("itemShippingCost%d", i), item.getShippingCost()); i++; } }    }