|
|
|
@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.api.service;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import org.apache.dolphinscheduler.api.enums.Status; |
|
|
|
|
import org.apache.dolphinscheduler.api.exceptions.ServiceException; |
|
|
|
|
import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
@ -159,19 +158,19 @@ public class ResourcesServiceTest {
|
|
|
|
|
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); |
|
|
|
|
User user = new User(); |
|
|
|
|
//HDFS_NOT_STARTUP
|
|
|
|
|
Result result = resourcesService.updateResource(user,1,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE); |
|
|
|
|
Result result = resourcesService.updateResource(user,1,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
|
//RESOURCE_NOT_EXIST
|
|
|
|
|
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); |
|
|
|
|
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); |
|
|
|
|
result = resourcesService.updateResource(user,0,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE); |
|
|
|
|
result = resourcesService.updateResource(user,0,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
|
//USER_NO_OPERATION_PERM
|
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest","ResourcesServiceTest",ResourceType.FILE,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
@ -186,7 +185,7 @@ public class ResourcesServiceTest {
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
|
} |
|
|
|
|
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF); |
|
|
|
|
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF,null); |
|
|
|
|
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
|
//SUCCESS
|
|
|
|
@ -199,25 +198,25 @@ public class ResourcesServiceTest {
|
|
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest.jar","ResourcesServiceTest",ResourceType.FILE); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest.jar","ResourcesServiceTest",ResourceType.FILE,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
|
//RESOURCE_EXIST
|
|
|
|
|
Mockito.when(resourcesMapper.queryResourceList("/ResourcesServiceTest1.jar", 0, 0)).thenReturn(getResourceList()); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.FILE); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.FILE,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(),result.getMsg()); |
|
|
|
|
//USER_NOT_EXIST
|
|
|
|
|
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(null); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.UDF); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.UDF,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode()); |
|
|
|
|
|
|
|
|
|
//TENANT_NOT_EXIST
|
|
|
|
|
Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); |
|
|
|
|
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.UDF); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest",ResourceType.UDF,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
@ -231,7 +230,7 @@ public class ResourcesServiceTest {
|
|
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest1.jar",ResourceType.UDF); |
|
|
|
|
result = resourcesService.updateResource(user,1,"ResourcesServiceTest1.jar","ResourcesServiceTest1.jar",ResourceType.UDF,null); |
|
|
|
|
logger.info(result.toString()); |
|
|
|
|
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg()); |
|
|
|
|
|
|
|
|
|