@Test public void shouldConvert() throws Exception { RequestMap expectedMap = new RequestMap(); expectedMap.putMap(new HashMap<String, String>() {{ put("paymentMethodGroup1", "BALANCE"); put("paymentMethodConfigKey1_1", "DISCOUNT_PERCENT"); put("paymentMethodConfigValue1_1", "10.00"); put("paymentMethodGroup2", "CREDIT_CARD"); put("paymentMethodConfigKey2_1", "MAX_INSTALLMENTS_NO_INTEREST"); put("paymentMethodConfigValue2_1", "2"); }}); RequestMap map = mapConverter.convert(paymentMethodConfigs); assertEquals(expectedMap, map); }
@Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentMethodConfig> paymentMethodConfigs) { int i = 1; for (PaymentMethodConfig paymentMethodConfig : paymentMethodConfigs) { if (paymentMethodConfig.getPaymentMethod().getGroup() != null) { requestMap.putString(String.format("paymentMethodGroup%d", i), paymentMethodConfig.getPaymentMethod().getGroup().getValue()); requestMap.putString(String.format("paymentMethodConfigKey%d_1", i), paymentMethodConfig.getConfig().getKey().getValue()); requestMap.putConfigValue(String.format("paymentMethodConfigValue%d_1", i), paymentMethodConfig.getConfig()); i++; } } }
PaymentMethodConfigsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentMethodConfig>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentMethodConfig> paymentMethodConfigs) { int i = 1; for (PaymentMethodConfig paymentMethodConfig : paymentMethodConfigs) { if (paymentMethodConfig.getPaymentMethod().getGroup() != null) { requestMap.putString(String.format("paymentMethodGroup%d", i), paymentMethodConfig.getPaymentMethod().getGroup().getValue()); requestMap.putString(String.format("paymentMethodConfigKey%d_1", i), paymentMethodConfig.getConfig().getKey().getValue()); requestMap.putConfigValue(String.format("paymentMethodConfigValue%d_1", i), paymentMethodConfig.getConfig()); i++; } } } }
PaymentMethodConfigsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentMethodConfig>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentMethodConfig> paymentMethodConfigs) { int i = 1; for (PaymentMethodConfig paymentMethodConfig : paymentMethodConfigs) { if (paymentMethodConfig.getPaymentMethod().getGroup() != null) { requestMap.putString(String.format("paymentMethodGroup%d", i), paymentMethodConfig.getPaymentMethod().getGroup().getValue()); requestMap.putString(String.format("paymentMethodConfigKey%d_1", i), paymentMethodConfig.getConfig().getKey().getValue()); requestMap.putConfigValue(String.format("paymentMethodConfigValue%d_1", i), paymentMethodConfig.getConfig()); i++; } } }  }
PaymentMethodConfigsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentMethodConfig>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentMethodConfig> paymentMethodConfigs) { int i = 1; for (PaymentMethodConfig paymentMethodConfig : paymentMethodConfigs) { if (paymentMethodConfig.getPaymentMethod().getGroup() != null) { requestMap.putString(String.format("paymentMethodGroup%d", i), paymentMethodConfig.getPaymentMethod().getGroup().getValue()); requestMap.putString(String.format("paymentMethodConfigKey%d_1", i), paymentMethodConfig.getConfig().getKey().getValue()); requestMap.putConfigValue(String.format("paymentMethodConfigValue%d_1", i), paymentMethodConfig.getConfig()); i++; } } }   }
PaymentMethodConfigsV2MapConverter extends
    AbstractMapConverter<Iterable<? extends PaymentMethodConfig>> { @Override protected void convert(RequestMap requestMap, Iterable<? extends PaymentMethodConfig> paymentMethodConfigs) { int i = 1; for (PaymentMethodConfig paymentMethodConfig : paymentMethodConfigs) { if (paymentMethodConfig.getPaymentMethod().getGroup() != null) { requestMap.putString(String.format("paymentMethodGroup%d", i), paymentMethodConfig.getPaymentMethod().getGroup().getValue()); requestMap.putString(String.format("paymentMethodConfigKey%d_1", i), paymentMethodConfig.getConfig().getKey().getValue()); requestMap.putConfigValue(String.format("paymentMethodConfigValue%d_1", i), paymentMethodConfig.getConfig()); i++; } } }    }