-
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-618: Add UC6 - Request Update to Confirmed Booking
Signed-off-by: Niels Thykier <[email protected]>
- Loading branch information
Showing
4 changed files
with
93 additions
and
2 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
66 changes: 66 additions & 0 deletions
66
...nformance/standards/booking/action/UC6_Carrier_RequestUpdateToConfirmedBookingAction.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,66 @@ | ||
package org.dcsa.conformance.standards.booking.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Getter; | ||
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 | ||
public class UC6_Carrier_RequestUpdateToConfirmedBookingAction extends BookingAction { | ||
private final JsonSchemaValidator requestSchemaValidator; | ||
|
||
public UC6_Carrier_RequestUpdateToConfirmedBookingAction( | ||
String carrierPartyName, | ||
String shipperPartyName, | ||
BookingAction previousAction, | ||
JsonSchemaValidator requestSchemaValidator) { | ||
super(carrierPartyName, shipperPartyName, previousAction, "UC6", 204); | ||
this.requestSchemaValidator = requestSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("UC6: Request update to the confirmed booking with CBR %s" | ||
.formatted(getDspSupplier().get().carrierBookingReference())); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
ObjectNode jsonNode = super.asJsonNode(); | ||
var dsp = getDspSupplier().get(); | ||
return jsonNode.put("cbr", dsp.carrierBookingReference()) | ||
.put("cbrr", dsp.carrierBookingRequestReference() ); | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
return Stream.of( | ||
new UrlPathCheck( | ||
BookingRole::isCarrier, getMatchedExchangeUuid(), "/v2/booking-notifications"), | ||
new ResponseStatusCheck( | ||
BookingRole::isShipper, getMatchedExchangeUuid(), expectedStatus), | ||
new ApiHeaderCheck( | ||
BookingRole::isCarrier, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
BookingRole::isShipper, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
new JsonSchemaCheck( | ||
BookingRole::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