From e36671255a9f0c0f6f71691a75974cbdd11d9327 Mon Sep 17 00:00:00 2001 From: "LAPTOP-00JMG2HE\\George Wei" Date: Fri, 23 Aug 2024 18:41:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8Cmvn=20test?= =?UTF-8?q?=E6=97=B6=E5=A4=9A=E4=B8=AATestCase=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=EF=BC=9A1)=E4=BD=BF=E7=94=A8=E6=96=AD=E8=A8=80=E6=AF=94?= =?UTF-8?q?=E8=BE=83POJO=E5=AF=B9=E8=B1=A1=E6=97=B6=E6=9C=AA=E5=BF=BD?= =?UTF-8?q?=E7=95=A5expiresTime=E3=80=81createTime=E3=80=81updateTime?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=EF=BC=9B2)=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=95=B0=E6=8D=AE=E5=BA=93=E6=97=B6=E6=9C=AA?= =?UTF-8?q?=E4=BB=A5UTF8=E7=BC=96=E7=A0=81=E8=AF=BB=E5=8F=96=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/job/JobLogServiceImplTest.java | 2 +- .../logger/ApiAccessLogServiceImplTest.java | 2 +- .../logger/ApiErrorLogServiceImplTest.java | 2 +- .../test/resources/application-unit-test.yaml | 1 + .../oauth2/OAuth2ApproveServiceImplTest.java | 2 +- .../oauth2/OAuth2CodeServiceImplTest.java | 4 ++-- .../oauth2/OAuth2TokenServiceImplTest.java | 18 +++++++++--------- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java index d3342eeec..0ef0f6692 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java @@ -114,7 +114,7 @@ public class JobLogServiceImplTest extends BaseDbUnitTest { assertEquals(1, count); List logs = jobLogMapper.selectList(); assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); + assertPojoEquals(log02, logs.get(0), "createTime", "updateTime"); } @Test diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java index 660f3d38f..7ad09e19b 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java @@ -91,7 +91,7 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest { assertEquals(1, count); List logs = apiAccessLogMapper.selectList(); assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); + assertPojoEquals(log02, logs.get(0), "createTime", "updateTime"); } @Test diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java index 66514e0d4..0a3c20994 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java @@ -157,7 +157,7 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest { assertEquals(1, count); List logs = apiErrorLogMapper.selectList(); assertEquals(1, logs.size()); - assertEquals(log02, logs.get(0)); + assertPojoEquals(log02, logs.get(0), "createTime", "updateTime"); } } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml index d88a15a60..5ce2d4b5f 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/application-unit-test.yaml @@ -19,6 +19,7 @@ spring: sql: init: schema-locations: classpath:/sql/create_tables.sql + encoding: UTF-8 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 data: diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java index 91a96769d..05432275c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2ApproveServiceImplTest.java @@ -209,7 +209,7 @@ public class OAuth2ApproveServiceImplTest extends BaseDbUnitTest { List result = oauth2ApproveService.getApproveList(userId, userType, clientId); // 断言 assertEquals(1, result.size()); - assertPojoEquals(approve, result.get(0)); + assertPojoEquals(approve, result.get(0), "expiresTime"); } @Test diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java index 2601ffc97..c052576f1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2CodeServiceImplTest.java @@ -50,7 +50,7 @@ class OAuth2CodeServiceImplTest extends BaseDbUnitTest { scopes, redirectUri, state); // 断言 OAuth2CodeDO dbCodeDO = oauth2CodeMapper.selectByCode(codeDO.getCode()); - assertPojoEquals(codeDO, dbCodeDO, "createTime", "updateTime", "deleted"); + assertPojoEquals(codeDO, dbCodeDO, "expiresTime", "createTime", "updateTime", "deleted"); assertEquals(userId, codeDO.getUserId()); assertEquals(userType, codeDO.getUserType()); assertEquals(clientId, codeDO.getClientId()); @@ -92,7 +92,7 @@ class OAuth2CodeServiceImplTest extends BaseDbUnitTest { // 调用 OAuth2CodeDO result = oauth2CodeService.consumeAuthorizationCode(code); - assertPojoEquals(codeDO, result); + assertPojoEquals(codeDO, result, "expiresTime"); assertNull(oauth2CodeMapper.selectByCode(code)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java index 8f2f63cae..a3070648f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2TokenServiceImplTest.java @@ -77,7 +77,7 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(userId, userType, clientId, scopes); // 断言访问令牌 OAuth2AccessTokenDO dbAccessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, dbAccessTokenDO, "createTime", "updateTime", "deleted"); + assertPojoEquals(accessTokenDO, dbAccessTokenDO, "expiresTime", "createTime", "updateTime", "deleted"); assertEquals(userId, accessTokenDO.getUserId()); assertEquals(userType, accessTokenDO.getUserType()); assertEquals(2, accessTokenDO.getUserInfo().size()); @@ -88,7 +88,7 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { assertFalse(DateUtils.isExpired(accessTokenDO.getExpiresTime())); // 断言访问令牌的缓存 OAuth2AccessTokenDO redisAccessTokenDO = oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, redisAccessTokenDO, "createTime", "updateTime", "deleted"); + assertPojoEquals(accessTokenDO, redisAccessTokenDO, "expiresTime", "createTime", "updateTime", "deleted"); // 断言刷新令牌 OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectList().get(0); assertPojoEquals(accessTokenDO, refreshTokenDO, "id", "expiresTime", "createTime", "updateTime", "deleted"); @@ -177,13 +177,13 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { assertNull(oauth2AccessTokenRedisDAO.get(accessTokenDO.getAccessToken())); // 断言,新的访问令牌 OAuth2AccessTokenDO dbAccessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(newAccessTokenDO.getAccessToken()); - assertPojoEquals(newAccessTokenDO, dbAccessTokenDO, "createTime", "updateTime", "deleted"); + assertPojoEquals(newAccessTokenDO, dbAccessTokenDO, "expiresTime", "createTime", "updateTime", "deleted"); assertPojoEquals(newAccessTokenDO, refreshTokenDO, "id", "expiresTime", "createTime", "updateTime", "deleted", "creator", "updater"); assertFalse(DateUtils.isExpired(newAccessTokenDO.getExpiresTime())); // 断言,新的访问令牌的缓存 OAuth2AccessTokenDO redisAccessTokenDO = oauth2AccessTokenRedisDAO.get(newAccessTokenDO.getAccessToken()); - assertPojoEquals(newAccessTokenDO, redisAccessTokenDO, "createTime", "updateTime", "deleted"); + assertPojoEquals(newAccessTokenDO, redisAccessTokenDO, "expiresTime", "createTime", "updateTime", "deleted"); } @Test @@ -198,9 +198,9 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { // 调用 OAuth2AccessTokenDO result = oauth2TokenService.getAccessToken(accessToken); // 断言 - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", + assertPojoEquals(accessTokenDO, result, "expiresTime", "createTime", "updateTime", "deleted", "creator", "updater"); - assertPojoEquals(accessTokenDO, oauth2AccessTokenRedisDAO.get(accessToken), "createTime", "updateTime", "deleted", + assertPojoEquals(accessTokenDO, oauth2AccessTokenRedisDAO.get(accessToken), "expiresTime", "createTime", "updateTime", "deleted", "creator", "updater"); } @@ -237,7 +237,7 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { // 调研,并断言 OAuth2AccessTokenDO result = oauth2TokenService.getAccessToken(accessToken); // 断言 - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", + assertPojoEquals(accessTokenDO, result, "expiresTime", "createTime", "updateTime", "deleted", "creator", "updater"); } @@ -259,7 +259,7 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { oauth2RefreshTokenMapper.insert(refreshTokenDO); // 调用 OAuth2AccessTokenDO result = oauth2TokenService.removeAccessToken(accessTokenDO.getAccessToken()); - assertPojoEquals(accessTokenDO, result, "createTime", "updateTime", "deleted", + assertPojoEquals(accessTokenDO, result, "expiresTime", "createTime", "updateTime", "deleted", "creator", "updater"); // 断言数据 assertNull(oauth2AccessTokenMapper.selectByAccessToken(accessTokenDO.getAccessToken())); @@ -297,7 +297,7 @@ public class OAuth2TokenServiceImplTest extends BaseDbAndRedisUnitTest { // 断言 assertEquals(1, pageResult.getTotal()); assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbAccessToken, pageResult.getList().get(0)); + assertPojoEquals(dbAccessToken, pageResult.getList().get(0), "expiresTime"); } }