All rules are implemented the unit tests, and we can write a validation service that our clients can access. It will define one method for validating a customer. This is the BankingValidationService
interface:
/** * service for validating the banking domain */ public interface BankingValidationService { /** * validates given customer and returns validation report */ ValidationReport validate(Customer customer); }
Code listing 21: Banking validation service interface
The interface defines one method that validates a Customer
object and returns the ValidationReport
interface. Since, in our domain model, all objects are accessible (traversable) from the Customer
object, it is sufficient to just pass this class as the method parameter. The implementation is more interesting:
public class BankingValidationServiceImpl implements BankingValidationService { private KnowledgeBase knowledgeBase; private ReportFactory reportFactory; private BankingInquiryService...