From fbb8ff438ad0c0db1bfc78d33bbc73b2c7d40683 Mon Sep 17 00:00:00 2001 From: Wuv1Up Date: Sat, 30 May 2020 12:45:39 +0800 Subject: [PATCH] fix return value of created project (#2804) Co-authored-by: dailidong --- .../apache/dolphinscheduler/api/service/ProjectService.java | 6 ++---- .../api/controller/ProjectControllerTest.java | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java index 8f9a62000a..6d3650b77f 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectService.java @@ -88,6 +88,8 @@ public class ProjectService extends BaseService{ project.setUpdateTime(now); if (projectMapper.insert(project) > 0) { + Project insertedProject = projectMapper.queryByName(name); + result.put(Constants.DATA_LIST, insertedProject); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.CREATE_PROJECT_ERROR); @@ -124,9 +126,7 @@ public class ProjectService extends BaseService{ * @return true if the login user have permission to see the project */ public Map checkProjectAndAuth(User loginUser, Project project, String projectName) { - Map result = new HashMap<>(5); - if (project == null) { putMsg(result, Status.PROJECT_NOT_FOUNT, projectName); } else if (!checkReadPermission(loginUser, project)) { @@ -135,8 +135,6 @@ public class ProjectService extends BaseService{ }else { putMsg(result, Status.SUCCESS); } - - return result; } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectControllerTest.java index 42cdd1705a..7eb0eb3202 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectControllerTest.java @@ -46,7 +46,7 @@ public class ProjectControllerTest extends AbstractControllerTest{ MultiValueMap paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("projectName","project_test1"); - paramsMap.add("desc","the test project"); + paramsMap.add("description","the test project"); MvcResult mvcResult = mockMvc.perform(post("/projects/create") .header(SESSION_ID, sessionId) @@ -56,7 +56,8 @@ public class ProjectControllerTest extends AbstractControllerTest{ .andReturn(); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); - Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); + Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); + Assert.assertNotNull(result.getData()); logger.info(mvcResult.getResponse().getContentAsString()); }