As a good practice, we'll define an interface for interacting with the other system. We'll introduce a LegacyBankService
interface for this purpose. It will make it easier to change the way we communicate with the legacy system, and also the tests will be easier to write.
package droolsbook.transform.service; import java.util.List; import java.util.Map; public interface LegacyBankService { /** * @return all customers */ List<Map<String, Object>> findAllCustomers(); /** * @return addresses for specified customer id */ List<Map<String, Object>> findAddressByCustomerId( Long customerId); /** * @return accounts for specified customer id */ List<Map<String, Object>> findAccountByCustomerId( Long customerId); }
Code listing 1: Interface that abstracts the legacy system interactions
The interface defines three methods. The first one can retrieve a list of all customers, and the second and third ones...