-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from qqxx6661/dev_diff_fix
refactor: Diff function ignore field
- Loading branch information
Showing
17 changed files
with
140 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,9 @@ | |
* 字段的别名:不填则默认字段名 | ||
*/ | ||
String alias() default ""; | ||
|
||
/** | ||
* 字段是否在DIFF中忽略:默认不忽略 | ||
*/ | ||
boolean ignored() default false; | ||
} |
16 changes: 0 additions & 16 deletions
16
src/main/java/cn/monitor4all/logRecord/annotation/LogRecordDiffIgnoreField.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/cn/monitor4all/logRecord/test/LogRecordDiffIgnoreNullValueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cn.monitor4all.logRecord.test; | ||
|
||
import cn.monitor4all.logRecord.bean.LogDTO; | ||
import cn.monitor4all.logRecord.configuration.LogRecordAutoConfiguration; | ||
import cn.monitor4all.logRecord.test.bean.TestComplexUser; | ||
import cn.monitor4all.logRecord.test.service.OperatorIdGetService; | ||
import cn.monitor4all.logRecord.test.service.TestService; | ||
import cn.monitor4all.logRecord.test.utils.TestHelper; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* 单元测试 | ||
*/ | ||
@Slf4j | ||
@SpringBootTest | ||
@ContextConfiguration(classes = { | ||
LogRecordAutoConfiguration.class, | ||
OperatorIdGetService.class, | ||
TestService.class,}) | ||
@PropertySource("classpath:testLogRecordDiffIgnoreNullValue.properties") | ||
@EnableAspectJAutoProxy(proxyTargetClass = true) | ||
public class LogRecordDiffIgnoreNullValueTest { | ||
|
||
@Autowired | ||
private TestService testService; | ||
|
||
@Test | ||
public void testLogRecordDiffIgnoreNullValue() { | ||
TestHelper.addLock("testLogRecordDiffIgnoreNewObjectNullValue"); | ||
testService.testLogRecordDiffIgnoreNewObjectNullValue(new TestComplexUser(2, null, 20, Arrays.asList("小李四", "大李四"), "后端")); | ||
TestHelper.await("testLogRecordDiffIgnoreNewObjectNullValue"); | ||
LogDTO logDTO = TestHelper.getLogDTO("testLogRecordDiffIgnoreNewObjectNullValue"); | ||
|
||
Assertions.assertEquals(logDTO.getMsg(), "【用户工号】从【1】变成了【2】 【nickNameList】从【[小张三, 大张三]】变成了【[小李四, 大李四]】"); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getOldClassName(), "cn.monitor4all.logRecord.test.bean.TestComplexUser"); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getOldClassAlias(), "用户信息复杂实体"); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getDiffFieldDTOList().get(0).getFieldName(), "id"); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getDiffFieldDTOList().get(0).getOldFieldAlias(), "用户工号"); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getDiffFieldDTOList().get(0).getNewFieldAlias(), "用户工号"); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getDiffFieldDTOList().get(0).getOldValue(), 1); | ||
Assertions.assertEquals(logDTO.getDiffDTOList().get(0).getDiffFieldDTOList().get(0).getNewValue(), 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...t/java/cn/monitor4all/logRecord/test/service/TestLogRecordDiffIgnoreNullValueService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cn.monitor4all.logRecord.test.service; | ||
|
||
import cn.monitor4all.logRecord.bean.LogDTO; | ||
import cn.monitor4all.logRecord.service.IOperationLogGetService; | ||
import cn.monitor4all.logRecord.test.utils.TestHelper; | ||
import com.alibaba.fastjson.JSON; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.test.context.TestComponent; | ||
|
||
@Slf4j | ||
@TestComponent | ||
@ConditionalOnProperty(name = "test.config", havingValue = "logRecordDiffIgnoreNullValue") | ||
public class TestLogRecordDiffIgnoreNullValueService implements IOperationLogGetService { | ||
|
||
@Override | ||
public boolean createLog(LogDTO logDTO) throws Exception { | ||
|
||
log.info("logDTO: [{}]", JSON.toJSONString(logDTO)); | ||
|
||
if ("testLogRecordDiffIgnoreNewObjectNullValue".equals(logDTO.getBizType())) { | ||
TestHelper.putLogDTO("testLogRecordDiffIgnoreNewObjectNullValue", logDTO); | ||
TestHelper.releaseLock("testLogRecordDiffIgnoreNewObjectNullValue"); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
test.config=exception | ||
log-record.retry.retry-times=3 | ||
#log-record.thread-pool.enabled=false | ||
log-record.retry.retry-times=3 |
3 changes: 3 additions & 0 deletions
3
src/test/resources/testLogRecordDiffIgnoreNullValue.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test.config=logRecordDiffIgnoreNullValue | ||
log-record.diffIgnoreNewObjectNullValue=true | ||
log-record.diffIgnoreOldObjectNullValue=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
test.config=normal | ||
#log-record.thread-pool.enabled=false | ||
test.config=normal |