feat: add dispatch retry and import recovery flows
This commit is contained in:
@@ -69,6 +69,21 @@ public class BossApiClientDispatchPlansTest {
|
||||
assertEquals("{}", connection.requestBody());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void retryDispatchPlanUsesProjectScopedRetryEndpoint() throws Exception {
|
||||
RecordingConnection connection = new RecordingConnection(new URL("https://boss.hyzq.net/api/v1/projects/p1/dispatch-plans/plan-1/retry"));
|
||||
RecordingBossApiClient apiClient = new RecordingBossApiClient(connection);
|
||||
|
||||
BossApiClient.ApiResponse response = apiClient.retryDispatchPlan("p1", "plan-1");
|
||||
|
||||
assertEquals(200, response.statusCode);
|
||||
assertEquals("/api/v1/projects/p1/dispatch-plans/plan-1/retry", apiClient.lastPath);
|
||||
assertEquals("POST", connection.requestMethodValue);
|
||||
assertEquals(12000, connection.connectTimeoutValue);
|
||||
assertEquals(65000, connection.readTimeoutValue);
|
||||
assertEquals("{}", connection.requestBody());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getProjectAgentControlsUsesScopedEndpoint() throws Exception {
|
||||
RecordingConnection connection = new RecordingConnection(new URL("https://boss.hyzq.net/api/v1/projects/master-agent/agent-controls"));
|
||||
|
||||
@@ -392,6 +392,47 @@ public class ProjectDetailActivityUiTest {
|
||||
assertEquals(null, ReflectionHelpers.getField(activity, "currentPendingDispatchPlan"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyDispatchPlanActionResponseStoresRejectedPlanForRecovery() throws Exception {
|
||||
Intent intent = new Intent()
|
||||
.putExtra(ProjectDetailActivity.EXTRA_PROJECT_ID, "group-1")
|
||||
.putExtra(ProjectDetailActivity.EXTRA_PROJECT_NAME, "巡检协作群");
|
||||
TestProjectDetailActivity activity = Robolectric
|
||||
.buildActivity(TestProjectDetailActivity.class, intent)
|
||||
.setup()
|
||||
.get();
|
||||
|
||||
ReflectionHelpers.setField(activity, "projectCollaborationMode", "approval_required");
|
||||
ReflectionHelpers.setField(activity, "projectApprovalState", "pending_user");
|
||||
ReflectionHelpers.setField(
|
||||
activity,
|
||||
"currentPendingDispatchPlan",
|
||||
new JSONObject().put("planId", "dispatch-plan-1").put("status", "pending_user_confirmation")
|
||||
);
|
||||
|
||||
JSONObject rejectedPlan = new JSONObject()
|
||||
.put("planId", "dispatch-plan-1")
|
||||
.put("status", "rejected");
|
||||
JSONObject response = new JSONObject()
|
||||
.put("plan", rejectedPlan)
|
||||
.put("collaborationGate", new JSONObject()
|
||||
.put("isGroup", true)
|
||||
.put("collaborationMode", "approval_required")
|
||||
.put("requiresMasterAgentApproval", true)
|
||||
.put("approvalState", "rejected"));
|
||||
|
||||
ReflectionHelpers.callInstanceMethod(
|
||||
activity,
|
||||
"applyDispatchPlanActionResponse",
|
||||
ReflectionHelpers.ClassParameter.from(JSONObject.class, response)
|
||||
);
|
||||
|
||||
assertEquals("rejected", ReflectionHelpers.getField(activity, "projectApprovalState"));
|
||||
assertEquals(null, ReflectionHelpers.getField(activity, "currentPendingDispatchPlan"));
|
||||
JSONObject storedRejected = ReflectionHelpers.getField(activity, "currentRejectedDispatchPlan");
|
||||
assertEquals("dispatch-plan-1", storedRejected.optString("planId"));
|
||||
}
|
||||
|
||||
private static JSONObject buildGroupProjectPayload() throws Exception {
|
||||
JSONObject threadMeta = new JSONObject()
|
||||
.put("threadId", "group-thread-3")
|
||||
|
||||
Reference in New Issue
Block a user