-
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-626: UC6 - Carrier - Publish draft transport document
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
9 changed files
with
503 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
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
65 changes: 65 additions & 0 deletions
65
...in/java/org/dcsa/conformance/standards/ebl/action/Shipper_GetTransportDocumentAction.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,65 @@ | ||
package org.dcsa.conformance.standards.ebl.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import java.util.stream.Stream; | ||
import org.dcsa.conformance.core.check.*; | ||
import org.dcsa.conformance.core.traffic.HttpMessageType; | ||
import org.dcsa.conformance.standards.ebl.party.*; | ||
|
||
public class Shipper_GetTransportDocumentAction extends EblAction { | ||
|
||
private final TransportDocumentStatus expectedTdStatus; | ||
private final JsonSchemaValidator responseSchemaValidator; | ||
|
||
public Shipper_GetTransportDocumentAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
EblAction previousAction, | ||
TransportDocumentStatus expectedTdStatus, | ||
JsonSchemaValidator responseSchemaValidator) { | ||
super(shipperPartyName, carrierPartyName, previousAction, "GET TD", 200); | ||
this.expectedTdStatus = expectedTdStatus; | ||
this.responseSchemaValidator = responseSchemaValidator; | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
return super.asJsonNode() | ||
.put("tdr", getDspSupplier().get().transportDocumentReference()); | ||
} | ||
|
||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return "GET the TD with reference '%s'" | ||
.formatted(getDspSupplier().get().transportDocumentReference()); | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
var dsp = getDspSupplier().get(); | ||
var tdr = dsp.transportDocumentReference() != null ? dsp.transportDocumentReference() : "<UNKNOWN-TDR>"; | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
return Stream.of( | ||
new UrlPathCheck( | ||
EblRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
"/v3/transport-documents/" + tdr), | ||
new ResponseStatusCheck( | ||
EblRole::isCarrier, getMatchedExchangeUuid(), expectedStatus), | ||
new ApiHeaderCheck( | ||
EblRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
EblRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion)); | ||
} | ||
}; | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
...csa/conformance/standards/ebl/action/UC6_Carrier_PublishDraftTransportDocumentAction.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,65 @@ | ||
package org.dcsa.conformance.standards.ebl.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import java.util.stream.Stream; | ||
import lombok.Getter; | ||
import org.dcsa.conformance.core.check.*; | ||
import org.dcsa.conformance.core.traffic.HttpMessageType; | ||
import org.dcsa.conformance.standards.ebl.party.EblRole; | ||
|
||
@Getter | ||
public class UC6_Carrier_PublishDraftTransportDocumentAction extends StateChangingSIAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
|
||
public UC6_Carrier_PublishDraftTransportDocumentAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
EblAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator) { | ||
super(carrierPartyName, shipperPartyName, previousAction, "UC6", 204); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC6: Publish draft transport document for shipping instructions with reference %s" | ||
.formatted(getDspSupplier().get().shippingInstructionsReference())); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
return super.asJsonNode() | ||
.put("documentReference", getDspSupplier().get().shippingInstructionsReference()); | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
return Stream.of( | ||
new HttpMethodCheck(EblRole::isCarrier, getMatchedExchangeUuid(), "POST"), | ||
new UrlPathCheck( | ||
EblRole::isCarrier, getMatchedExchangeUuid(), "/v3/transport-document-notifications"), | ||
new ResponseStatusCheck( | ||
EblRole::isShipper, getMatchedExchangeUuid(), expectedStatus), | ||
// TODO: Notification payload check | ||
new ApiHeaderCheck( | ||
EblRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
EblRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
new JsonSchemaCheck( | ||
EblRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
requestSchemaValidator)); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.