From 801e6dd6bb721ee2d9f35528673865483957fcd3 Mon Sep 17 00:00:00 2001 From: ouyangyewei Date: Wed, 15 Dec 2021 13:40:07 +0800 Subject: [PATCH] to feature 7418 (#7420) Co-authored-by: ouyangyewei --- .../dolphinscheduler/api/controller/AccessTokenController.java | 2 +- .../dolphinscheduler/api/service/AccessTokenService.java | 2 +- .../api/service/impl/AccessTokenServiceImpl.java | 3 ++- .../api/controller/AccessTokenControllerTest.java | 1 + .../dolphinscheduler/api/service/AccessTokenServiceTest.java | 2 ++ 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java index e78c5bd389..f458da89df 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java @@ -194,7 +194,7 @@ public class AccessTokenController extends BaseController { * @param userId token for user * @param expireTime token expire time * @param token token string (if it is absent, it will be automatically generated) - * @return update result code + * @return updated access token entity */ @ApiOperation(value = "updateToken", notes = "UPDATE_TOKEN_NOTES") @ApiImplicitParams({ diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java index 81fb5e8d5b..99ac4c95cc 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java @@ -83,7 +83,7 @@ public interface AccessTokenService { * @param userId token for user * @param expireTime token expire time * @param token token string (if it is absent, it will be automatically generated) - * @return update result code + * @return updated access token entity */ Map updateToken(User loginUser, int id, int userId, String expireTime, String token); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java index 04572ff096..9fd9bbfc3d 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java @@ -208,7 +208,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok * @param userId token for user * @param expireTime token expire time * @param token token string (if it is absent, it will be automatically generated) - * @return update result code + * @return updated access token entity */ @Override public Map updateToken(User loginUser, int id, int userId, String expireTime, String token) { @@ -241,6 +241,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok accessTokenMapper.updateById(accessToken); + result.put(Constants.DATA_LIST, accessToken); putMsg(result, Status.SUCCESS); return result; } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java index 921537c9af..21c2438b33 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java @@ -193,6 +193,7 @@ public class AccessTokenControllerTest extends AbstractControllerTest { Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); + Assert.assertNotNull(result.getData()); logger.info(mvcResult.getResponse().getContentAsString()); } } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java index 009fb9af81..a9276a5f40 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java @@ -152,11 +152,13 @@ public class AccessTokenServiceTest { Map result = accessTokenService.updateToken(getLoginUser(), 1,Integer.MAX_VALUE,getDate(),"token"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); + Assert.assertNotNull(result.get(Constants.DATA_LIST)); // Token is absent result = accessTokenService.updateToken(getLoginUser(), 1, Integer.MAX_VALUE,getDate(),null); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); + Assert.assertNotNull(result.get(Constants.DATA_LIST)); // ACCESS_TOKEN_NOT_EXIST result = accessTokenService.updateToken(getLoginUser(), 2,Integer.MAX_VALUE,getDate(),"token");