Search in sources :

Example 1 with CheckingAccountEntity

use of org.qi4j.dci.moneytransfer.domain.entity.CheckingAccountEntity in project qi4j-sdk by Qi4j.

the class TransferMoneyTest method bootstrapData.

private static void bootstrapData(SingletonAssembler assembler) throws Exception {
    UnitOfWork uow = assembler.module().newUnitOfWork(newUsecase("Bootstrap data"));
    try {
        SavingsAccountEntity savingsAccount = uow.newEntity(SavingsAccountEntity.class, SAVINGS_ACCOUNT_ID);
        savingsAccount.increasedBalance(1000);
        CheckingAccountEntity checkingAccount = uow.newEntity(CheckingAccountEntity.class, CHECKING_ACCOUNT_ID);
        checkingAccount.increasedBalance(200);
        // Create some creditor debt
        BalanceData bakerAccount = uow.newEntity(CreditorRolemap.class, CREDITOR_ID1);
        bakerAccount.decreasedBalance(50);
        BalanceData butcherAccount = uow.newEntity(CreditorRolemap.class, CREDITOR_ID2);
        butcherAccount.decreasedBalance(90);
        // Save
        uow.complete();
    } finally {
        uow.discard();
    }
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) SavingsAccountEntity(org.qi4j.dci.moneytransfer.domain.entity.SavingsAccountEntity) BalanceData(org.qi4j.dci.moneytransfer.domain.data.BalanceData) CheckingAccountEntity(org.qi4j.dci.moneytransfer.domain.entity.CheckingAccountEntity)

Example 2 with CheckingAccountEntity

use of org.qi4j.dci.moneytransfer.domain.entity.CheckingAccountEntity in project qi4j-sdk by Qi4j.

the class TransferMoneyTest2 method bootstrapData.

private static void bootstrapData() throws Exception {
    UnitOfWork uow = module.newUnitOfWork(newUsecase("Bootstrap data"));
    try {
        SavingsAccountEntity account = uow.newEntity(SavingsAccountEntity.class, SAVINGS_ACCOUNT_ID);
        account.increasedBalance(1000);
        CheckingAccountEntity checkingAccount = uow.newEntity(CheckingAccountEntity.class, CHECKING_ACCOUNT_ID);
        checkingAccount.increasedBalance(200);
        // Create some creditor debt
        BalanceData bakerAccount = uow.newEntity(CreditorEntity.class, CREDITOR_ID1);
        bakerAccount.decreasedBalance(50);
        BalanceData butcherAccount = uow.newEntity(CreditorEntity.class, CREDITOR_ID2);
        butcherAccount.decreasedBalance(90);
        // Save
        uow.complete();
    } finally {
        uow.discard();
    }
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) SavingsAccountEntity(org.qi4j.dci.moneytransfer.domain.entity.SavingsAccountEntity) BalanceData(org.qi4j.dci.moneytransfer.domain.data.BalanceData) CheckingAccountEntity(org.qi4j.dci.moneytransfer.domain.entity.CheckingAccountEntity)

Aggregations

UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)2 BalanceData (org.qi4j.dci.moneytransfer.domain.data.BalanceData)2 CheckingAccountEntity (org.qi4j.dci.moneytransfer.domain.entity.CheckingAccountEntity)2 SavingsAccountEntity (org.qi4j.dci.moneytransfer.domain.entity.SavingsAccountEntity)2