mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 12:09:13 +08:00
refactor: add testAssert
This commit is contained in:
parent
27d31f7846
commit
d1326f9c8f
@ -81,7 +81,7 @@ public class TestResourceReturnDTO {
|
||||
private String uiGrid;
|
||||
|
||||
@Schema(title = "grid最大线程数")
|
||||
private String girdConcurrentNumber;
|
||||
private Integer girdConcurrentNumber;
|
||||
|
||||
/**
|
||||
* 关联的组织id集合
|
||||
|
@ -141,7 +141,7 @@ public class OrganizationService {
|
||||
String roleId = userRoleRelationsByUser.getRoleId();
|
||||
String userId = userRoleRelationsByUser.getUserId();
|
||||
Map<String, String> pIdNameMap = userIdprojectIdMap.get(userId);
|
||||
if (pIdNameMap == null || MapUtils.isEmpty(pIdNameMap)) {
|
||||
if (MapUtils.isEmpty(pIdNameMap)) {
|
||||
pIdNameMap = new HashMap<>();
|
||||
}
|
||||
String projectName = projectIdNameMap.get(projectId);
|
||||
@ -151,7 +151,7 @@ public class OrganizationService {
|
||||
userIdprojectIdMap.put(userId, pIdNameMap);
|
||||
|
||||
Set<String> roleIds = userIdRoleIdMap.get(userId);
|
||||
if (roleIds == null || CollectionUtils.isEmpty(roleIds)) {
|
||||
if (CollectionUtils.isEmpty(roleIds)) {
|
||||
roleIds = new HashSet<>();
|
||||
}
|
||||
roleIds.add(roleId);
|
||||
@ -164,13 +164,11 @@ public class OrganizationService {
|
||||
orgUserExtend.setProjectIdNameMap(projectIdNameMap);
|
||||
}
|
||||
Set<String> userRoleIds = userIdRoleIdMap.get(orgUserExtend.getId());
|
||||
if (CollectionUtils.isNotEmpty(userRoleIds)) {
|
||||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andIdIn(new ArrayList<>(userRoleIds));
|
||||
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
||||
Map<String, String> userRoleIdNameMap = userRoles.stream().collect(Collectors.toMap(UserRole::getId, UserRole::getName));
|
||||
orgUserExtend.setUserRoleIdNameMap(userRoleIdNameMap);
|
||||
}
|
||||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andIdIn(new ArrayList<>(userRoleIds));
|
||||
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
|
||||
Map<String, String> userRoleIdNameMap = userRoles.stream().collect(Collectors.toMap(UserRole::getId, UserRole::getName));
|
||||
orgUserExtend.setUserRoleIdNameMap(userRoleIdNameMap);
|
||||
}
|
||||
return orgUserExtends;
|
||||
}
|
||||
@ -422,9 +420,7 @@ public class OrganizationService {
|
||||
public void updateMember(OrganizationMemberExtendRequest organizationMemberExtendRequest, String createUserId) {
|
||||
String organizationId = organizationMemberExtendRequest.getOrganizationId();
|
||||
List<String> memberIds = organizationMemberExtendRequest.getMemberIds();
|
||||
if(CollectionUtils.isEmpty(memberIds)) {
|
||||
throw new MSException(Translator.get("user.not.exist"));
|
||||
}
|
||||
|
||||
//校验组织是否存在
|
||||
checkOrgExist(organizationId);
|
||||
//校验成员是否是当前组织的成员
|
||||
|
@ -88,22 +88,30 @@ public class OrganizationControllerTests extends BaseTest {
|
||||
public void addMemberByOrgError() throws Exception {
|
||||
//组织ID正确
|
||||
// 成员选择为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Collections.emptyList(), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
// 用户组不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Collections.emptyList(), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
// 成员都不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_userX", "sys_default_userY"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
// 成员有一个不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user3", "sys_default_userY"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
// 用户组为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Collections.emptyList(), status().isBadRequest());
|
||||
// 用户组都不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_X", "sys_default_org_role_id_Y"), status().is5xxServerError());
|
||||
// 用户组有一个不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_Y"), status().isOk());
|
||||
//成员和用户组都为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "sys_default_organization_3", Collections.emptyList(), Collections.emptyList(), status().isBadRequest());
|
||||
// 组织不存在
|
||||
// 成员选择为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "default-organization-x", Collections.emptyList(), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "default-organization-x", Collections.emptyList(), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
// 用户组不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组都为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "default-organization-x", Collections.emptyList(), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
//组织为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, null, Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_LIST_ADD_MEMBER, null, Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
|
||||
}
|
||||
|
||||
@ -124,30 +132,30 @@ public class OrganizationControllerTests extends BaseTest {
|
||||
public void updateOrgMemberError() throws Exception {
|
||||
//组织ID正确
|
||||
// 成员选择为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Collections.emptyList(), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Collections.emptyList(), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
// 成员都不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user3", "sys_default_user4"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_userX", "sys_default_userY"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
// 成员有一个不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user4"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user3", "sys_default_userY"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
// 用户组为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Collections.emptyList(), status().isBadRequest());
|
||||
// 用户组都不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-8", "default-org-role-id-9"), status().is5xxServerError());
|
||||
// 用户组有一个不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-9"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_X", "sys_default_org_role_id_Y"), status().is5xxServerError());
|
||||
// 用户组有一个不存在是过滤是成功的
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_Y"), status().isOk());
|
||||
//成员和用户组都为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "sys_default_organization_3", Collections.emptyList(), Collections.emptyList(), status().isBadRequest());
|
||||
// 组织不存在
|
||||
// 成员选择为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "default-organization-x", Collections.emptyList(), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "default-organization-x", Collections.emptyList(), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
// 用户组不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组都为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "default-organization-x", Collections.emptyList(), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
//组织为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, null, Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER, null, Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
|
||||
}
|
||||
|
||||
@ -169,26 +177,26 @@ public class OrganizationControllerTests extends BaseTest {
|
||||
public void updateOrgMemberToRoleError() throws Exception {
|
||||
//组织ID正确
|
||||
// 成员选择为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Collections.emptyList(), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Collections.emptyList(), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
// 成员都不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Arrays.asList("sys_default_user3", "sys_default_user4"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Arrays.asList("sys_default_userX", "sys_default_userY"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
// 成员有一个不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user4"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Arrays.asList("sys_default_user3", "sys_default_userY"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
// 用户组不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Arrays.asList("sys_default_user", "sys_default_user2"), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组都为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "sys_default_organization_3", Collections.emptyList(), Collections.emptyList(), status().isBadRequest());
|
||||
// 组织不存在
|
||||
// 成员选择为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "default-organization-x", Collections.emptyList(), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "default-organization-x", Collections.emptyList(), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
// 用户组不存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组都为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "default-organization-x", Collections.emptyList(), Collections.emptyList(), status().isBadRequest());
|
||||
//成员和用户组存在
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().is5xxServerError());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, "default-organization-x", Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().is5xxServerError());
|
||||
//组织为空
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, null, Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("default-org-role-id-2", "default-org-role-id-3"), status().isBadRequest());
|
||||
addOrUpdateOrganizationMemberError(ORGANIZATION_UPDATE_MEMBER_TO_ROLE, null, Arrays.asList("sys_default_user", "sys_default_user2"), Arrays.asList("sys_default_org_role_id_2", "sys_default_org_role_id_3"), status().isBadRequest());
|
||||
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,14 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
" }],\n" +
|
||||
"\"ip\":\"172.2.130.1\",\n" +
|
||||
"\"token\":\"dsdfssdsvgsd\",\n" +
|
||||
"\"namespaces\":\"测试\",\n" +
|
||||
"\"nameSpaces\":\"测试\",\n" +
|
||||
"\"concurrentNumber\":3,\n" +
|
||||
"\"podThreads\":2,\n" +
|
||||
"\"jobDefinition\":\"jsfsjs\",\n" +
|
||||
"\"apiTestImage\":\"ddgd\",\n" +
|
||||
"\"deployName\":\"hello\",\n" +
|
||||
"\"uiGrid\":\"localhost:4444\"\n" +
|
||||
"\"uiGrid\":\"localhost:4444\",\n" +
|
||||
"\"girdConcurrentNumber\":2\n" +
|
||||
"}";
|
||||
|
||||
private static final String configuration = "{\n" +
|
||||
@ -87,13 +88,14 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
" \"orgIds\": [\"sys_default_organization_2\",\"sys_default_organization_3\"],\n" +
|
||||
" \"ip\": \"172.2.130.1\",\n" +
|
||||
" \"token\": \"dsdfssdsvgsd\",\n" +
|
||||
" \"namespaces\": \"测试\",\n" +
|
||||
" \"nameSpaces\": \"测试\",\n" +
|
||||
" \"concurrentNumber\": 3,\n" +
|
||||
" \"podThreads\": 2,\n" +
|
||||
" \"jobDefinition\": \"jsfsjs\",\n" +
|
||||
" \"apiTestImage\": \"ddgd\",\n" +
|
||||
" \"deployName\": \"hello\",\n" +
|
||||
" \"uiGrid\": \"localhost:4444\"\n" +
|
||||
" \"uiGrid\": \"localhost:4444\",\n" +
|
||||
"\"girdConcurrentNumber\":2\n" +
|
||||
"}";
|
||||
|
||||
|
||||
@ -125,6 +127,9 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
if (!allOrg) {
|
||||
Assertions.assertTrue((CollectionUtils.isNotEmpty(testResourcePoolOrganizations) && testResourcePoolOrganizations.size() == 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return mvcResult;
|
||||
}
|
||||
|
||||
@ -276,17 +281,13 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
|
||||
@Test
|
||||
@Order(13)
|
||||
void getResourcePoolsDetailWidthBlob() throws Exception {
|
||||
MvcResult testPoolBlob = this.addTestResourcePoolSuccess("test_pool_blob", false, true, true, false, false, ResourcePoolTypeEnum.K8S.name());
|
||||
void getResourcePoolsDetailWidthBlobK8s() throws Exception {
|
||||
MvcResult testPoolBlob = this.addTestResourcePoolSuccess("test_pool_blob_k8s", false, true, true, true, true, ResourcePoolTypeEnum.K8S.name());
|
||||
TestResourcePool testResourcePoolRequest1 = getResult(testPoolBlob);
|
||||
String id = testResourcePoolRequest1.getId();
|
||||
QueryResourcePoolRequest request = new QueryResourcePoolRequest();
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(5);
|
||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/detail/" + id)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.content(JSON.toJSONString(request))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk()).andDo(print())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
@ -294,10 +295,74 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
ResultHolder resultHolder = JsonUtils.parseObject(contentAsString, ResultHolder.class);
|
||||
TestResourcePoolReturnDTO testResourcePoolReturnDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), TestResourcePoolReturnDTO.class);
|
||||
Assertions.assertTrue((CollectionUtils.isNotEmpty(testResourcePoolReturnDTO.getTestResourceReturnDTO().getOrgIdNameMap())));
|
||||
if (testResourcePoolRequest1.getUiTest()) {
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getUiGrid());
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getGirdConcurrentNumber() > 0);
|
||||
}
|
||||
|
||||
if (testResourcePoolRequest1.getApiTest()) {
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getIp());
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getToken());
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getNameSpaces());
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getDeployName());
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getConcurrentNumber() > 0);
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getPodThreads() > 0);
|
||||
}
|
||||
|
||||
if (testResourcePoolRequest1.getLoadTest()) {
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getIp());
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getToken());
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getNameSpaces());
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getConcurrentNumber() > 0);
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getPodThreads() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void getResourcePoolsDetailWidthBlobNode() throws Exception {
|
||||
MvcResult testPoolBlob = this.addTestResourcePoolSuccess("test_pool_blob_node", false, true, true, true, true, ResourcePoolTypeEnum.NODE.name());
|
||||
TestResourcePool testResourcePoolRequest1 = getResult(testPoolBlob);
|
||||
String id = testResourcePoolRequest1.getId();
|
||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/detail/" + id)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk()).andDo(print())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
String contentAsString = mvcResult.getResponse().getContentAsString();
|
||||
ResultHolder resultHolder = JsonUtils.parseObject(contentAsString, ResultHolder.class);
|
||||
TestResourcePoolReturnDTO testResourcePoolReturnDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), TestResourcePoolReturnDTO.class);
|
||||
Assertions.assertTrue((CollectionUtils.isNotEmpty(testResourcePoolReturnDTO.getTestResourceReturnDTO().getOrgIdNameMap())));
|
||||
if (testResourcePoolRequest1.getUiTest()) {
|
||||
Assertions.assertNotNull(testResourcePoolReturnDTO.getTestResourceReturnDTO().getUiGrid());
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getGirdConcurrentNumber() > 0);
|
||||
}
|
||||
|
||||
if (testResourcePoolRequest1.getApiTest()) {
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getNodesList().size()>0);
|
||||
for (TestResourceNodeDTO testResourceNodeDTO : testResourcePoolReturnDTO.getTestResourceReturnDTO().getNodesList()) {
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getIp());
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getPort());
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getConcurrentNumber());
|
||||
}
|
||||
}
|
||||
|
||||
if (testResourcePoolRequest1.getLoadTest()) {
|
||||
Assertions.assertTrue(testResourcePoolReturnDTO.getTestResourceReturnDTO().getNodesList().size()>0);
|
||||
for (TestResourceNodeDTO testResourceNodeDTO : testResourcePoolReturnDTO.getTestResourceReturnDTO().getNodesList()) {
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getIp());
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getPort());
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getConcurrentNumber());
|
||||
Assertions.assertNotNull(testResourceNodeDTO.getMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void getResourcePoolsDetailWidthBlobNoOtgIds() throws Exception {
|
||||
MvcResult testPoolBlob = this.addTestResourcePoolSuccess("test_pool_blob_no_org_id", true, false, true, false, false, ResourcePoolTypeEnum.K8S.name());
|
||||
TestResourcePool testResourcePoolRequest1 = getResult(testPoolBlob);
|
||||
@ -321,7 +386,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
@Order(16)
|
||||
void getResourcePoolsDetailFiled() throws Exception {
|
||||
QueryResourcePoolRequest request = new QueryResourcePoolRequest();
|
||||
request.setCurrent(1);
|
||||
@ -336,7 +401,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
@Order(17)
|
||||
void updateTestResourcePool() throws Exception {
|
||||
MvcResult testPoolBlob = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, ResourcePoolTypeEnum.K8S.name());
|
||||
TestResourcePool testResourcePoolRequest1 = getResult(testPoolBlob);
|
||||
@ -371,7 +436,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
@Order(18)
|
||||
void updateUiTestResourcePoolFiled() throws Exception {
|
||||
this.dealTestResourcePoolFiled("UPDATE");
|
||||
}
|
||||
@ -441,7 +506,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
/*@Sql(scripts = {"/dml/init_test_resource_pool.sql"},
|
||||
config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED),
|
||||
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)*/
|
||||
@Order(18)
|
||||
@Order(19)
|
||||
void deleteTestResourcePool() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/delete/103")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
@ -452,7 +517,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
@Order(20)
|
||||
void deleteTestResourcePoolFiled() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/delete/105")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
@ -463,7 +528,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
@Order(21)
|
||||
void unableTestResourcePoolSuccess() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/set/enable/104")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
@ -474,7 +539,7 @@ class TestResourcePoolControllerTests extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
@Order(22)
|
||||
void unableTestResourcePoolFiled() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/set/enable/105")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
|
@ -16,6 +16,8 @@ INSERT INTO user(id, name, email, password, create_time, update_time, language,
|
||||
('sys_default_user', 'testUserOne', 'testUserOne@metersphere.io', MD5('calong'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||
INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, last_project_id, create_user, update_user) VALUE
|
||||
('sys_default_user2', 'testUserTwo', 'testUserTwo@metersphere.io', MD5('calong'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||
INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, last_project_id, create_user, update_user) VALUE
|
||||
('sys_default_user3', 'testUserThree', 'testUserThree@metersphere.io', MD5('calong'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||
|
||||
INSERT INTO user_role(id, name, description, internal, type, create_time, update_time, create_user, scope_id) VALUE
|
||||
('sys_default_org_role_id_3', 'sys_default_org_role_id_3', 'XXX', FALSE, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'sys_default_organization_3');
|
||||
|
Loading…
Reference in New Issue
Block a user