PaymentProcessorFactoryImpl implements ApplicationContextAware, PaymentProcessorFactory { @Override public PaymentProcessor create(final String paymentGatewayLabel, final String shopCode) { final PaymentProcessor paymentProcessor = (PaymentProcessor) applicationContext.getBean(paymentProcessorBeanId); paymentProcessor.setPaymentGateway( paymentModulesManager.getPaymentGateway(paymentGatewayLabel, shopCode) ); return paymentProcessor; } PaymentProcessorFactoryImpl(final PaymentModulesManager paymentModulesManager, final String paymentProcessorBeanId); @Override void setApplicationContext(final ApplicationContext applicationContext); @Override PaymentProcessor create(final String paymentGatewayLabel, final String shopCode);  }
@Test public void testCreate() { PaymentProcessor paymentProcessor0 = paymentProcessorFactory.create("testPaymentGatewayLabel", "SHOIP1"); PaymentProcessor paymentProcessor1 = paymentProcessorFactory.create("testPaymentGatewayLabel", "SHOIP1"); assertNotSame(paymentProcessor0, paymentProcessor1); }