Skip to content

Commit

Permalink
Sync outbound exchange capture, sandbox task lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
gj0dcsa committed Dec 24, 2023
1 parent 50d4ecb commit ef0fd26
Show file tree
Hide file tree
Showing 36 changed files with 438 additions and 432 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.databind.JsonNode;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.SneakyThrows;
Expand All @@ -11,12 +10,12 @@
import org.dcsa.conformance.core.party.ConformanceParty;
import org.dcsa.conformance.core.party.CounterpartConfiguration;
import org.dcsa.conformance.core.party.PartyConfiguration;
import org.dcsa.conformance.core.party.PartyWebClient;
import org.dcsa.conformance.core.scenario.ScenarioListBuilder;
import org.dcsa.conformance.core.state.JsonNodeMap;
import org.dcsa.conformance.core.toolkit.JsonToolkit;
import org.dcsa.conformance.core.traffic.ConformanceRequest;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingCarrier;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingShipper;

public class BookingComponentFactory extends AbstractComponentFactory {
Expand All @@ -40,7 +39,7 @@ public List<ConformanceParty> createParties(
PartyConfiguration[] partyConfigurations,
CounterpartConfiguration[] counterpartConfigurations,
JsonNodeMap persistentMap,
Consumer<ConformanceRequest> asyncWebClient,
PartyWebClient webClient,
Map<String, ? extends Collection<String>> orchestratorAuthHeader) {
Map<String, PartyConfiguration> partyConfigurationsByRoleName =
Arrays.stream(partyConfigurations)
Expand All @@ -60,7 +59,7 @@ public List<ConformanceParty> createParties(
carrierConfiguration,
counterpartConfigurationsByRoleName.get(BookingRole.SHIPPER.getConfigName()),
persistentMap,
asyncWebClient,
webClient,
orchestratorAuthHeader));
}

Expand All @@ -73,7 +72,7 @@ public List<ConformanceParty> createParties(
shipperConfiguration,
counterpartConfigurationsByRoleName.get(BookingRole.CARRIER.getConfigName()),
persistentMap,
asyncWebClient,
webClient,
orchestratorAuthHeader));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
package org.dcsa.conformance.standards.booking.action;

import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Stream;
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.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;

public class Shipper_GetAmendedBooking404Action extends BookingAction {

public Shipper_GetAmendedBooking404Action(
String carrierPartyName,
String shipperPartyName,
BookingAction previousAction) {
super(shipperPartyName, carrierPartyName, previousAction, "GET (amended content, non-existing)", 404);
String carrierPartyName, String shipperPartyName, BookingAction previousAction) {
super(
shipperPartyName,
carrierPartyName,
previousAction,
"GET (amended content, non-existing)",
404);
}

@Override
public ObjectNode asJsonNode() {
return super.asJsonNode()
.put("cbrr", getDspSupplier().get().carrierBookingRequestReference())
.put("amendedContent", true);
.put("cbrr", getDspSupplier().get().carrierBookingRequestReference())
.put("amendedContent", true);
}

@Override
public String getHumanReadablePrompt() {
return "GET the (non-existing) amendment to the booking with CBR '%s'"
.formatted(getDspSupplier().get().carrierBookingReference());
return "GET the (non-existing) amendment to the booking with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference());
}

@Override
Expand All @@ -45,11 +44,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
"/v2/bookings/" + getDspSupplier().get().carrierBookingRequestReference()),
new QueryParamCheck(
BookingRole::isShipper,
getMatchedExchangeUuid(),
"amendedContent",
"true"
),
BookingRole::isShipper, getMatchedExchangeUuid(), "amendedContent", "true"),
new ResponseStatusCheck(
BookingRole::isCarrier, getMatchedExchangeUuid(), expectedStatus),
new ApiHeaderCheck(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public Shipper_GetBookingAction(
BookingState expectedAmendedBookingStatus,
JsonSchemaValidator responseSchemaValidator,
boolean requestAmendedStatus) {
super(shipperPartyName, carrierPartyName, previousAction, requestAmendedStatus ? "GET (amended content)" : "GET", 200);
super(
shipperPartyName,
carrierPartyName,
previousAction,
requestAmendedStatus ? "GET (amended content)" : "GET",
200);
this.expectedBookingStatus = expectedBookingStatus;
this.expectedAmendedBookingStatus = expectedAmendedBookingStatus;
this.responseSchemaValidator = responseSchemaValidator;
Expand All @@ -38,14 +43,16 @@ public Shipper_GetBookingAction(
@Override
public ObjectNode asJsonNode() {
return super.asJsonNode()
.put("cbrr", getDspSupplier().get().carrierBookingRequestReference())
.put("amendedContent", requestAmendedContent);
.put("cbrr", getDspSupplier().get().carrierBookingRequestReference())
.put("amendedContent", requestAmendedContent);
}

@Override
public String getHumanReadablePrompt() {
return "GET the booking with CBR '%s'"
.formatted(getDspSupplier().get().carrierBookingReference());
return "GET the booking with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference());
}

@Override
Expand All @@ -71,17 +78,15 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
HttpMessageType.RESPONSE,
expectedApiVersion),
new JsonSchemaCheck(
BookingRole::isCarrier,
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator
),
BookingRole::isCarrier,
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator),
new CarrierGetBookingPayloadResponseConformanceCheck(
getMatchedExchangeUuid(),
expectedBookingStatus,
expectedAmendedBookingStatus,
requestAmendedContent
),
getMatchedExchangeUuid(),
expectedBookingStatus,
expectedAmendedBookingStatus,
requestAmendedContent),
new ActionCheck(
"GET returns the expected Booking data",
BookingRole::isCarrier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ public UC10_Carrier_DeclineBookingAction(

@Override
public String getHumanReadablePrompt() {
return ("UC10: Decline the booking request with CBR %s"
.formatted(getDspSupplier().get().carrierBookingReference()));
return ("UC10: Decline the booking request with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference()));
}

@Override
public ObjectNode asJsonNode() {
ObjectNode jsonNode = super.asJsonNode();
var dsp = getDspSupplier().get();
return jsonNode.put("cbr", dsp.carrierBookingReference())
.put("cbrr", dsp.carrierBookingRequestReference() );
return jsonNode
.put("cbr", dsp.carrierBookingReference())
.put("cbrr", dsp.carrierBookingRequestReference());
}

@Override
Expand All @@ -50,14 +53,13 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
new CarrierBookingNotificationDataPayloadRequestConformanceCheck(
getMatchedExchangeUuid(),
BookingState.DECLINED,
dsp.amendedBookingStatus() != null ? BookingState.AMENDMENT_DECLINED : null
),
dsp.amendedBookingStatus() != null ? BookingState.AMENDMENT_DECLINED : null),
ApiHeaderCheck.createNotificationCheck(
BookingRole::isCarrier,
getMatchedExchangeUuid(),
HttpMessageType.REQUEST,
expectedApiVersion),
ApiHeaderCheck.createNotificationCheck(
ApiHeaderCheck.createNotificationCheck(
BookingRole::isShipper,
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@ public UC12_Carrier_ConfirmBookingCompletedAction(

@Override
public String getHumanReadablePrompt() {
return ("UC12: Complete the booking request with CBR %s"
.formatted(getDspSupplier().get().carrierBookingReference()));
return ("UC12: Complete the booking request with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference()));
}

@Override
public ObjectNode asJsonNode() {
ObjectNode jsonNode = super.asJsonNode();
var dsp = getDspSupplier().get();
return jsonNode.put("cbrr", dsp.carrierBookingRequestReference())
.put("cbr", dsp.carrierBookingReference());
return jsonNode
.put("cbrr", dsp.carrierBookingRequestReference())
.put("cbr", dsp.carrierBookingReference());
}

@Override
public ConformanceCheck createCheck(String expectedApiVersion) {
return new ConformanceCheck(getActionTitle()) {
@Override
protected Stream<? extends ConformanceCheck> createSubChecks() {
var dsp = getDspSupplier().get();
return Stream.of(
new UrlPathCheck(
BookingRole::isCarrier, getMatchedExchangeUuid(), "/v2/booking-notifications"),
new ResponseStatusCheck(
BookingRole::isShipper, getMatchedExchangeUuid(), expectedStatus),
new CarrierBookingNotificationDataPayloadRequestConformanceCheck(
getMatchedExchangeUuid(),
BookingState.COMPLETED
),
getMatchedExchangeUuid(), BookingState.COMPLETED),
ApiHeaderCheck.createNotificationCheck(
BookingRole::isCarrier,
getMatchedExchangeUuid(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package org.dcsa.conformance.standards.booking.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.booking.checks.CarrierBookingNotificationDataPayloadRequestConformanceCheck;
import org.dcsa.conformance.standards.booking.checks.CarrierBookingRefStatusPayloadResponseConformanceCheck;
import org.dcsa.conformance.standards.booking.party.BookingRole;
import org.dcsa.conformance.standards.booking.party.BookingState;

import java.util.stream.Stream;

@Getter
public class UC2_Carrier_RequestUpdateToBookingRequestAction extends StateChangingBookingAction {
private final JsonSchemaValidator requestSchemaValidator;
Expand All @@ -26,8 +24,10 @@ public UC2_Carrier_RequestUpdateToBookingRequestAction(

@Override
public String getHumanReadablePrompt() {
return ("UC2: Request update to the booking request with CBRR %s"
.formatted(getDspSupplier().get().carrierBookingRequestReference()));
return ("UC2: Request update to the booking request with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference()));
}

@Override
Expand All @@ -42,15 +42,13 @@ public ConformanceCheck createCheck(String expectedApiVersion) {
@Override
protected Stream<? extends ConformanceCheck> createSubChecks() {
return Stream.of(
new HttpMethodCheck(BookingRole::isCarrier, getMatchedExchangeUuid(), "POST"),
new HttpMethodCheck(BookingRole::isCarrier, getMatchedExchangeUuid(), "POST"),
new UrlPathCheck(
BookingRole::isCarrier, getMatchedExchangeUuid(), "/v2/booking-notifications"),
new ResponseStatusCheck(
BookingRole::isShipper, getMatchedExchangeUuid(), expectedStatus),
new CarrierBookingNotificationDataPayloadRequestConformanceCheck(
getMatchedExchangeUuid(),
BookingState.PENDING_UPDATE
),
getMatchedExchangeUuid(), BookingState.PENDING_UPDATE),
ApiHeaderCheck.createNotificationCheck(
BookingRole::isCarrier,
getMatchedExchangeUuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.dcsa.conformance.core.check.*;
import org.dcsa.conformance.core.traffic.HttpMessageType;
import org.dcsa.conformance.standards.booking.checks.CarrierBookingNotificationDataPayloadRequestConformanceCheck;
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 All @@ -26,8 +25,10 @@ public UC4_Carrier_RejectBookingRequestAction(

@Override
public String getHumanReadablePrompt() {
return ("UC4: Reject the booking request with CBRR %s"
.formatted(getDspSupplier().get().carrierBookingRequestReference()));
return ("UC4: Reject the booking request with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference()));
}

@Override
Expand All @@ -48,9 +49,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
new ResponseStatusCheck(
BookingRole::isShipper, getMatchedExchangeUuid(), expectedStatus),
new CarrierBookingNotificationDataPayloadRequestConformanceCheck(
getMatchedExchangeUuid(),
BookingState.REJECTED
),
getMatchedExchangeUuid(), BookingState.REJECTED),
ApiHeaderCheck.createNotificationCheck(
BookingRole::isCarrier,
getMatchedExchangeUuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import java.util.stream.Stream;
import lombok.Getter;
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.CarrierBookingNotificationDataPayloadRequestConformanceCheck;
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 All @@ -20,24 +18,23 @@ public UC5_Carrier_ConfirmBookingRequestAction(
String shipperPartyName,
BookingAction previousAction,
JsonSchemaValidator requestSchemaValidator) {
super(
carrierPartyName,
shipperPartyName,
previousAction,
"UC5",
204);
super(carrierPartyName, shipperPartyName, previousAction, "UC5", 204);
this.requestSchemaValidator = requestSchemaValidator;
}

@Override
public String getHumanReadablePrompt() {
return ("UC5: Confirm the booking request with CBRR %s".formatted(getDspSupplier().get()));
return ("UC5: Confirm the booking request with CBR '%s' and CBRR '%s'"
.formatted(
getDspSupplier().get().carrierBookingReference(),
getDspSupplier().get().carrierBookingRequestReference()));
}

@Override
public ObjectNode asJsonNode() {
ObjectNode jsonNode = super.asJsonNode();
return jsonNode.put("cbrr", getDspSupplier().get().carrierBookingRequestReference())
return jsonNode
.put("cbrr", getDspSupplier().get().carrierBookingRequestReference())
.put("cbr", getDspSupplier().get().carrierBookingReference());
}

Expand All @@ -52,9 +49,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
new ResponseStatusCheck(
BookingRole::isShipper, getMatchedExchangeUuid(), expectedStatus),
new CarrierBookingNotificationDataPayloadRequestConformanceCheck(
getMatchedExchangeUuid(),
BookingState.CONFIRMED
),
getMatchedExchangeUuid(), BookingState.CONFIRMED),
ApiHeaderCheck.createNotificationCheck(
BookingRole::isCarrier,
getMatchedExchangeUuid(),
Expand Down
Loading

0 comments on commit ef0fd26

Please sign in to comment.