-
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-623: EBL UC1 - Submit Shipping Instructions
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
14 changed files
with
2,619 additions
and
2,275 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
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
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
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
15 changes: 15 additions & 0 deletions
15
ebl/src/main/java/org/dcsa/conformance/standards/ebl/action/StateChangingSIAction.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,15 @@ | ||
package org.dcsa.conformance.standards.ebl.action; | ||
|
||
import org.dcsa.conformance.core.traffic.ConformanceExchange; | ||
|
||
public abstract class StateChangingSIAction extends EblAction { | ||
protected StateChangingSIAction(String sourcePartyName, String targetPartyName, EblAction previousAction, String actionTitle, int expectedStatus) { | ||
super(sourcePartyName, targetPartyName, previousAction, actionTitle, expectedStatus); | ||
} | ||
|
||
@Override | ||
protected void doHandleExchange(ConformanceExchange exchange) { | ||
super.doHandleExchange(exchange); | ||
updateDSPFromResponsePayload(exchange); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...g/dcsa/conformance/standards/ebl/action/UC1_Shipper_SubmitShippingInstructionsAction.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,89 @@ | ||
package org.dcsa.conformance.standards.ebl.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
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; | ||
|
||
@Getter | ||
@Slf4j | ||
public class UC1_Shipper_SubmitShippingInstructionsAction extends StateChangingSIAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
private final JsonSchemaValidator responseSchemaValidator; | ||
private final JsonSchemaValidator notificationSchemaValidator; | ||
|
||
public UC1_Shipper_SubmitShippingInstructionsAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
EblAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator, | ||
JsonSchemaValidator responseSchemaValidator, | ||
JsonSchemaValidator notificationSchemaValidator) { | ||
super(shipperPartyName, carrierPartyName, previousAction, "UC1", 201); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
this.responseSchemaValidator = responseSchemaValidator; | ||
this.notificationSchemaValidator = notificationSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC1: Submit a booking request using the following parameters:"); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
ObjectNode jsonNode = super.asJsonNode(); | ||
jsonNode.set("csp", getCspSupplier().get().toJson()); | ||
return jsonNode; | ||
} | ||
|
||
@Override | ||
protected boolean expectsNotificationExchange() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
Stream<ActionCheck> primaryExchangeChecks = | ||
Stream.of( | ||
new HttpMethodCheck(EblRole::isShipper, getMatchedExchangeUuid(), "POST"), | ||
new UrlPathCheck(EblRole::isShipper, getMatchedExchangeUuid(), "/v3/shipping-instructions"), | ||
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)); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.