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 下载量 125 浏览量
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+
- 资源: 7530
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Matlab_让我们学习如何使用变量、函数、向量和更多的内置命令.zip
- Matlab_欠驱动自主水下航行器轨迹跟踪的Lyapunov控制器设计.zip
- 练习VBA网络抓取数据的代码实例
- Matlab_牛津机器人汽车数据集的软件开发工具包.zip
- Matlab_人工势场APF方法为实际应用提供了一种简单有效的运动规划方法。目前开发的项目是在Matlab中开发的,改.zip
- Matlab_让我们重现多机器人系统的论文模拟,编队控制,分布式优化和协作操作.zip
- Matlab_人脸对齐的监督下降法SDM的Matlab实现.zip
- Matlab_三维卷积神经网络CNN体积输入支持二维和三维核的Matlab框架.zip
- Matlab_色谱和质谱数据分析的功能.zip
- 基于人眼视觉系统的实时HEVC编码优化及其高效时空同质区域检测方法
- Matlab_深度架构学习的Matlab环境.zip
- Matlab_实现了TADT跟踪器的论文TargetAware深度跟踪.zip
- Matlab_实现了图像增强算法,使用视网膜理论来增加图像的对比度.zip
- Matlab_实现了无气味卡尔曼滤波UKF用于加速度计和陀螺仪的方向跟踪传感器融合.zip
- Matlab_实验用Matlab代码给出了复杂网络高阶组织的方法和一些实例.zip
- Matlab_实现一个基于部分可观察马尔可夫决策过程的强化学习算法.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功