refactor(项目设置): 优化状态流单元测试代码

This commit is contained in:
AgAngle 2023-10-25 17:21:45 +08:00 committed by Craftsman
parent f494bcf001
commit e90a9bac8a
2 changed files with 7 additions and 2 deletions

View File

@ -29,7 +29,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MvcResult;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static io.metersphere.project.enums.result.ProjectResultCode.PROJECT_TEMPLATE_PERMISSION;
import static io.metersphere.system.controller.handler.result.CommonResultCode.STATUS_ITEM_EXIST;
@ -302,7 +304,8 @@ public class ProjectStatusFlowSettingControllerTest extends BaseTest {
@Order(6)
public void sortStatusItem() throws Exception {
List<StatusItem> statusItems = baseStatusItemService.getByScopeIdAndScene(DEFAULT_PROJECT_ID, TemplateScene.BUG.name());
List<String> statusIds = statusItems.stream().map(StatusItem::getId).toList().reversed();
List<String> statusIds = statusItems.stream().map(StatusItem::getId).collect(Collectors.toList());
Collections.reverse(statusIds);
// @@校验请求成功
this.requestPostWithOkAndReturn(STATUS_SORT, statusIds, DEFAULT_PROJECT_ID, TemplateScene.BUG.name());
OrganizationStatusFlowSettingControllerTest.assertSortStatusItem(DEFAULT_PROJECT_ID, statusIds);

View File

@ -30,6 +30,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MvcResult;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -393,7 +394,8 @@ public class OrganizationStatusFlowSettingControllerTest extends BaseTest {
@Order(6)
public void sortStatusItem() throws Exception {
List<StatusItem> statusItems = baseStatusItemService.getByScopeIdAndScene(DEFAULT_ORGANIZATION_ID, TemplateScene.BUG.name());
List<String> statusIds = statusItems.stream().map(StatusItem::getId).toList().reversed();
List<String> statusIds = statusItems.stream().map(StatusItem::getId).collect(Collectors.toList());
Collections.reverse(statusIds);
// @@校验请求成功
this.requestPostWithOkAndReturn(STATUS_SORT, statusIds, DEFAULT_ORGANIZATION_ID, TemplateScene.BUG.name());
assertSortStatusItem(DEFAULT_ORGANIZATION_ID, statusIds);