-
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.
version: dependency update refactor: test class docs: README
- Loading branch information
Showing
29 changed files
with
209 additions
and
57 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
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
68 changes: 68 additions & 0 deletions
68
...er/src/test/java/cn/monitor4all/logRecord/springboot3/test/OperationLogCustomLogTest.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,68 @@ | ||
package cn.monitor4all.logRecord.springboot3.test; | ||
|
||
|
||
import cn.monitor4all.logRecord.bean.LogDTO; | ||
import cn.monitor4all.logRecord.bean.LogRequest; | ||
import cn.monitor4all.logRecord.springboot3.LogRecordAutoConfiguration; | ||
import cn.monitor4all.logRecord.springboot3.test.service.OperatorIdGetService; | ||
import cn.monitor4all.logRecord.springboot3.test.service.TestService; | ||
import cn.monitor4all.logRecord.springboot3.test.utils.TestHelper; | ||
import cn.monitor4all.logRecord.util.OperationLogUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
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.Date; | ||
|
||
/** | ||
* 单元测试:自定义线程池 | ||
*/ | ||
@Slf4j | ||
@SpringBootTest | ||
@ContextConfiguration(classes = { | ||
LogRecordAutoConfiguration.class, | ||
OperatorIdGetService.class, | ||
TestService.class,}) | ||
@PropertySource("classpath:testCustomLog.properties") | ||
@EnableAspectJAutoProxy(proxyTargetClass = true) | ||
public class OperationLogCustomLogTest { | ||
|
||
@Test | ||
public void testBuildLogRequest() { | ||
TestHelper.addLock("testBuildLogRequest"); | ||
Date date = new Date(); | ||
LogRequest logRequest = LogRequest.builder() | ||
.bizId("testBizId") | ||
.bizType("testBuildLogRequest") | ||
.exception("testException") | ||
.operateDate(date) | ||
.success(true) | ||
.msg("testMsg") | ||
.tag("testTag") | ||
.returnStr("testReturnStr") | ||
.executionTime(0L) | ||
.extra("testExtra") | ||
.operatorId("testOperatorId") | ||
.build(); | ||
OperationLogUtil.log(logRequest); | ||
TestHelper.await("testBuildLogRequest"); | ||
LogDTO logDTO = TestHelper.getLogDTO("testBuildLogRequest"); | ||
|
||
Assertions.assertEquals("testBizId", logDTO.getBizId()); | ||
Assertions.assertEquals("testBuildLogRequest", logDTO.getBizType()); | ||
Assertions.assertEquals("testException", logDTO.getException()); | ||
Assertions.assertEquals(date, logDTO.getOperateDate()); | ||
Assertions.assertEquals(true, logDTO.getSuccess()); | ||
Assertions.assertEquals("testMsg", logDTO.getMsg()); | ||
Assertions.assertEquals("testTag", logDTO.getTag()); | ||
Assertions.assertEquals("testReturnStr", logDTO.getReturnStr()); | ||
Assertions.assertEquals(0L, logDTO.getExecutionTime()); | ||
Assertions.assertEquals("testExtra", logDTO.getExtra()); | ||
Assertions.assertEquals("testOperatorId", logDTO.getOperatorId()); | ||
} | ||
|
||
} |
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
27 changes: 27 additions & 0 deletions
27
...va/cn/monitor4all/logRecord/springboot3/test/service/OperationLogCustomLogGetService.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,27 @@ | ||
package cn.monitor4all.logRecord.springboot3.test.service; | ||
|
||
import cn.monitor4all.logRecord.bean.LogDTO; | ||
import cn.monitor4all.logRecord.service.IOperationLogGetService; | ||
import cn.monitor4all.logRecord.springboot3.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 = "customLog") | ||
public class OperationLogCustomLogGetService implements IOperationLogGetService { | ||
|
||
@Override | ||
public boolean createLog(LogDTO logDTO) throws Exception { | ||
log.info("logDTO: [{}]", JSON.toJSONString(logDTO)); | ||
|
||
if ("testBuildLogRequest".equals(logDTO.getBizType())) { | ||
TestHelper.putLogDTO("testBuildLogRequest", logDTO); | ||
TestHelper.releaseLock("testBuildLogRequest"); | ||
} | ||
|
||
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
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
1 change: 1 addition & 0 deletions
1
log-record-springboot3-starter/src/test/resources/testCommon.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 @@ | ||
test.config=common |
1 change: 1 addition & 0 deletions
1
log-record-springboot3-starter/src/test/resources/testCustomLog.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 @@ | ||
test.config=customLog |
2 changes: 1 addition & 1 deletion
2
...stLogRecordDiffIgnoreNullValue.properties → ...ources/testDiffIgnoreNullValue.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
test.config=logRecordDiffIgnoreNullValue | ||
test.config=diffIgnoreNullValue | ||
log-record.diff-ignore-new-object-null-value=true | ||
log-record.diff-ignore-old-object-null-value=true |
1 change: 0 additions & 1 deletion
1
log-record-springboot3-starter/src/test/resources/testNormal.properties
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
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
Oops, something went wrong.