-
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-625: UC2 - Carrier - Request update to shipping instructions
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
4 changed files
with
139 additions
and
7 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
65 changes: 65 additions & 0 deletions
65
...nformance/standards/ebl/action/UC2_Carrier_RequestUpdateToShippingInstructionsAction.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 UC2_Carrier_RequestUpdateToShippingInstructionsAction extends StateChangingSIAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
|
||
public UC2_Carrier_RequestUpdateToShippingInstructionsAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
EblAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator) { | ||
super(carrierPartyName, shipperPartyName, previousAction, "UC2", 204); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC2: Request update to the shipping instructions with shipping instructions 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/shipping-instructions-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)); | ||
} | ||
}; | ||
} | ||
} |
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