Skip to content

Commit

Permalink
Merge pull request #114 from dcsaorg/DT-1370
Browse files Browse the repository at this point in the history
Dt 1370
  • Loading branch information
preetamnpr authored Sep 5, 2024
2 parents d3017a6 + 0323b0e commit 362dfff
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class BookingChecks {

private static final JsonPointer CARRIER_BOOKING_REQUEST_REFERENCE = JsonPointer.compile("/carrierBookingRequestReference");
private static final JsonPointer CARRIER_BOOKING_REFERENCE = JsonPointer.compile("/carrierBookingReference");
private static final String RE_EMPTY_CONTAINER_PICKUP = "emptyContainerPickup";
private static final JsonPointer BOOKING_STATUS = JsonPointer.compile("/bookingStatus");
public static ActionCheck requestContentChecks(UUID matched, String standardVersion, Supplier<CarrierScenarioParameters> cspSupplier, Supplier<DynamicScenarioParameters> dspSupplier) {
var checks = new ArrayList<>(STATIC_BOOKING_CHECKS);
Expand Down Expand Up @@ -394,6 +396,39 @@ private static Set<String> validateDocumentPartyFields(JsonNode documentPartyNod
if(!"SD".equals(receiptTypeAtOrigin) && ielNode != null) {
issues.add("Container intermediate export stop-off location should not be provided");
}
if("SD".equals(receiptTypeAtOrigin)) {
var requestedEquipments = body.path("requestedEquipments");
if (requestedEquipments.isArray()) {
AtomicInteger counter = new AtomicInteger(0);
StreamSupport.stream(requestedEquipments.spliterator(), false)
.forEach(element -> {
int currentCount = counter.getAndIncrement();
var containerPositionings = element.path("containerPositionings");
var containerPositionsDateTime = StreamSupport.stream(containerPositionings.spliterator(), false)
.filter(o -> !o.path("dateTime").asText("").isEmpty())
.findFirst()
.orElse(null);
if ((preNode == null || preNode.isEmpty()) || containerPositionsDateTime == null){
issues.add("Empty container positioning DateTime at requestedEquipments position %s must be provided.".formatted(currentCount));
}
});
}
}
if("CY".equals(receiptTypeAtOrigin)) {
var requestedEquipments = body.path("requestedEquipments");
if (requestedEquipments.isArray()) {
AtomicInteger counter = new AtomicInteger(0);
StreamSupport.stream(requestedEquipments.spliterator(), false)
.forEach(element -> {
int currentCount = counter.getAndIncrement();
if (element.path(RE_EMPTY_CONTAINER_PICKUP).isContainerNode()
&& element.path(RE_EMPTY_CONTAINER_PICKUP).path("dateTime").asText("").isEmpty()
&& element.path(RE_EMPTY_CONTAINER_PICKUP).path("depotReleaseLocation").asText("").isEmpty()) {
issues.add("Empty container Pickup DateTime/depotReleaseLocation at requestedEquipments position %s must be provided.".formatted(currentCount));
}
});
}
}
return issues;
});

Expand Down Expand Up @@ -729,8 +764,7 @@ private static void generateScenarioRelatedChecks(List<JsonContentCheck> checks,
}
return Set.of();
}
)
);
));

private static final List<JsonContentCheck> RESPONSE_ONLY_CHECKS = Arrays.asList(
CHECK_ABSENCE_OF_CONFIRMED_FIELDS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"bookingAgent": {
"partyName": "DCSA Conformance Toolkit",
"address": {
"name": "Mustermann",
"street": "Strawinskylaan 4117",
"floor": "6",
"postCode": "1077 ZX",
Expand All @@ -59,16 +58,13 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "ADDR",
"address" : {
"name" : "Henrik",
"street": "Taylorweg",
"streetNumber": "5",
"postCode": "5466",
Expand All @@ -77,6 +73,18 @@
}
},
"locationTypeCode": "POD"
},
{
"location": {
"address" : {
"street": "Taylorweg",
"streetNumber": "5",
"postCode": "5466",
"city": "AE Veghel",
"countryCode": "NL"
}
},
"locationTypeCode": "PRE"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POL_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POL"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "POD_UNLOCATION_CODE_PLACEHOLDER"
},
"locationTypeCode": "POD"
Expand Down

0 comments on commit 362dfff

Please sign in to comment.