package com;


import com.transaction_anno.entity.AccountEntity;
import com.transaction_anno.service.AccountService;
import com.transaction_anno.service.AccountTwoService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:context.xml")
public class TestTx {

    @Autowired
    AccountService accountService;
    @Autowired
    AccountTwoService accountTwoService;
    @Test
    public void transformAnno() {
        // 转账操作
        AccountEntity reduceEntity = new AccountEntity();
        AccountEntity addEntity = new AccountEntity();
        reduceEntity.setId(16).setBalance(3.0);
        addEntity.setId(17).setBalance(3.0);
        accountService.reduceAccount(reduceEntity);
        accountTwoService.addAccountBalance(addEntity);
    }
}
