From 85e5031786be90ece03dc99ed42ac5d580f39981 Mon Sep 17 00:00:00 2001 From: Assert <42203474+shangeyao@users.noreply.github.com> Date: Thu, 14 Jul 2022 19:03:34 +0800 Subject: [PATCH] [Fix-10595][api] Fix Dependent Node Only View Projects Created By Self (#10834) * [Fix-10595][api] Fix Dependent Node Only View Projects Created By Self --- .../dao/mapper/ProjectMapper.xml | 10 ++++--- .../dao/mapper/ProjectMapperTest.java | 30 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml index 549afdfcb6..9bf7d53f9b 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml @@ -162,11 +162,13 @@ diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java index 7bf8ffb47d..ddb5e6d9b2 100644 --- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java +++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java @@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.entity.Project; +import org.apache.dolphinscheduler.dao.entity.ProjectUser; import org.apache.dolphinscheduler.dao.entity.User; import java.util.Date; @@ -39,6 +40,9 @@ public class ProjectMapperTest extends BaseDaoTest { @Autowired private UserMapper userMapper; + @Autowired + private ProjectUserMapper projectUserMapper; + /** * insert * @@ -168,7 +172,7 @@ public class ProjectMapperTest extends BaseDaoTest { } /** - * test query authed prject list by userId + * test query authed project list by userId */ @Test public void testQueryAuthedProjectListByUserId() { @@ -187,9 +191,31 @@ public class ProjectMapperTest extends BaseDaoTest { Project project = insertOne(); List projects = projectMapper.queryProjectExceptUserId( - 100000 + 100000 ); Assert.assertNotEquals(projects.size(), 0); } + + @Test + public void testQueryAllProject() { + User user = new User(); + user.setUserName("ut user"); + userMapper.insert(user); + + Project project = insertOne(); + project.setUserId(user.getId()); + projectMapper.updateById(project); + + ProjectUser projectUser = new ProjectUser(); + projectUser.setProjectId(project.getId()); + projectUser.setUserId(user.getId()); + projectUser.setCreateTime(new Date()); + projectUser.setUpdateTime(new Date()); + projectUserMapper.insert(projectUser); + + List allProject = projectMapper.queryAllProject(user.getId()); + + Assert.assertNotEquals(allProject.size(), 0); + } } \ No newline at end of file