Package com.xebia.lottery.commands

Examples of com.xebia.lottery.commands.ValidationError


    @Autowired private Bus bus;
   
    public Customer create(VersionedId customerId, CustomerInfo info, double initialAccountBalance) {
        List<ValidationError> errors = new ArrayList<ValidationError>();
        if (StringUtils.isBlank(info.getName())) {
            errors.add(new ValidationError("customer name is required"));
        }
        if (initialAccountBalance < 10.0) {
            errors.add(new ValidationError("minimum account balance is 10.00"));
        }
        if (errors.isEmpty()) {
            return new Customer(customerId, info, initialAccountBalance);
        } else {
            bus.reply(errors);
View Full Code Here


        apply(new LotteryCreatedEvent(id,  info));
    }

    public void purchaseTicketForCustomer(Customer customer) {
        if (!customer.isBalanceSufficient(this.ticketPrice)) {
            notify(new ValidationError("insufficient account balance to purchase ticket"));
            return;
        }
       
        customer.deductBalance(this.ticketPrice);
        apply(new LotteryTicketPurchasedEvent(aggregate.getVersionedId(), customer.getVersionedId(), generateTicketNumber()));
View Full Code Here

TOP

Related Classes of com.xebia.lottery.commands.ValidationError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.