test(firstleg): cover phase3 container loading flow
This commit is contained in:
@@ -314,7 +314,7 @@ public class SmartLoadingService {
|
||||
|| !Objects.equals(history.getActionType(), action)
|
||||
|| itemId != null && !Objects.equals(history.getLoadingPlanItemId(), itemId)
|
||||
|| history.getAfterSnapshot() == null
|
||||
|| !history.getAfterSnapshot().contains("\"requestHash\":\"" + requestHash + "\"")) {
|
||||
|| !sameRequestHash(history.getAfterSnapshot(), requestHash)) {
|
||||
throw conflict("operationId 已用于不同请求");
|
||||
}
|
||||
LoadingPlanEntity plan = repository.plan(planId);
|
||||
@@ -322,6 +322,15 @@ public class SmartLoadingService {
|
||||
return view(plan, requireBooking(plan.getContainerBookingId()));
|
||||
}
|
||||
|
||||
private boolean sameRequestHash(String snapshot, String requestHash) {
|
||||
try {
|
||||
var value = objectMapper.readTree(snapshot);
|
||||
return value != null && requestHash.equals(value.path("requestHash").asText());
|
||||
} catch (JsonProcessingException exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void history(long planId, Long itemId, String action, String from, String to,
|
||||
String operation, long operatorId, String operatorName) {
|
||||
history(planId, itemId, action, from, to, operation, null, null, operatorId, operatorName);
|
||||
|
||||
Reference in New Issue
Block a user