Package com.xebia.lottery.events

Examples of com.xebia.lottery.events.CustomerBalanceChangedEvent


    }
   
    public Customer(VersionedId customerId, CustomerInfo customerInfo, double initialAccountBalance) {
        super(customerId);
        apply(new CustomerCreatedEvent(customerId, customerInfo));
        apply(new CustomerBalanceChangedEvent(customerId, 0.0, initialAccountBalance, initialAccountBalance));
    }
View Full Code Here


        return this.accountBalance >= amount;
    }

    public void deductBalance(double amount) {
        Validate.isTrue(isBalanceSufficient(amount), "insufficient balance");
        apply(new CustomerBalanceChangedEvent(getVersionedId(), this.accountBalance, -amount, this.accountBalance - amount));
    }
View Full Code Here

    @Test
    public void findCustomers() {
        assertTrue(lotteryQueryService.findCustomers().isEmpty());

        customerCreatedEventHandler.handleMessage(new CustomerCreatedEvent(WhenCustomerIsCreated.CUSTOMER_ID, WhenCustomerIsCreated.CUSTOMER_INFO));
        customerBalanceChangedEventHandler.handleMessage(new CustomerBalanceChangedEvent(WhenCustomerIsCreated.CUSTOMER_ID, 0.0, 50.0, 50.0));

        List<CustomerAccountQueryResult> customers = lotteryQueryService.findCustomers();
        assertEquals(1, customers.size());
        CustomerAccountQueryResult customer = customers.get(0);
        assertEquals(WhenCustomerIsCreated.CUSTOMER_ID, customer.getCustomerId());
View Full Code Here

    @Override
    protected void given() {
        customer = new Customer(CUSTOMER_ID);
        customer.loadFromHistory(asList(
                new CustomerCreatedEvent(CUSTOMER_ID, CUSTOMER_INFO),
                new CustomerBalanceChangedEvent(CUSTOMER_ID, 0, 50, 50)));
       
        lottery = new Lottery(LOTTERY_ID);
        lottery.loadFromHistory(asList(new LotteryCreatedEvent(LOTTERY_ID, LOTTER_INFO)));
    }
View Full Code Here

   
    @Test
    public void shouldDeductTicketPriceFromCustomerBalance() {
        assertChange(
                customer,
                new CustomerBalanceChangedEvent(CUSTOMER_ID, 50, -15, 35));
    }
View Full Code Here

        assertChange(subject, new CustomerCreatedEvent(CUSTOMER_ID, CUSTOMER_INFO));
    }
   
    @Test
    public void shouldGiveCustomerInitialBalance() {
        assertChange(subject, new CustomerBalanceChangedEvent(CUSTOMER_ID, 0,10.0, 10.0));
    }
View Full Code Here

TOP

Related Classes of com.xebia.lottery.events.CustomerBalanceChangedEvent

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.