feat: 申请单开发
parent
3fe5635b08
commit
f0250d96d9
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.bs.service.expenseapplytrip;
|
||||
package cn.iocoder.yudao.module.bpm.service.expenseapplytrip;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.bs.service.expenseapplytrip;
|
||||
package cn.iocoder.yudao.module.bpm.service.expenseapplytrip;
|
||||
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapplytrip.ExpenseApplyTripDO;
|
||||
import cn.iocoder.yudao.module.bs.dal.mysql.expenseapplytrip.ExpenseApplyTripMapper;
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.oa.listener;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEvent;
|
||||
import cn.iocoder.yudao.module.bpm.framework.bpm.core.event.BpmProcessInstanceResultEventListener;
|
||||
import cn.iocoder.yudao.module.bpm.service.expenseapply.ExpenseApplyServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* OA 请假单的结果的监听器实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class ExpenseApplyResultListener extends BpmProcessInstanceResultEventListener {
|
||||
|
||||
@Resource
|
||||
private ExpenseApplyServiceImpl expenseApplyService;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return ExpenseApplyServiceImpl.PROCESS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceResultEvent event) {
|
||||
expenseApplyService.processInstanceCallBack(Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||
}
|
||||
|
||||
}
|
@ -1,259 +0,0 @@
|
||||
package cn.iocoder.yudao.module.bs.service.expenseapply;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyExportReqVO;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyPageReqVO;
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.ExpenseApplyUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO;
|
||||
import cn.iocoder.yudao.module.bs.dal.mysql.expenseapply.ExpenseApplyMapper;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.EXPENSE_APPLY_NOT_EXISTS;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* {@link ExpenseApplyServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(ExpenseApplyServiceImpl.class)
|
||||
public class ExpenseApplyServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ExpenseApplyServiceImpl expenseApplyService;
|
||||
|
||||
@Resource
|
||||
private ExpenseApplyMapper expenseApplyMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateExpenseApply_success() {
|
||||
// 准备参数
|
||||
ExpenseApplyCreateReqVO reqVO = randomPojo(ExpenseApplyCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
// Long expenseApplyId = expenseApplyService.createExpenseApply(reqVO);
|
||||
// // 断言
|
||||
// assertNotNull(expenseApplyId);
|
||||
// // 校验记录的属性是否正确
|
||||
// ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(expenseApplyId);
|
||||
// assertPojoEquals(reqVO, expenseApply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateExpenseApply_success() {
|
||||
// mock 数据
|
||||
ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class);
|
||||
expenseApplyMapper.insert(dbExpenseApply);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ExpenseApplyUpdateReqVO reqVO = randomPojo(ExpenseApplyUpdateReqVO.class, o -> {
|
||||
o.setId(dbExpenseApply.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
expenseApplyService.updateExpenseApply(reqVO);
|
||||
// 校验是否更新正确
|
||||
ExpenseApplyDO expenseApply = expenseApplyMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, expenseApply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateExpenseApply_notExists() {
|
||||
// 准备参数
|
||||
ExpenseApplyUpdateReqVO reqVO = randomPojo(ExpenseApplyUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> expenseApplyService.updateExpenseApply(reqVO), EXPENSE_APPLY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteExpenseApply_success() {
|
||||
// mock 数据
|
||||
ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class);
|
||||
expenseApplyMapper.insert(dbExpenseApply);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbExpenseApply.getId();
|
||||
|
||||
// 调用
|
||||
expenseApplyService.deleteExpenseApply(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(expenseApplyMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteExpenseApply_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> expenseApplyService.deleteExpenseApply(id), EXPENSE_APPLY_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetExpenseApplyPage() {
|
||||
// mock 数据
|
||||
ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class, o -> { // 等会查询到
|
||||
o.setBillType(null);
|
||||
o.setApplyNo(null);
|
||||
o.setUserId(null);
|
||||
o.setNickname(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setProjectName(null);
|
||||
o.setReason(null);
|
||||
o.setAmount(null);
|
||||
o.setStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setFiles(null);
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setUpdateBy(null);
|
||||
});
|
||||
expenseApplyMapper.insert(dbExpenseApply);
|
||||
// 测试 billType 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setBillType(null)));
|
||||
// 测试 applyNo 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setApplyNo(null)));
|
||||
// 测试 userId 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUserId(null)));
|
||||
// 测试 nickname 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setNickname(null)));
|
||||
// 测试 deptId 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptName(null)));
|
||||
// 测试 projectName 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setProjectName(null)));
|
||||
// 测试 reason 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setReason(null)));
|
||||
// 测试 amount 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setAmount(null)));
|
||||
// 测试 status 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setRemark(null)));
|
||||
// 测试 files 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setFiles(null)));
|
||||
// 测试 createBy 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateTime(null)));
|
||||
// 测试 updateBy 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUpdateBy(null)));
|
||||
// 准备参数
|
||||
ExpenseApplyPageReqVO reqVO = new ExpenseApplyPageReqVO();
|
||||
reqVO.setBillType(null);
|
||||
reqVO.setApplyNo(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setNickname(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setProjectName(null);
|
||||
reqVO.setReason(null);
|
||||
reqVO.setAmount(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setFiles(null);
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setUpdateBy(null);
|
||||
|
||||
// 调用
|
||||
PageResult<ExpenseApplyDO> pageResult = expenseApplyService.getExpenseApplyPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbExpenseApply, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetExpenseApplyList() {
|
||||
// mock 数据
|
||||
ExpenseApplyDO dbExpenseApply = randomPojo(ExpenseApplyDO.class, o -> { // 等会查询到
|
||||
o.setBillType(null);
|
||||
o.setApplyNo(null);
|
||||
o.setUserId(null);
|
||||
o.setNickname(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setProjectName(null);
|
||||
o.setReason(null);
|
||||
o.setAmount(null);
|
||||
o.setStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setFiles(null);
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setUpdateBy(null);
|
||||
});
|
||||
expenseApplyMapper.insert(dbExpenseApply);
|
||||
// 测试 billType 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setBillType(null)));
|
||||
// 测试 applyNo 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setApplyNo(null)));
|
||||
// 测试 userId 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUserId(null)));
|
||||
// 测试 nickname 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setNickname(null)));
|
||||
// 测试 deptId 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setDeptName(null)));
|
||||
// 测试 projectName 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setProjectName(null)));
|
||||
// 测试 reason 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setReason(null)));
|
||||
// 测试 amount 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setAmount(null)));
|
||||
// 测试 status 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setRemark(null)));
|
||||
// 测试 files 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setFiles(null)));
|
||||
// 测试 createBy 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setCreateTime(null)));
|
||||
// 测试 updateBy 不匹配
|
||||
expenseApplyMapper.insert(cloneIgnoreId(dbExpenseApply, o -> o.setUpdateBy(null)));
|
||||
// 准备参数
|
||||
ExpenseApplyExportReqVO reqVO = new ExpenseApplyExportReqVO();
|
||||
reqVO.setBillType(null);
|
||||
reqVO.setApplyNo(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setNickname(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setProjectName(null);
|
||||
reqVO.setReason(null);
|
||||
reqVO.setAmount(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setFiles(null);
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setUpdateBy(null);
|
||||
|
||||
// 调用
|
||||
List<ExpenseApplyDO> list = expenseApplyService.getExpenseApplyList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbExpenseApply, list.get(0));
|
||||
}
|
||||
|
||||
}
|
@ -1,263 +0,0 @@
|
||||
package cn.iocoder.yudao.module.bs.service.invoice;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.*;
|
||||
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
|
||||
import cn.iocoder.yudao.module.bs.dal.mysql.invoice.InvoiceMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link InvoiceServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author chenqp
|
||||
*/
|
||||
@Import(InvoiceServiceImpl.class)
|
||||
public class InvoiceServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private InvoiceServiceImpl invoiceService;
|
||||
|
||||
@Resource
|
||||
private InvoiceMapper invoiceMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateInvoice_success() {
|
||||
// 准备参数
|
||||
InvoiceCreateReqVO reqVO = randomPojo(InvoiceCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long invoiceId = invoiceService.createInvoice(reqVO);
|
||||
// 断言
|
||||
assertNotNull(invoiceId);
|
||||
// 校验记录的属性是否正确
|
||||
InvoiceDO invoice = invoiceMapper.selectById(invoiceId);
|
||||
assertPojoEquals(reqVO, invoice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateInvoice_success() {
|
||||
// mock 数据
|
||||
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class);
|
||||
invoiceMapper.insert(dbInvoice);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
InvoiceUpdateReqVO reqVO = randomPojo(InvoiceUpdateReqVO.class, o -> {
|
||||
o.setId(dbInvoice.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
invoiceService.updateInvoice(reqVO);
|
||||
// 校验是否更新正确
|
||||
InvoiceDO invoice = invoiceMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, invoice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateInvoice_notExists() {
|
||||
// 准备参数
|
||||
InvoiceUpdateReqVO reqVO = randomPojo(InvoiceUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> invoiceService.updateInvoice(reqVO), INVOICE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteInvoice_success() {
|
||||
// mock 数据
|
||||
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class);
|
||||
invoiceMapper.insert(dbInvoice);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbInvoice.getId();
|
||||
|
||||
// 调用
|
||||
invoiceService.deleteInvoice(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(invoiceMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteInvoice_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> invoiceService.deleteInvoice(id), INVOICE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetInvoicePage() {
|
||||
// mock 数据
|
||||
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class, o -> { // 等会查询到
|
||||
o.setFiles(null);
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setUpdateBy(null);
|
||||
o.setInvoiceType(null);
|
||||
o.setInvoiceCode(null);
|
||||
o.setInvoiceNum(null);
|
||||
o.setInvoiceDate(null);
|
||||
o.setSeller(null);
|
||||
o.setTaxAmount(null);
|
||||
o.setExcludingTaxAmount(null);
|
||||
o.setTotalAmount(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setRemark(null);
|
||||
});
|
||||
invoiceMapper.insert(dbInvoice);
|
||||
// 测试 files 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setFiles(null)));
|
||||
// 测试 createBy 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateTime(null)));
|
||||
// 测试 updateBy 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setUpdateBy(null)));
|
||||
// 测试 invoiceType 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceType(null)));
|
||||
// 测试 invoiceCode 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceCode(null)));
|
||||
// 测试 invoiceNum 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceNum(null)));
|
||||
// 测试 invoiceDate 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceDate(null)));
|
||||
// 测试 seller 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setSeller(null)));
|
||||
// 测试 taxAmount 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTaxAmount(null)));
|
||||
// 测试 excludingTaxAmount 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setExcludingTaxAmount(null)));
|
||||
// 测试 totalAmount 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTotalAmount(null)));
|
||||
// 测试 deptId 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptName(null)));
|
||||
// 测试 remark 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setRemark(null)));
|
||||
// 准备参数
|
||||
InvoicePageReqVO reqVO = new InvoicePageReqVO();
|
||||
reqVO.setFiles(null);
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setUpdateBy(null);
|
||||
reqVO.setInvoiceType(null);
|
||||
reqVO.setInvoiceCode(null);
|
||||
reqVO.setInvoiceNum(null);
|
||||
reqVO.setInvoiceDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setSeller(null);
|
||||
reqVO.setTaxAmount(null);
|
||||
reqVO.setExcludingTaxAmount(null);
|
||||
reqVO.setTotalAmount(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setRemark(null);
|
||||
|
||||
// 调用
|
||||
PageResult<InvoiceDO> pageResult = invoiceService.getInvoicePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbInvoice, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetInvoiceList() {
|
||||
// mock 数据
|
||||
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class, o -> { // 等会查询到
|
||||
o.setFiles(null);
|
||||
o.setCreateBy(null);
|
||||
o.setCreateTime(null);
|
||||
o.setUpdateBy(null);
|
||||
o.setInvoiceType(null);
|
||||
o.setInvoiceCode(null);
|
||||
o.setInvoiceNum(null);
|
||||
o.setInvoiceDate(null);
|
||||
o.setSeller(null);
|
||||
o.setTaxAmount(null);
|
||||
o.setExcludingTaxAmount(null);
|
||||
o.setTotalAmount(null);
|
||||
o.setDeptId(null);
|
||||
o.setDeptName(null);
|
||||
o.setRemark(null);
|
||||
});
|
||||
invoiceMapper.insert(dbInvoice);
|
||||
// 测试 files 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setFiles(null)));
|
||||
// 测试 createBy 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateBy(null)));
|
||||
// 测试 createTime 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateTime(null)));
|
||||
// 测试 updateBy 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setUpdateBy(null)));
|
||||
// 测试 invoiceType 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceType(null)));
|
||||
// 测试 invoiceCode 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceCode(null)));
|
||||
// 测试 invoiceNum 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceNum(null)));
|
||||
// 测试 invoiceDate 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceDate(null)));
|
||||
// 测试 seller 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setSeller(null)));
|
||||
// 测试 taxAmount 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTaxAmount(null)));
|
||||
// 测试 excludingTaxAmount 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setExcludingTaxAmount(null)));
|
||||
// 测试 totalAmount 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTotalAmount(null)));
|
||||
// 测试 deptId 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptName(null)));
|
||||
// 测试 remark 不匹配
|
||||
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setRemark(null)));
|
||||
// 准备参数
|
||||
InvoiceExportReqVO reqVO = new InvoiceExportReqVO();
|
||||
reqVO.setFiles(null);
|
||||
reqVO.setCreateBy(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setUpdateBy(null);
|
||||
reqVO.setInvoiceType(null);
|
||||
reqVO.setInvoiceCode(null);
|
||||
reqVO.setInvoiceNum(null);
|
||||
reqVO.setInvoiceDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setSeller(null);
|
||||
reqVO.setTaxAmount(null);
|
||||
reqVO.setExcludingTaxAmount(null);
|
||||
reqVO.setTotalAmount(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setRemark(null);
|
||||
|
||||
// 调用
|
||||
List<InvoiceDO> list = invoiceService.getInvoiceList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbInvoice, list.get(0));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue