@Test public void testGetParameterValue() throws Exception { final PaymentGatewayParameter defParam = mockery.mock(PaymentGatewayParameter.class, "defParam"); final PaymentGatewayParameter shopParam = mockery.mock(PaymentGatewayParameter.class, "shopParam"); final PaymentGatewayConfigurationVisitor visitor = mockery.mock(PaymentGatewayConfigurationVisitor.class, "visitor"); mockery.checking(new Expectations() {{ allowing(defParam).getLabel(); will(returnValue("param")); allowing(defParam).getValue(); will(returnValue("value")); allowing(shopParam).getLabel(); will(returnValue("#SHOP10_param")); allowing(shopParam).getValue(); will(returnValue("shopvalue")); allowing(visitor).getConfiguration("shopCode"); will(returnValue("SHOP10")); allowing(visitor).getConfiguration("label"); will(returnValue("PostFinance")); }}); final AbstractPostFinancePaymentGatewayImpl pg = new AbstractPostFinancePaymentGatewayImpl() { @Override public Payment authorizeCapture(final Payment payment, final boolean forceProcessing) { return null; } @Override public Payment authorize(final Payment payment, final boolean forceProcessing) { return null; } @Override public Payment reverseAuthorization(final Payment payment, final boolean forceProcessing) { return null; } @Override public Payment capture(final Payment payment, final boolean forceProcessing) { return null; } @Override public Payment voidCapture(final Payment payment, final boolean forceProcessing) { return null; } @Override public Payment refund(final Payment payment, final boolean forceProcessing) { return null; } @Override public PaymentGatewayFeature getPaymentGatewayFeatures() { return null; } @Override public Collection<PaymentGatewayParameter> getPaymentGatewayParameters() { return Arrays.asList(defParam, shopParam); } @Override public String getHtmlForm(final String cardHolderName, final String locale, final BigDecimal amount, final String currencyCode, final String orderReference, final Payment payment) { return null; } @Override public Payment createPaymentPrototype(final String operation, final Map map, final boolean forceProcessing) { return null; } }; assertEquals("value", pg.getParameterValue("param")); pg.accept(visitor); assertEquals("shopvalue", pg.getParameterValue("param")); assertNull(pg.getParameterValue(null)); assertNull(pg.getParameterValue("#SHOP10_param")); }
@Override public String getParameterValue(final String valueLabel) { if (valueLabel == null || valueLabel.startsWith("#")) { return null; } if (shopCode != null && !"DEFAULT".equals(shopCode)) { final String shopSpecific = getParameterValueInternal("#" + shopCode + "_" + valueLabel); if (shopSpecific != null) { return shopSpecific; } } return getParameterValueInternal(valueLabel); }
AbstractPostFinancePaymentGatewayImpl implements ConfigurablePaymentGateway, PaymentGateway { @Override public String getParameterValue(final String valueLabel) { if (valueLabel == null || valueLabel.startsWith("#")) { return null; } if (shopCode != null && !"DEFAULT".equals(shopCode)) { final String shopSpecific = getParameterValueInternal("#" + shopCode + "_" + valueLabel); if (shopSpecific != null) { return shopSpecific; } } return getParameterValueInternal(valueLabel); } }
AbstractPostFinancePaymentGatewayImpl implements ConfigurablePaymentGateway, PaymentGateway { @Override public String getParameterValue(final String valueLabel) { if (valueLabel == null || valueLabel.startsWith("#")) { return null; } if (shopCode != null && !"DEFAULT".equals(shopCode)) { final String shopSpecific = getParameterValueInternal("#" + shopCode + "_" + valueLabel); if (shopSpecific != null) { return shopSpecific; } } return getParameterValueInternal(valueLabel); }  }
AbstractPostFinancePaymentGatewayImpl implements ConfigurablePaymentGateway, PaymentGateway { @Override public String getParameterValue(final String valueLabel) { if (valueLabel == null || valueLabel.startsWith("#")) { return null; } if (shopCode != null && !"DEFAULT".equals(shopCode)) { final String shopSpecific = getParameterValueInternal("#" + shopCode + "_" + valueLabel); if (shopSpecific != null) { return shopSpecific; } } return getParameterValueInternal(valueLabel); }  @Override String getShopCode(); @Override String getLabel(); @Override String getName(final String locale); @Override Collection<PaymentGatewayParameter> getPaymentGatewayParameters(); @Override void deleteParameter(final String parameterLabel); @Override void addParameter(final PaymentGatewayParameter paymentGatewayParameter); @Override void updateParameter(final PaymentGatewayParameter paymentGatewayParameter); void setPaymentGatewayParameterService(
            final PaymentGatewayParameterService paymentGatewayParameterService); @Override String getParameterValue(final String valueLabel); static String dump(Map<?, ?> map); @Override void accept(final PaymentGatewayConfigurationVisitor visitor); }
AbstractPostFinancePaymentGatewayImpl implements ConfigurablePaymentGateway, PaymentGateway { @Override public String getParameterValue(final String valueLabel) { if (valueLabel == null || valueLabel.startsWith("#")) { return null; } if (shopCode != null && !"DEFAULT".equals(shopCode)) { final String shopSpecific = getParameterValueInternal("#" + shopCode + "_" + valueLabel); if (shopSpecific != null) { return shopSpecific; } } return getParameterValueInternal(valueLabel); }  @Override String getShopCode(); @Override String getLabel(); @Override String getName(final String locale); @Override Collection<PaymentGatewayParameter> getPaymentGatewayParameters(); @Override void deleteParameter(final String parameterLabel); @Override void addParameter(final PaymentGatewayParameter paymentGatewayParameter); @Override void updateParameter(final PaymentGatewayParameter paymentGatewayParameter); void setPaymentGatewayParameterService(
            final PaymentGatewayParameterService paymentGatewayParameterService); @Override String getParameterValue(final String valueLabel); static String dump(Map<?, ?> map); @Override void accept(final PaymentGatewayConfigurationVisitor visitor);  }