Skip to content

Commit

Permalink
DT-1154 No more beta suffixes and old betas
Browse files Browse the repository at this point in the history
  • Loading branch information
gj0dcsa committed Apr 27, 2024
2 parents b67c3a2 + 0010008 commit d4456f7
Show file tree
Hide file tree
Showing 77 changed files with 64 additions and 10,852 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class BookingComponentFactory extends AbstractComponentFactory {
public static final String STANDARD_NAME = "Booking";
public static final List<String> STANDARD_VERSIONS = List.of("2.0.0-Beta-1");
public static final List<String> STANDARD_VERSIONS = List.of("2.0.0");

private static final String CARRIER_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
private static final String SHIPPER_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator),
BookingChecks.responseContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier(), expectedBookingStatus, expectedAmendedBookingStatus))
BookingChecks.responseContentChecks(getMatchedExchangeUuid(), expectedApiVersion, getCspSupplier(), getDspSupplier(), expectedBookingStatus, expectedAmendedBookingStatus))
;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
BookingState.RECEIVED
),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier()),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), expectedApiVersion, getCspSupplier(), getDspSupplier()),
new JsonSchemaCheck(
BookingRole::isShipper,
getMatchedExchangeUuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
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;
Expand Down Expand Up @@ -83,7 +82,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier()));
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), expectedApiVersion, getCspSupplier(), getDspSupplier()));
return Stream.concat(
primaryExchangeChecks,
getNotificationChecks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
responseSchemaValidator),
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), getCspSupplier(), getDspSupplier()));
BookingChecks.requestContentChecks(getMatchedExchangeUuid(), expectedApiVersion, 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 @@ -59,13 +59,14 @@ 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 JsonPointer BOOKING_STATUS = JsonPointer.compile("/bookingStatus");
public static ActionCheck requestContentChecks(UUID matched, Supplier<CarrierScenarioParameters> cspSupplier, Supplier<DynamicScenarioParameters> dspSupplier) {
public static ActionCheck requestContentChecks(UUID matched, String standardVersion, Supplier<CarrierScenarioParameters> cspSupplier, Supplier<DynamicScenarioParameters> dspSupplier) {
var checks = new ArrayList<>(STATIC_BOOKING_CHECKS);
generateScenarioRelatedChecks(checks, cspSupplier, dspSupplier);
return JsonAttribute.contentChecks(
BookingRole::isShipper,
matched,
HttpMessageType.REQUEST,
standardVersion,
checks
);
}
Expand Down Expand Up @@ -636,7 +637,7 @@ private static void generateScenarioRelatedChecks(List<JsonContentCheck> checks,
REASON_FIELD_ABSENCE
);

public static ActionCheck responseContentChecks(UUID matched, Supplier<CarrierScenarioParameters> cspSupplier, Supplier<DynamicScenarioParameters> dspSupplier, BookingState bookingStatus, BookingState amendedBookingState) {
public static ActionCheck responseContentChecks(UUID matched, String standardVersion, Supplier<CarrierScenarioParameters> cspSupplier, Supplier<DynamicScenarioParameters> dspSupplier, BookingState bookingStatus, BookingState amendedBookingState) {
var checks = new ArrayList<JsonContentCheck>();
checks.add(JsonAttribute.mustEqual(
CARRIER_BOOKING_REQUEST_REFERENCE,
Expand Down Expand Up @@ -671,6 +672,7 @@ public static ActionCheck responseContentChecks(UUID matched, Supplier<CarrierSc
BookingRole::isCarrier,
matched,
HttpMessageType.RESPONSE,
standardVersion,
checks
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ protected Set<String> checkConformance(Function<UUID, ConformanceExchange> getEx
Collection<String> headerValues = headers.get(headerName);
if (headerValues.size() != 1) return Set.of("Duplicate Api-Version headers");
String exchangeApiVersion = headerValues.stream().findFirst().orElseThrow();
if (exchangeApiVersion.contains("-")) {
exchangeApiVersion = exchangeApiVersion.substring(0, exchangeApiVersion.indexOf("-"));
}
return switch (httpMessageType) {
case REQUEST -> isNotification
? _checkNotificationRequestApiVersionHeader(expectedVersion, exchangeApiVersion)
Expand Down
105 changes: 0 additions & 105 deletions core/src/main/java/org/dcsa/conformance/core/check/JsonAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ public class JsonAttribute {

private static final BiFunction<JsonNode, String, Set<String>> EMPTY_VALIDATOR = (ignoredA, ignoredB) -> Set.of();

@Deprecated
public static ActionCheck contentChecks(
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
HttpMessageType httpMessageType,
JsonContentCheck ... checks
) {
return contentChecks("", isRelevantForRoleName, matchedExchangeUuid, httpMessageType, Arrays.asList(checks));
}

public static ActionCheck contentChecks(
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
Expand All @@ -44,28 +34,6 @@ public static ActionCheck contentChecks(
return contentChecks(titlePrefix, isRelevantForRoleName, matchedExchangeUuid, httpMessageType, standardsVersion, Arrays.asList(checks));
}

public static ActionCheck contentChecks(
String titlePrefix,
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
HttpMessageType httpMessageType,
JsonContentCheck ... checks
) {
return contentChecks(titlePrefix, isRelevantForRoleName, matchedExchangeUuid, httpMessageType, Arrays.asList(checks));
}

@Deprecated
public static ActionCheck contentChecks(
String titlePrefix,
String title,
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
HttpMessageType httpMessageType,
JsonContentCheck ... checks
) {
return contentChecks(titlePrefix, title, isRelevantForRoleName, matchedExchangeUuid, httpMessageType, null, Arrays.asList(checks));
}

public static ActionCheck contentChecks(
String titlePrefix,
String title,
Expand All @@ -79,16 +47,6 @@ public static ActionCheck contentChecks(
}


@Deprecated
public static ActionCheck contentChecks(
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
HttpMessageType httpMessageType,
List<JsonContentCheck> checks
) {
return contentChecks("", isRelevantForRoleName, matchedExchangeUuid, httpMessageType, null, checks);
}

public static ActionCheck contentChecks(
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
Expand All @@ -99,17 +57,6 @@ public static ActionCheck contentChecks(
return contentChecks("", isRelevantForRoleName, matchedExchangeUuid, httpMessageType, standardsVersion, checks);
}

@Deprecated
public static ActionCheck contentChecks(
String titlePrefix,
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
HttpMessageType httpMessageType,
List<JsonContentCheck> checks
) {
return contentChecks(titlePrefix, isRelevantForRoleName, matchedExchangeUuid, httpMessageType, null, checks);
}

public static ActionCheck contentChecks(
String titlePrefix,
Predicate<String> isRelevantForRoleName,
Expand Down Expand Up @@ -731,58 +678,6 @@ public static JsonContentMatchedValidation combineAndValidateAgainstDataset(
};
}


@Deprecated
public static JsonContentCheck ifThen(
@NonNull
String name,
@NonNull
Predicate<JsonNode> when,
@NonNull
JsonContentValidation then
) {
return new JsonContentCheckImpl(
name,
(body) -> {
if (when.test(body)) {
return then.validate(body);
}
return Set.of();
});
}

@Deprecated
public static JsonContentCheck ifThenElse(
@NonNull
String name,
@NonNull
Predicate<JsonNode> when,
@NonNull
JsonContentValidation then,
@NonNull
JsonContentValidation elseCheck
) {
return new JsonContentCheckImpl(
name,
(body) -> {
if (when.test(body)) {
return then.validate(body);
}
return elseCheck.validate(body);
});
}

public static JsonRebaseableContentCheck ifThen(
@NonNull
String name,
@NonNull
Predicate<JsonNode> when,
@NonNull
BiFunction<JsonNode, String, Set<String>> then
) {
return ifThenElse(name, when, then, EMPTY_VALIDATOR);
}

public static JsonRebaseableContentCheck ifThen(
@NonNull
String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@

public class EblIssuanceComponentFactory extends AbstractComponentFactory {
public static final String STANDARD_NAME = "eBL Issuance";
public static final List<String> STANDARD_VERSIONS = List.of(
"2.0.0-Beta-1",
"3.0.0-Beta-1",
"3.0.0-Beta-2"
);
public static final List<String> STANDARD_VERSIONS = List.of("2.0.0", "3.0.0");

private static final String CARRIER_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
private static final String PLATFORM_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
Expand Down Expand Up @@ -125,7 +121,7 @@ public JsonSchemaValidator getMessageSchemaValidator(String apiProviderRole, boo
.formatted(
standardVersion, apiProviderRole.toLowerCase());
String schemaName;
if (standardVersion.startsWith("2.") || standardVersion.equals("3.0.0-Beta-1")) {
if (standardVersion.startsWith("2.")) {
schemaName = EblIssuanceRole.isCarrier(apiProviderRole)
? (forRequest ? "issuanceRequest" : null)
: (forRequest ? "issuanceResponse" : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class IssuanceChecks {

private static JsonRebaseableContentCheck hasEndorseeScenarioCheck(String standardsVersion, EblType eblType) {
if (standardsVersion.startsWith("2.") || standardsVersion.equals("3.0.0-Beta-1")) {
if (standardsVersion.startsWith("2.")) {
return JsonAttribute.customValidator(
"[Scenario] Validate END party presence is correct",
JsonAttribute.path("document", JsonAttribute.path("documentParties",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void sendIssuanceRequest(JsonNode actionPrompt) {
if (eblType.isToOrder()) {
var td = (ObjectNode)jsonRequestBody.path("document");
td.put("isToOrder", true);
if (apiVersion.startsWith("2.") || apiVersion.equals("3.0.0-Beta-1")) {
if (apiVersion.startsWith("2.")) {
var documentParties = (ArrayNode)td.path("documentParties");
var cnIdx = -1;
for (int i = 0 ; i < documentParties.size() ; i++) {
Expand Down
Loading

0 comments on commit d4456f7

Please sign in to comment.