test(系统设置): 添加组织管理用例

This commit is contained in:
song-cc-rock 2023-06-16 15:44:53 +08:00 committed by 刘瑞斌
parent 585701c174
commit 50302a0145
2 changed files with 17 additions and 5 deletions

View File

@ -48,9 +48,6 @@ public class OrganizationServiceImpl implements OrganizationService{
OrganizationExample example = new OrganizationExample();
example.createCriteria().andNumEqualTo(100001L);
List<Organization> organizations = organizationMapper.selectByExample(example);
if (CollectionUtils.isEmpty(organizations)) {
throw new MSException(Translator.get("organization_default_not_exists"));
}
Organization organization = organizations.get(0);
BeanUtils.copyBean(organizationDTO, organization);
return organizationDTO;

View File

@ -21,6 +21,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import java.util.Arrays;
import java.util.Collections;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -91,7 +92,7 @@ public class OrganizationControllerTests extends BaseTest{
@Test
@Order(4)
public void testAddOrganizationMember() throws Exception {
public void testAddOrganizationMemberPass() throws Exception {
OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest();
organizationMemberRequest.setOrganizationId("default-organization-3");
organizationMemberRequest.setMemberIds(Arrays.asList("admin", "default-admin"));
@ -105,6 +106,20 @@ public class OrganizationControllerTests extends BaseTest{
@Test
@Order(5)
public void testAddOrganizationMemberNotPass() throws Exception {
OrganizationMemberRequest organizationMemberRequest = new OrganizationMemberRequest();
organizationMemberRequest.setOrganizationId("default-organization-3");
organizationMemberRequest.setMemberIds(Collections.emptyList());
mockMvc.perform(MockMvcRequestBuilders.post(REQ_PREFIX + "/add-member")
.header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken)
.content(JSON.toJSONString(organizationMemberRequest))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}
@Test
@Order(6)
public void testRemoveOrganizationMember() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get(REQ_PREFIX + "/remove-member/default-organization-3/admin")
.header(SessionConstants.HEADER_TOKEN, sessionId)
@ -113,7 +128,7 @@ public class OrganizationControllerTests extends BaseTest{
}
@Test
@Order(6)
@Order(7)
public void testGetOrganizationProject() throws Exception {
ProjectRequest projectRequest = new ProjectRequest();
projectRequest.setCurrent(1);