From 25fda8c85eba569cb9be6137b331e1d88081a3f2 Mon Sep 17 00:00:00 2001 From: SangeethaPalat Date: Mon, 23 Sep 2024 14:21:55 +0200 Subject: [PATCH 1/2] APCV-1367 and APCV-1268- CS conformance incorrect prompt and Get action title update fixes --- .../standards/cs/CsScenarioListBuilder.java | 66 ++++++++++++++----- .../cs/action/CsGetPortSchedulesAction.java | 12 +++- .../cs/action/CsGetRoutingsAction.java | 9 ++- .../cs/action/CsGetVesselSchedulesAction.java | 9 ++- 4 files changed, 72 insertions(+), 24 deletions(-) diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java index bee602db..66070a02 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java @@ -135,42 +135,42 @@ public static LinkedHashMap createModuleScenarioL "Limit and Pagination", noAction() .thenEither( - scenarioWithParametersPtpForPagination(getPtpRoutings(),PLACE_OF_RECEIPT,PLACE_OF_DELIVERY,LIMIT), - scenarioWithParametersPsForPagination(getPortSchedules(),UN_LOCATION_CODE,DATE,LIMIT), - scenarioWithParametersVsForPagination(getVesselSchedules(),VESSEL_IMO_NUMBER,LIMIT)))) + scenarioWithParametersPtpForPagination(getPtpRoutings(true),PLACE_OF_RECEIPT,PLACE_OF_DELIVERY,LIMIT), + scenarioWithParametersPsForPagination(getPortSchedules(true),UN_LOCATION_CODE,DATE,LIMIT), + scenarioWithParametersVsForPagination(getVesselSchedules(true),VESSEL_IMO_NUMBER,LIMIT)))) .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); } private static CsScenarioListBuilder scenarioWithParametersPtpForPagination( - CsScenarioListBuilder thenWhat, CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings().then(thenWhat)); + CsScenarioListBuilder nextRoutingsAction, CsFilterParameter... csFilterParameters) { + return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings(true).then(nextRoutingsAction)); } private static CsScenarioListBuilder scenarioWithParametersPsForPagination( - CsScenarioListBuilder thenWhat, CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPortSchedules().then(thenWhat)); + CsScenarioListBuilder nextPortSchedulesAction, CsFilterParameter... csFilterParameters) { + return supplyScenarioParameters(csFilterParameters).then(getPortSchedules(true).then(nextPortSchedulesAction)); } private static CsScenarioListBuilder scenarioWithParametersVsForPagination( - CsScenarioListBuilder thenWhat, CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules().then(thenWhat)); + CsScenarioListBuilder nextVesselSchedulesAction, CsFilterParameter... csFilterParameters) { + return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules(true).then(nextVesselSchedulesAction)); } private static CsScenarioListBuilder scenarioWithParametersPtp( CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings()); + return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings(false)); } private static CsScenarioListBuilder scenarioWithParametersPs( CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPortSchedules()); + return supplyScenarioParameters(csFilterParameters).then(getPortSchedules(false)); } private static CsScenarioListBuilder scenarioWithParametersVs( CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules()); + return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules(false)); } private static CsScenarioListBuilder supplyScenarioParameters( @@ -185,7 +185,7 @@ private static CsScenarioListBuilder noAction() { return new CsScenarioListBuilder(null); } - private static CsScenarioListBuilder getVesselSchedules() { + private static CsScenarioListBuilder getVesselSchedules(boolean hasNextAction) { CsComponentFactory componentFactory = threadLocalComponentFactory.get(); String publisherPartyName = threadLocalPublisherPartyName.get(); String subscriberPartyName = threadLocalSubscriberPartyName.get(); @@ -195,10 +195,11 @@ private static CsScenarioListBuilder getVesselSchedules() { subscriberPartyName, publisherPartyName, (CsAction) previousAction, + getActionTitleVs(hasNextAction, (CsAction) previousAction), componentFactory.getMessageSchemaValidator("api", "serviceSchedules"))); } - private static CsScenarioListBuilder getPtpRoutings() { + private static CsScenarioListBuilder getPtpRoutings(boolean hasNextAction) { CsComponentFactory componentFactory = threadLocalComponentFactory.get(); String publisherPartyName = threadLocalPublisherPartyName.get(); String subscriberPartyName = threadLocalSubscriberPartyName.get(); @@ -208,10 +209,44 @@ private static CsScenarioListBuilder getPtpRoutings() { subscriberPartyName, publisherPartyName, (CsAction) previousAction, + getActionTitlePtp(hasNextAction, (CsAction) previousAction), componentFactory.getMessageSchemaValidator("api", "pointToPointRoutings"))); } - private static CsScenarioListBuilder getPortSchedules() { + private static String getActionTitlePs(boolean hasNextAction, CsAction previousAction) { + if (hasNextAction) { + if (previousAction instanceof CsGetPortSchedulesAction) { + return "GetPortSchedulesSecondPage"; + } else { + return "GetPortSchedulesFirstPage"; + } + } + return "GetPortSchedules"; + } + + private static String getActionTitleVs(boolean hasNextAction, CsAction previousAction) { + if (hasNextAction) { + if (previousAction instanceof CsGetVesselSchedulesAction) { + return "GetVesselSchedulesSecondPage"; + } else { + return "GetVesselSchedulesFirstPage"; + } + } + return "GetVesselSchedules"; + } + + private static String getActionTitlePtp(boolean hasNextAction, CsAction previousAction) { + if (hasNextAction) { + if (previousAction instanceof CsGetRoutingsAction) { + return "GetRoutingsSecondPage"; + } else { + return "GetRoutingsFirstPage"; + } + } + return "GetRoutings"; + } + + private static CsScenarioListBuilder getPortSchedules(boolean hasNextAction) { CsComponentFactory componentFactory = threadLocalComponentFactory.get(); String publisherPartyName = threadLocalPublisherPartyName.get(); String subscriberPartyName = threadLocalSubscriberPartyName.get(); @@ -221,6 +256,7 @@ private static CsScenarioListBuilder getPortSchedules() { subscriberPartyName, publisherPartyName, (CsAction) previousAction, + getActionTitlePs(hasNextAction, (CsAction) previousAction), componentFactory.getMessageSchemaValidator("api", "portSchedules"))); } } diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java index 811980fb..60561ee5 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java @@ -15,14 +15,20 @@ public CsGetPortSchedulesAction( String subscriberPartyName, String publisherPartyName, CsAction previousAction, + String actionTitle, JsonSchemaValidator responseSchemaValidator) { - super(subscriberPartyName, publisherPartyName, previousAction, "GetPortSchedules", 200); + + super(subscriberPartyName, publisherPartyName, previousAction, actionTitle + , 200); this.responseSchemaValidator = responseSchemaValidator; } + @Override public String getHumanReadablePrompt() { - return "Send a GET port schedules request with the following parameters: " - + sspSupplier.get().toJson().toPrettyString(); + return previousAction instanceof CsGetPortSchedulesAction + ? "Send a GET port schedules request to fetch the second results page, using the cursor retrieved from the headers of the response of the first GET request." + : "Send a GET port schedules request with the following parameters: " + + sspSupplier.get().toJson().toPrettyString(); } @Override diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java index 43b2fcd0..61c4b373 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java @@ -15,8 +15,9 @@ public CsGetRoutingsAction( String subscriberPartyName, String publisherPartyName, CsAction previousAction, + String actionTitle, JsonSchemaValidator responseSchemaValidator1) { - super(subscriberPartyName, publisherPartyName, previousAction, "GetRoutings", 200); + super(subscriberPartyName, publisherPartyName, previousAction, actionTitle, 200); this.responseSchemaValidator = responseSchemaValidator1; } @@ -35,8 +36,10 @@ public ObjectNode asJsonNode() { @Override public String getHumanReadablePrompt() { - return "Send a GET point to point routings request with the following parameters: " - + sspSupplier.get().toJson().toPrettyString(); + return previousAction instanceof CsGetRoutingsAction + ? "Send a GET point to point routings request to fetch the second results page, using the cursor retrieved from the headers of the response of the first GET request." + : "Send a GET point to point routings request with the following parameters: " + + sspSupplier.get().toJson().toPrettyString(); } @Override diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java index 507e69b2..921e4f0e 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java @@ -19,15 +19,18 @@ public CsGetVesselSchedulesAction( String subscriberPartyName, String publisherPartyName, CsAction previousAction, + String actionTitle, JsonSchemaValidator responseSchemaValidator) { - super(subscriberPartyName, publisherPartyName, previousAction, "GetVesselSchedules", 200); + super(subscriberPartyName, publisherPartyName, previousAction, actionTitle, 200); this.responseSchemaValidator = responseSchemaValidator; } @Override public String getHumanReadablePrompt() { - return "Send a GET vessel schedules request with the following parameters: " - + sspSupplier.get().toJson().toPrettyString(); + return previousAction instanceof CsGetVesselSchedulesAction + ? "Send a GET vessel schedules request to fetch the second results page, using the cursor retrieved from the headers of the response of the first GET request." + : "Send a GET vessel schedules request with the following parameters: " + + sspSupplier.get().toJson().toPrettyString(); } @Override From f8146da096a4712934f0bf6166d966bb5bf364eb Mon Sep 17 00:00:00 2001 From: SangeethaPalat Date: Mon, 23 Sep 2024 18:12:44 +0200 Subject: [PATCH 2/2] APCV-1268-Updated the changes for action naming in pagination --- .../standards/cs/CsScenarioListBuilder.java | 60 ++++--------------- .../cs/action/CsGetPortSchedulesAction.java | 12 ++-- .../cs/action/CsGetRoutingsAction.java | 9 ++- .../cs/action/CsGetVesselSchedulesAction.java | 11 +++- 4 files changed, 35 insertions(+), 57 deletions(-) diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java index 66070a02..264c524c 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/CsScenarioListBuilder.java @@ -135,9 +135,9 @@ public static LinkedHashMap createModuleScenarioL "Limit and Pagination", noAction() .thenEither( - scenarioWithParametersPtpForPagination(getPtpRoutings(true),PLACE_OF_RECEIPT,PLACE_OF_DELIVERY,LIMIT), - scenarioWithParametersPsForPagination(getPortSchedules(true),UN_LOCATION_CODE,DATE,LIMIT), - scenarioWithParametersVsForPagination(getVesselSchedules(true),VESSEL_IMO_NUMBER,LIMIT)))) + scenarioWithParametersPtpForPagination(getPtpRoutings(),PLACE_OF_RECEIPT,PLACE_OF_DELIVERY,LIMIT), + scenarioWithParametersPsForPagination(getPortSchedules(),UN_LOCATION_CODE,DATE,LIMIT), + scenarioWithParametersVsForPagination(getVesselSchedules(),VESSEL_IMO_NUMBER,LIMIT)))) .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); @@ -145,32 +145,32 @@ public static LinkedHashMap createModuleScenarioL private static CsScenarioListBuilder scenarioWithParametersPtpForPagination( CsScenarioListBuilder nextRoutingsAction, CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings(true).then(nextRoutingsAction)); + return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings().then(nextRoutingsAction)); } private static CsScenarioListBuilder scenarioWithParametersPsForPagination( CsScenarioListBuilder nextPortSchedulesAction, CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPortSchedules(true).then(nextPortSchedulesAction)); + return supplyScenarioParameters(csFilterParameters).then(getPortSchedules().then(nextPortSchedulesAction)); } private static CsScenarioListBuilder scenarioWithParametersVsForPagination( CsScenarioListBuilder nextVesselSchedulesAction, CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules(true).then(nextVesselSchedulesAction)); + return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules().then(nextVesselSchedulesAction)); } private static CsScenarioListBuilder scenarioWithParametersPtp( CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings(false)); + return supplyScenarioParameters(csFilterParameters).then(getPtpRoutings()); } private static CsScenarioListBuilder scenarioWithParametersPs( CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getPortSchedules(false)); + return supplyScenarioParameters(csFilterParameters).then(getPortSchedules()); } private static CsScenarioListBuilder scenarioWithParametersVs( CsFilterParameter... csFilterParameters) { - return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules(false)); + return supplyScenarioParameters(csFilterParameters).then(getVesselSchedules()); } private static CsScenarioListBuilder supplyScenarioParameters( @@ -185,7 +185,7 @@ private static CsScenarioListBuilder noAction() { return new CsScenarioListBuilder(null); } - private static CsScenarioListBuilder getVesselSchedules(boolean hasNextAction) { + private static CsScenarioListBuilder getVesselSchedules() { CsComponentFactory componentFactory = threadLocalComponentFactory.get(); String publisherPartyName = threadLocalPublisherPartyName.get(); String subscriberPartyName = threadLocalSubscriberPartyName.get(); @@ -195,11 +195,10 @@ private static CsScenarioListBuilder getVesselSchedules(boolean hasNextAction) { subscriberPartyName, publisherPartyName, (CsAction) previousAction, - getActionTitleVs(hasNextAction, (CsAction) previousAction), componentFactory.getMessageSchemaValidator("api", "serviceSchedules"))); } - private static CsScenarioListBuilder getPtpRoutings(boolean hasNextAction) { + private static CsScenarioListBuilder getPtpRoutings() { CsComponentFactory componentFactory = threadLocalComponentFactory.get(); String publisherPartyName = threadLocalPublisherPartyName.get(); String subscriberPartyName = threadLocalSubscriberPartyName.get(); @@ -209,44 +208,10 @@ private static CsScenarioListBuilder getPtpRoutings(boolean hasNextAction) { subscriberPartyName, publisherPartyName, (CsAction) previousAction, - getActionTitlePtp(hasNextAction, (CsAction) previousAction), componentFactory.getMessageSchemaValidator("api", "pointToPointRoutings"))); } - private static String getActionTitlePs(boolean hasNextAction, CsAction previousAction) { - if (hasNextAction) { - if (previousAction instanceof CsGetPortSchedulesAction) { - return "GetPortSchedulesSecondPage"; - } else { - return "GetPortSchedulesFirstPage"; - } - } - return "GetPortSchedules"; - } - - private static String getActionTitleVs(boolean hasNextAction, CsAction previousAction) { - if (hasNextAction) { - if (previousAction instanceof CsGetVesselSchedulesAction) { - return "GetVesselSchedulesSecondPage"; - } else { - return "GetVesselSchedulesFirstPage"; - } - } - return "GetVesselSchedules"; - } - - private static String getActionTitlePtp(boolean hasNextAction, CsAction previousAction) { - if (hasNextAction) { - if (previousAction instanceof CsGetRoutingsAction) { - return "GetRoutingsSecondPage"; - } else { - return "GetRoutingsFirstPage"; - } - } - return "GetRoutings"; - } - - private static CsScenarioListBuilder getPortSchedules(boolean hasNextAction) { + private static CsScenarioListBuilder getPortSchedules() { CsComponentFactory componentFactory = threadLocalComponentFactory.get(); String publisherPartyName = threadLocalPublisherPartyName.get(); String subscriberPartyName = threadLocalSubscriberPartyName.get(); @@ -256,7 +221,6 @@ private static CsScenarioListBuilder getPortSchedules(boolean hasNextAction) { subscriberPartyName, publisherPartyName, (CsAction) previousAction, - getActionTitlePs(hasNextAction, (CsAction) previousAction), componentFactory.getMessageSchemaValidator("api", "portSchedules"))); } } diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java index 60561ee5..abd8724a 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetPortSchedulesAction.java @@ -15,11 +15,15 @@ public CsGetPortSchedulesAction( String subscriberPartyName, String publisherPartyName, CsAction previousAction, - String actionTitle, JsonSchemaValidator responseSchemaValidator) { - - super(subscriberPartyName, publisherPartyName, previousAction, actionTitle - , 200); + super( + subscriberPartyName, + publisherPartyName, + previousAction, + (previousAction instanceof CsGetPortSchedulesAction) + ? "GetPortSchedules (second page)" + : "GetPortSchedules", + 200); this.responseSchemaValidator = responseSchemaValidator; } diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java index 61c4b373..82b25fb6 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetRoutingsAction.java @@ -15,10 +15,13 @@ public CsGetRoutingsAction( String subscriberPartyName, String publisherPartyName, CsAction previousAction, - String actionTitle, JsonSchemaValidator responseSchemaValidator1) { - super(subscriberPartyName, publisherPartyName, previousAction, actionTitle, 200); - + super( + subscriberPartyName, + publisherPartyName, + previousAction, + (previousAction instanceof CsGetRoutingsAction) ? "GetRoutings (second page)" : "GetRoutings", + 200); this.responseSchemaValidator = responseSchemaValidator1; } diff --git a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java index 921e4f0e..3d99ef92 100644 --- a/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java +++ b/commercial-schedules/src/main/java/org/dcsa/conformance/standards/cs/action/CsGetVesselSchedulesAction.java @@ -19,12 +19,19 @@ public CsGetVesselSchedulesAction( String subscriberPartyName, String publisherPartyName, CsAction previousAction, - String actionTitle, JsonSchemaValidator responseSchemaValidator) { - super(subscriberPartyName, publisherPartyName, previousAction, actionTitle, 200); + super( + subscriberPartyName, + publisherPartyName, + previousAction, + (previousAction instanceof CsGetVesselSchedulesAction) + ? "GetVesselSchedules (second page)" + : "GetVesselSchedules", + 200); this.responseSchemaValidator = responseSchemaValidator; } + @Override public String getHumanReadablePrompt() { return previousAction instanceof CsGetVesselSchedulesAction