-
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-628: UC7 - Shipper - Approve Draft Transport Document
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
5 changed files
with
226 additions
and
13 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
90 changes: 90 additions & 0 deletions
90
...csa/conformance/standards/ebl/action/UC7_Shipper_ApproveDraftTransportDocumentAction.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,90 @@ | ||
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 UC7_Shipper_ApproveDraftTransportDocumentAction extends StateChangingSIAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
private final JsonSchemaValidator responseSchemaValidator; | ||
private final JsonSchemaValidator notificationSchemaValidator; | ||
|
||
public UC7_Shipper_ApproveDraftTransportDocumentAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
EblAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator, | ||
JsonSchemaValidator responseSchemaValidator, | ||
JsonSchemaValidator notificationSchemaValidator) { | ||
super(shipperPartyName, carrierPartyName, previousAction, "UC7", 200); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
this.responseSchemaValidator = responseSchemaValidator; | ||
this.notificationSchemaValidator = notificationSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC7: Approve the draft transport document using the following parameters:"); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
return super.asJsonNode() | ||
.put("documentReference", getDspSupplier().get().transportDocumentReference()); | ||
} | ||
|
||
@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 tdr = dsp.transportDocumentReference() != null ? dsp.transportDocumentReference() : "<DSP MISSING TD REFERENCE>"; | ||
Stream<ActionCheck> primaryExchangeChecks = | ||
Stream.of( | ||
new HttpMethodCheck(EblRole::isShipper, getMatchedExchangeUuid(), "PATCH"), | ||
new UrlPathCheck(EblRole::isShipper, getMatchedExchangeUuid(), "/v3/transport-documents/%s".formatted(tdr)), | ||
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, | ||
getTDNotificationChecks( | ||
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
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