-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DT-636: UC5 - Shipper - Cancel Update to Shipping Instructions
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
5 changed files
with
236 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...onformance/standards/ebl/action/UC5_Shipper_CancelUpdateToShippingInstructionsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package org.dcsa.conformance.standards.ebl.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
import java.util.Objects; | ||
import java.util.stream.Stream; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.dcsa.conformance.core.check.*; | ||
import org.dcsa.conformance.core.traffic.HttpMessageType; | ||
import org.dcsa.conformance.standards.ebl.party.EblRole; | ||
import org.dcsa.conformance.standards.ebl.party.ShippingInstructionsStatus; | ||
|
||
@Getter | ||
@Slf4j | ||
public class UC5_Shipper_CancelUpdateToShippingInstructionsAction extends StateChangingSIAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
private final JsonSchemaValidator responseSchemaValidator; | ||
private final JsonSchemaValidator notificationSchemaValidator; | ||
|
||
public UC5_Shipper_CancelUpdateToShippingInstructionsAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
EblAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator, | ||
JsonSchemaValidator responseSchemaValidator, | ||
JsonSchemaValidator notificationSchemaValidator) { | ||
super(shipperPartyName, carrierPartyName, previousAction, "UC5", 200); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
this.responseSchemaValidator = responseSchemaValidator; | ||
this.notificationSchemaValidator = notificationSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC5: Cancel update to shipping instructions the document reference %s".formatted( | ||
getDspSupplier().get().shippingInstructionsReference() | ||
)); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
return super.asJsonNode() | ||
.put("documentReference", getDspSupplier().get().shippingInstructionsReference()); | ||
} | ||
|
||
@Override | ||
protected boolean expectsNotificationExchange() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
var dsp = getDspSupplier().get(); | ||
var sir = dsp.shippingInstructionsReference() != null ? dsp.shippingInstructionsReference() : "<DSP MISSING SI REFERENCE>"; | ||
Stream<ActionCheck> primaryExchangeChecks = | ||
Stream.of( | ||
new HttpMethodCheck(EblRole::isShipper, getMatchedExchangeUuid(), "PATCH"), | ||
new UrlPathCheck(EblRole::isShipper, getMatchedExchangeUuid(), "/v3/shipping-instructions/%s".formatted(sir)), | ||
new ResponseStatusCheck( | ||
EblRole::isCarrier, getMatchedExchangeUuid(), expectedStatus), | ||
new ApiHeaderCheck( | ||
EblRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
EblRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
// TODO: Add Carrier Ref Status Payload response check | ||
// TODO: Add Shipper content conformance check | ||
new JsonSchemaCheck( | ||
EblRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
requestSchemaValidator), | ||
new JsonSchemaCheck( | ||
EblRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
responseSchemaValidator)); | ||
return Stream.concat( | ||
primaryExchangeChecks, | ||
getSINotificationChecks( | ||
expectedApiVersion, | ||
notificationSchemaValidator)); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.