package com.mzt.logserver;
import com.google.common.collect.Lists;
import com.mzt.logapi.beans.CodeVariableType;
import com.mzt.logapi.beans.LogRecord;
import com.mzt.logserver.infrastructure.constants.LogRecordType;
import com.mzt.logserver.infrastructure.logrecord.service.DbLogRecordService;
import com.mzt.logserver.pojo.Order;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.test.context.jdbc.Sql;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
public class IOrderServiceTest extends BaseTest {
@Resource
private IOrderService orderService;
@Resource
private DbLogRecordService logRecordService;
@Test
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void createOrder() {
Order order = new Order();
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
orderService.createOrder(order);
List<LogRecord> logRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.ORDER);
Assert.assertEquals(1, logRecordList.size());
LogRecord logRecord = logRecordList.get(0);
Assert.assertEquals(logRecord.getAction(), "张三下了一个订单,购买商品「超值优惠红烧肉套餐」,测试变量「内部变量测试」,下单结果:true");
Assert.assertEquals(logRecord.getSubType(), "MANAGER_VIEW");
Assert.assertNotNull(logRecord.getExtra());
Assert.assertEquals(logRecord.getBizNo(), order.getOrderNo());
Assert.assertFalse(logRecord.isFail());
logRecordService.clean();
}
@Test
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void createOrders() {
Order order = new Order();
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
orderService.createOrders(order);
List<LogRecord> logRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.ORDER);
Assert.assertEquals(1, logRecordList.size());
LogRecord logRecord = logRecordList.get(0);
Assert.assertEquals(logRecord.getAction(), "张三下了一个订单,购买商品「超值优惠红烧肉套餐」,下单结果:true");
Assert.assertEquals(logRecord.getSubType(), "MANAGER_VIEW");
Assert.assertNotNull(logRecord.getExtra());
Assert.assertEquals(logRecord.getBizNo(), order.getOrderNo());
Assert.assertFalse(logRecord.isFail());
List<LogRecord> userLogRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.USER);
Assert.assertEquals(1, logRecordList.size());
LogRecord userLogRecord = userLogRecordList.get(0);
Assert.assertEquals(userLogRecord.getAction(), "张三下了一个订单,购买商品「超值优惠红烧肉套餐」,下单结果:true");
Assert.assertEquals(userLogRecord.getSubType(), "USER_VIEW");
Assert.assertEquals("", userLogRecord.getExtra());
Assert.assertEquals(userLogRecord.getBizNo(), order.getOrderNo());
Assert.assertFalse(userLogRecord.isFail());
logRecordService.clean();
}
@Test
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void createOrderMonitor() {
for (int i = 0; i < 100; i++) {
Order order = new Order();
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
orderService.createOrder(order);
}
logRecordService.clean();
}
@Test
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void createOrder_interface() {
Order order = new Order();
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
orderService.createOrder_interface(order);
List<LogRecord> logRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.ORDER);
Assert.assertEquals(1, logRecordList.size());
LogRecord logRecord = logRecordList.get(0);
Assert.assertEquals(logRecord.getAction(), "张三下了一个订单,购买商品「超值优惠红烧肉套餐」,测试变量「内部变量测试」,下单结果:true");
Assert.assertEquals(logRecord.getSubType(), "MANAGER_VIEW");
Assert.assertNotNull(logRecord.getExtra());
Assert.assertEquals(logRecord.getBizNo(), order.getOrderNo());
Assert.assertFalse(logRecord.isFail());
logRecordService.clean();
}
@Test(expected = RuntimeException.class)
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void createOrder_fail() {
Order order = new Order();
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
try {
orderService.createOrder_fail(order);
} finally {
List<LogRecord> logRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.ORDER);
Assert.assertEquals(1, logRecordList.size());
LogRecord logRecord = logRecordList.get(0);
Assert.assertEquals(logRecord.getAction(), "创建订单失败,失败原因:「测试fail」");
Assert.assertEquals(logRecord.getSubType(), "MANAGER_VIEW");
Assert.assertNotNull(logRecord.getExtra());
Assert.assertEquals(logRecord.getBizNo(), order.getOrderNo());
Assert.assertTrue(logRecord.isFail());
logRecordService.clean();
}
}
@Test
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void updateOrderBefore() {
Order order = new Order();
order.setOrderId(99L);
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
orderService.updateBefore(1L, order);
List<LogRecord> logRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.ORDER);
Assert.assertEquals(1, logRecordList.size());
LogRecord logRecord = logRecordList.get(0);
Assert.assertEquals(logRecord.getAction(), "更新了订单xxxx(99),更新内容为...");
Assert.assertNotNull(logRecord.getExtra());
Assert.assertEquals(logRecord.getOperator(), "111");
Assert.assertEquals(logRecord.getBizNo(), order.getOrderNo());
logRecordService.clean();
}
@Test
@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void updateOrderAfter() {
Order order = new Order();
order.setOrderId(99L);
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
order.setPurchaseName("张三");
orderService.updateAfter(1L, order);
List<LogRecord> logRecordList = logRecordService.queryLog(order.getOrderNo(), LogRecordType.ORDER);
Assert.assertEquals(1, logRecordList.size());
LogRecord logRecord = logRecordList.get(0);
Assert.assertEquals(logRecord.getAction(), "更新了订单xxxx(10000),更新内容为...");
Assert.assertNotNull(logRecord.getExtra());
Assert.assertEquals(logRecord.getOperator(), "111");
Assert.assertEquals(logRecord.getBizNo(), order.getOrderNo());
logRecordService.clean();
}
@Test
public void updateDollar() {
Order order = new Order();
order.setOrderId(99L);
order.setOrderNo("MT0000011");
order.setProductName("超值优惠红烧肉套餐");
没有合适的资源?快使用搜索试试~ 我知道了~
Springboot-注解-通用操作日志组件
共102个文件
java:83个
xml:4个
sql:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 143 浏览量
2024-04-05
09:10:01
上传
评论
收藏 220KB ZIP 举报
温馨提示
Springboot-注解-通用操作日志组件。2.0.0版本修改了一些变量名称,而且做的使向下不兼容的修改,如果大家不想改,可以一直使用1.x的版本,后续还会迭代的, 如果第一次接入推荐大家使用最新版本 3.X ~~ 1.x
资源推荐
资源详情
资源评论
收起资源包目录
Springboot-注解-通用操作日志组件 (102个子文件)
.gitignore 235B
spring.handlers 96B
IOrderServiceTest.java 29KB
IUserServiceTest.java 18KB
LogRecordInterceptor.java 12KB
OrderServiceImpl.java 10KB
DefaultDiffItemsToLogContentService.java 9KB
LogRecordValueParser.java 7KB
BizLogBeanDefinitionParser.java 7KB
ArrayDiffer.java 6KB
ISkuServiceTest.java 6KB
LogRecordProperties.java 5KB
LogRecordProxyAutoConfiguration.java 5KB
LogRecordOperationSource.java 4KB
SkuServiceImpl.java 4KB
RandomPOJOUtils.java 3KB
ArrayItemAccessor.java 3KB
AssertUtils.java 3KB
LogRecordPO.java 3KB
DiffParseFunction.java 3KB
LogRecordContext.java 3KB
LogRecordExpressionEvaluator.java 2KB
FastDiffUtil.java 2KB
UserServiceImpl.java 2KB
LogRecord.java 2KB
LogFunctionParser.java 2KB
IOrderService.java 2KB
LogRecordRepositoryImpl.java 2KB
ShiroConfig.java 2KB
IUserService.java 2KB
EnableLogRecord.java 2KB
JoinTransactionLogRecordService.java 1KB
ShiroTestController.java 1KB
LogRecordEvaluationContext.java 1KB
LogRecord.java 1KB
DbLogRecordService.java 1KB
User.java 1KB
AbsUserServiceImpl.java 1KB
TestLogRecordServiceImpl.java 1KB
ParseFunctionFactory.java 1KB
Order.java 1KB
OrderBeforeParseFunction.java 1KB
DiffFunction.java 1KB
LogRecordConfigureSelector.java 994B
DefaultLogRecordServiceImpl.java 969B
OrderParseFunction.java 948B
Main.java 947B
MethodExecuteResult.java 921B
DefaultFunctionServiceImpl.java 907B
ShiroTestRealm.java 906B
DataSourceAutoConfig.java 875B
ILogRecordService.java 833B
UserQueryServiceImpl.java 808B
UserBeanAspect.java 802B
LogRecordPointcut.java 793B
ExtInfoParseFunction.java 740B
BaseTest.java 728B
DefaultOperatorGetServiceImpl.java 659B
LogRecordRepository.java 645B
SexParseFunction.java 625B
BeanFactoryLogRecordAdvisor.java 623B
IdentityParseFunction.java 555B
IParseFunction.java 538B
DefaultLogRecordPerformanceMonitor.java 475B
LogRecordOps.java 456B
DefaultParseFunction.java 452B
Result.java 449B
DollarParseFunction.java 436B
BizLogNamespaceHandler.java 432B
IOperatorGetService.java 362B
SkuService.java 360B
ObjectSku.java 354B
ILogRecordPerformanceMonitor.java 338B
DiffLogField.java 297B
LogRecordType.java 291B
Operator.java 286B
IDiffItemsToLogContentService.java 277B
LogRecordMapper.java 277B
DiffLogAllFields.java 256B
DIffLogIgnore.java 252B
LogRecords.java 248B
UserQueryService.java 240B
LogEnumType.java 217B
IFunctionService.java 175B
CodeVariableType.java 163B
wechat-me.jpeg 76KB
wechat-group.jpg 35KB
LICENSE 11KB
document-2.x.md 28KB
document-1.x.md 26KB
spring.schemas 70B
create.sql 1KB
create.sql 1KB
clean.sql 24B
clean.sql 24B
pom.xml 4KB
pom.xml 4KB
pom.xml 2KB
pom.xml 908B
bizlog.xsd 653B
共 102 条
- 1
- 2
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7364
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- js基础但是这个烂怂东西要求标题不能少于10个字才能上传然后我其实还没有写完之后再修订吧.md
- electron-tabs-master
- Unity3D 布朗运动算法插件 Brownian Motion
- 鼎微R16中控升级包R16-4.5.10-20170221及强制升级方法
- 鼎微R16中控升级包公版UI 2015及强制升级方法,救砖包
- 基于CSS与JavaScript的积分系统设计源码
- 生物化学作业_1_生物化学作业资料.pdf
- 基于libgdx引擎的Java开发连连看游戏设计源码
- 基于MobileNetV3的SSD目标检测算法PyTorch实现设计源码
- 基于Java JDK的全面框架设计源码学习项目
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功