Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dt 786 #71

Merged
merged 21 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public String getHumanReadablePrompt() {
@Override
public JsonNode getJsonForHumanReadablePrompt() {
var csp = switch (scenarioType) {
case REGULAR, REGULAR_SHIPPER_OWNED -> new CarrierScenarioParameters("Example Carrier Service",
case REGULAR, REGULAR_SHIPPER_OWNED -> new CarrierScenarioParameters( "SCR-1234-REGULAR",
"Example Carrier Service",
"402E",
"service Name",
"640510",
Expand All @@ -69,7 +70,8 @@ public JsonNode getJsonForHumanReadablePrompt() {
null,
"DKAAR",
"DEBRV");
case REGULAR_2RE1C, REGULAR_2RE2C -> new CarrierScenarioParameters("Example Carrier Service",
case REGULAR_2RE1C, REGULAR_2RE2C -> new CarrierScenarioParameters( "SCR-1234-REGULAR-2REC",
"Example Carrier Service",
"402E",
"service Name",
"630260",
Expand All @@ -78,7 +80,8 @@ public JsonNode getJsonForHumanReadablePrompt() {
"Kitchen pots and pans",
"DKAAR",
"DEBRV");
case REGULAR_CHO_DEST -> new CarrierScenarioParameters("Example Carrier Service",
case REGULAR_CHO_DEST -> new CarrierScenarioParameters("SCR-1234-REGULAR-CHO-DEST",
"Example Carrier Service",
"402E",
"service Name",
"640510",
Expand All @@ -87,7 +90,8 @@ public JsonNode getJsonForHumanReadablePrompt() {
null,
"DKAAR",
"USGBO");
case REGULAR_CHO_ORIG -> new CarrierScenarioParameters("Example Carrier Service",
case REGULAR_CHO_ORIG -> new CarrierScenarioParameters("SCR-1234-REGULAR-CHO-ORIG",
"Example Carrier Service",
"402E",
"service Name",
"640510",
Expand All @@ -96,7 +100,8 @@ public JsonNode getJsonForHumanReadablePrompt() {
null,
"DKAAR",
"DKAAR");
case REGULAR_NON_OPERATING_REEFER -> new CarrierScenarioParameters("Example Carrier Service",
case REGULAR_NON_OPERATING_REEFER -> new CarrierScenarioParameters("SCR-1234-NON-OPERATING-REEFER",
"Example Carrier Service",
"402E",
"service Name",
"220291",
Expand All @@ -105,7 +110,8 @@ public JsonNode getJsonForHumanReadablePrompt() {
null,
"DKAAR",
"DEBRV");
case REEFER, REEFER_TEMP_CHANGE -> new CarrierScenarioParameters("Example Carrier Service",
case REEFER, REEFER_TEMP_CHANGE -> new CarrierScenarioParameters( "SCR-1234-REEFER",
"Example Carrier Service",
"402E",
"service Name",
"04052090",
Expand All @@ -114,7 +120,8 @@ public JsonNode getJsonForHumanReadablePrompt() {
null,
"DKAAR",
"DEBRV");
case DG -> new CarrierScenarioParameters("Example Carrier Service",
case DG -> new CarrierScenarioParameters("SCR-1234-DG",
"Example Carrier Service",
"403W",
"TA1",
"293499",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package org.dcsa.conformance.standards.booking.action;

import java.util.*;
import java.util.function.Function;

import java.util.stream.Stream;

import com.fasterxml.jackson.databind.node.ObjectNode;
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.toolkit.JsonToolkit;
import org.dcsa.conformance.core.traffic.ConformanceExchange;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.CarrierGetBookingPayloadResponseConformanceCheck;
import org.dcsa.conformance.standards.booking.checks.BookingChecks;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;

Expand Down Expand Up @@ -82,46 +79,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator),
new CarrierGetBookingPayloadResponseConformanceCheck(
nt-gt marked this conversation as resolved.
Show resolved Hide resolved
getMatchedExchangeUuid(),
expectedBookingStatus,
expectedAmendedBookingStatus,
requestAmendedContent),
new ActionCheck(
"GET returns the expected Booking data",
BookingRole::isCarrier,
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE) {
@Override
protected Set<String> checkConformance(
Function<UUID, ConformanceExchange> getExchangeByUuid) {
ConformanceExchange getExchange = getExchangeByUuid.apply(getMatchedExchangeUuid());
if (getExchange == null) return Set.of();
Set<String> conformanceErrors = new HashSet<>();
if (previousAction
instanceof UC1_Shipper_SubmitBookingRequestAction submitBookingRequestAction) {
ConformanceExchange submitBookingRequestExchange =
getExchangeByUuid.apply(submitBookingRequestAction.getMatchedExchangeUuid());
if (submitBookingRequestExchange == null) return Set.of();
// this is just an example
String uc1CarrierServiceName =
JsonToolkit.getTextAttributeOrNull(
submitBookingRequestExchange.getRequest().message().body().getJsonBody(),
"carrierServiceName");
String getCarrierServiceName =
JsonToolkit.getTextAttributeOrNull(
getExchange.getResponse().message().body().getJsonBody(),
"carrierServiceName");
if (!Objects.equals(uc1CarrierServiceName, getCarrierServiceName)) {
conformanceErrors.add(
"Expected carrierServiceName '%s' but found '%s'"
.formatted(uc1CarrierServiceName, getCarrierServiceName));
}
}
return conformanceErrors;
}
})
// .filter(Objects::nonNull)
BookingChecks.responseContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier(), expectedBookingStatus, expectedAmendedBookingStatus))
;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.extern.slf4j.Slf4j;
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.BookingChecks;
import org.dcsa.conformance.standards.booking.checks.CarrierBookingRefStatusPayloadResponseConformanceCheck;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import lombok.extern.slf4j.Slf4j;
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.BookingChecks;
import org.dcsa.conformance.standards.booking.checks.CarrierBookingRefStatusPayloadResponseConformanceCheck;
import org.dcsa.conformance.standards.booking.checks.ScenarioType;
import org.dcsa.conformance.standards.booking.checks.ShipperBookingContentConformanceCheck;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;

Expand Down Expand Up @@ -56,7 +55,6 @@ public ConformanceCheck createCheck(String expectedApiVersion) {
return new ConformanceCheck(getActionTitle()) {
@Override
protected Stream<? extends ConformanceCheck> createSubChecks() {
var scenarioType = getDspSupplier().get().scenarioType();
Stream<ActionCheck> primaryExchangeChecks =
Stream.of(
new HttpMethodCheck(BookingRole::isShipper, getMatchedExchangeUuid(), "POST"),
Expand All @@ -77,7 +75,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
BookingState.RECEIVED
),
new ShipperBookingContentConformanceCheck(getMatchedExchangeUuid(),scenarioType),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier()),
new JsonSchemaCheck(
BookingRole::isShipper,
getMatchedExchangeUuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.traffic.ConformanceExchange;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.BookingChecks;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;

Expand Down Expand Up @@ -81,7 +82,8 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
BookingRole::isCarrier,
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator));
responseSchemaValidator),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier()));
return Stream.concat(
primaryExchangeChecks,
getNotificationChecks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.extern.slf4j.Slf4j;
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.BookingChecks;
import org.dcsa.conformance.standards.booking.checks.CarrierBookingRefStatusPayloadResponseConformanceCheck;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;
Expand Down Expand Up @@ -84,7 +85,8 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
BookingRole::isCarrier,
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator));
responseSchemaValidator),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier()));
return Stream.concat(
Stream.concat(primaryExchangeChecks,
Stream.of(new CarrierBookingRefStatusPayloadResponseConformanceCheck(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.traffic.ConformanceExchange;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.BookingChecks;
import org.dcsa.conformance.standards.booking.checks.CarrierBookingRefStatusPayloadResponseConformanceCheck;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ abstract class AbstractCarrierPayloadConformanceCheck extends PayloadContentConf
BookingState.PENDING_AMENDMENT
);
nt-gt marked this conversation as resolved.
Show resolved Hide resolved

protected static final Set<BookingState> CONFIRMED_BOOKING_STATES = Set.of(
BookingState.CONFIRMED,
BookingState.PENDING_AMENDMENT,
BookingState.COMPLETED,
BookingState.DECLINED
);

protected static final Set<BookingState> REASON_STATES = Set.of(
BookingState.PENDING_UPDATE,
BookingState.PENDING_AMENDMENT,
BookingState.DECLINED,
BookingState.REJECTED,
BookingState.CANCELLED,
BookingState.AMENDMENT_CANCELLED,
BookingState.AMENDMENT_DECLINED
BookingState.AMENDMENT_DECLINED,
BookingState.AMENDMENT_CANCELLED
);

protected static final Set<BookingState> BOOKING_STATES_WHERE_CBR_IS_OPTIONAL = Set.of(
Expand Down
Loading
Loading