Skip to content

Commit

Permalink
DT-836 [2/?]: Add multiple container (UTE) scenarios
Browse files Browse the repository at this point in the history
Signed-off-by: Niels Thykier <[email protected]>
  • Loading branch information
nt-gt committed Jan 15, 2024
1 parent 86dbb45 commit 7fb5da4
Show file tree
Hide file tree
Showing 15 changed files with 587 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

public class JsonAttribute {

private static final JsonPointer ROOT_PTR = JsonPointer.compile("/");

public static ActionCheck contentChecks(
Predicate<String> isRelevantForRoleName,
UUID matchedExchangeUuid,
Expand Down Expand Up @@ -566,7 +564,7 @@ public static JsonContentCheck customValidator(
@NonNull String description,
@NonNull JsonContentMatchedValidation validator
) {
return JsonContentCheckImpl.of(description, ROOT_PTR, validator);
return JsonContentCheckImpl.of(description, atRoot(validator));
}

private static Function<JsonNode, JsonNode> at(JsonPointer jsonPointer) {
Expand All @@ -589,6 +587,10 @@ private static Function<JsonNode, Set<String>> atMatched(JsonPointer jsonPointer
return (refNode) -> validator.validate(refNode.at(jsonPointer), renderJsonPointer(jsonPointer));
}

private static Function<JsonNode, Set<String>> atRoot(JsonContentMatchedValidation validator) {
return (refNode) -> validator.validate(refNode, "");
}

static String renderValue(JsonNode node) {
if (node == null || node.isMissingNode()) {
return "(absent)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public static JsonNode templateFileToJsonNode(
String templatePath, Map<String, String> replacements) {
AtomicReference<String> jsonString = new AtomicReference<>();
try (InputStream inputStream = JsonToolkit.class.getResourceAsStream(templatePath)) {
if (inputStream == null) {
throw new IllegalArgumentException("Could not resolve " + templatePath);
}
jsonString.set(
new String(Objects.requireNonNull(inputStream).readAllBytes(), StandardCharsets.UTF_8));
new String(inputStream.readAllBytes(), StandardCharsets.UTF_8));
}
replacements.forEach((key, value) -> jsonString.set(jsonString.get().replaceAll(key, value)));
return OBJECT_MAPPER.readTree(jsonString.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public static EblScenarioListBuilder buildTree(
carrier_SupplyScenarioParameters(ScenarioType.REGULAR_SWB).thenAllPathsFrom(SI_START, TD_START, false),
carrier_SupplyScenarioParameters(ScenarioType.REGULAR_BOL).thenHappyPathFrom(SI_START, TD_START, false),
carrier_SupplyScenarioParameters(ScenarioType.REEFER).thenHappyPathFrom(SI_START, TD_START, false),
carrier_SupplyScenarioParameters(ScenarioType.DG).thenHappyPathFrom(SI_START, TD_START, false)
carrier_SupplyScenarioParameters(ScenarioType.DG).thenHappyPathFrom(SI_START, TD_START, false),
carrier_SupplyScenarioParameters(ScenarioType.REGULAR_2C_2U_1E).thenHappyPathFrom(SI_START, TD_START, false),
carrier_SupplyScenarioParameters(ScenarioType.REGULAR_2C_2U_2E).thenHappyPathFrom(SI_START, TD_START, false)
);
}

Expand Down Expand Up @@ -649,8 +651,8 @@ private static JsonSchemaValidator resolveMessageSchemaValidator(String apiName,
if (schemaValidator != null) {
return schemaValidator;
}
String schemaFilePath = "/standards/ebl/schemas/ebl-%s-v%s0.json"
.formatted(apiName, standardVersion.charAt(0));
String schemaFilePath = "/standards/ebl/schemas/ebl-%s-%s.json"
.formatted(apiName, standardVersion.toLowerCase());

schemaValidator = JsonSchemaValidator.getInstance(schemaFilePath, schema);
SCHEMA_CACHE.put(schemaKey, schemaValidator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,78 @@ public JsonNode getJsonForHumanReadablePrompt() {
case REGULAR_SWB, REGULAR_BOL -> new CarrierScenarioParameters(
"Booking Reference",
"Commodity subreference for regular (non-DG, non-reefer) cargo",
null,
// Any valid regular equipment reference will do as an example.
"NARU3472484",
null,
"DKAAR",
"640510",
null,
"Shoes - black, 400 boxes",
null,
"ServiceContractReference-1234",
"QuotationReference-1234"
);
case REEFER -> new CarrierScenarioParameters(
"Booking Reference",
"Commodity subreference for cargo requiring an *active* reefer",
null,
// Any valid reefer equipment reference will do as an example.
"KKFU6671914",
null,
"DKAAR",
"04052090",
null,
"Dairy products",
null,
"ServiceContractReference-1234AR",
"QuotationReference-1234AR"
);
case DG -> new CarrierScenarioParameters(
"Booking Reference",
"Commodity subreference for dangerous goods cargo",
null,
// Any valid regular equipment reference will do as an example.
"NARU3472484",
null,
"DKAAR",
"293499",
null,
"Environmentally hazardous substance, liquid, N.O.S (Propiconazole)",
null,
"ServiceContractReference-1234DG",
"QuotationReference-1234DG"
);
case REGULAR_2C_2U_1E -> new CarrierScenarioParameters(
"Booking Reference",
"Commodity Subreference for regular cargo 1",
"Commodity Subreference for regular cargo 2",
// Any valid reefer equipment reference will do as an example.
"MSKU3963442",
"MSKU7895860",
"DKAAR",
"691110",
"732391",
"Tableware and kitchenware",
"Kitchen pots and pans",
"SCR-1234-RG2C2U1E",
"QR-1234-RG2C2U1E"
);
case REGULAR_2C_2U_2E -> new CarrierScenarioParameters(
"Booking Reference",
"Commodity Subreference for regular cargo 1",
"Commodity Subreference for regular cargo 2",
// Any valid reefer equipment reference will do as an example.
"MSKU3963442",
"MSKU7895860",
"DKAAR",
"691110",
"732391",
"Tableware and kitchenware",
"Kitchen pots and pans",
"SCR-1234-RG2C2U2E",
"QR-1234-RG2C2U2E"
);
};
return csp.toJson();
}
Expand Down
Loading

0 comments on commit 7fb5da4

Please sign in to comment.