-
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-617: Implement UC12 - cancel by shipper
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
9 changed files
with
270 additions
and
31 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
74 changes: 74 additions & 0 deletions
74
...org/dcsa/conformance/standards/booking/action/UC12_Shipper_CancelEntireBookingAction.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,74 @@ | ||
package org.dcsa.conformance.standards.booking.action; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
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.booking.party.BookingRole; | ||
|
||
import java.util.stream.Stream; | ||
|
||
@Getter | ||
@Slf4j | ||
public class UC12_Shipper_CancelEntireBookingAction extends BookingAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
|
||
public UC12_Shipper_CancelEntireBookingAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
BookingAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator) { | ||
super(shipperPartyName, carrierPartyName, previousAction, "UC12", 200); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC12: Cancel an entire booking"); | ||
} | ||
|
||
@Override | ||
public JsonNode getJsonForHumanReadablePrompt() { | ||
return getCspSupplier().get().toJson(); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
ObjectNode jsonNode = super.asJsonNode(); | ||
jsonNode.put("cbrr", getDspSupplier().get().carrierBookingRequestReference()); | ||
return jsonNode; | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
var cbrr = getDspSupplier().get().carrierBookingRequestReference(); | ||
return Stream.of( | ||
new UrlPathCheck(BookingRole::isShipper, getMatchedExchangeUuid(), "/v2/bookings/%s".formatted(cbrr)), | ||
new ResponseStatusCheck( | ||
BookingRole::isCarrier, getMatchedExchangeUuid(), expectedStatus), | ||
new ApiHeaderCheck( | ||
BookingRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
BookingRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
new JsonSchemaCheck( | ||
BookingRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
requestSchemaValidator)) | ||
// .filter(Objects::nonNull) | ||
; | ||
} | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.