-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SD-1895 Add JIT 2.0 GET actions (#266)
* Relates to SD-160 which adds JIT 2.0
- Loading branch information
Showing
18 changed files
with
1,114 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
498 changes: 413 additions & 85 deletions
498
jit/src/main/java/org/dcsa/conformance/standards/jit/JitScenarioListBuilder.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
jit/src/main/java/org/dcsa/conformance/standards/jit/action/JitGetAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package org.dcsa.conformance.standards.jit.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.dcsa.conformance.core.check.ActionCheck; | ||
import org.dcsa.conformance.core.check.ApiHeaderCheck; | ||
import org.dcsa.conformance.core.check.ConformanceCheck; | ||
import org.dcsa.conformance.core.check.HttpMethodCheck; | ||
import org.dcsa.conformance.core.check.JsonSchemaCheck; | ||
import org.dcsa.conformance.core.check.JsonSchemaValidator; | ||
import org.dcsa.conformance.core.check.ResponseStatusCheck; | ||
import org.dcsa.conformance.core.check.UrlPathCheck; | ||
import org.dcsa.conformance.core.scenario.ConformanceAction; | ||
import org.dcsa.conformance.core.traffic.HttpMessageType; | ||
import org.dcsa.conformance.standards.jit.JitScenarioContext; | ||
import org.dcsa.conformance.standards.jit.JitStandard; | ||
import org.dcsa.conformance.standards.jit.checks.JitChecks; | ||
import org.dcsa.conformance.standards.jit.model.JitGetType; | ||
import org.dcsa.conformance.standards.jit.party.JitRole; | ||
|
||
@Slf4j | ||
public class JitGetAction extends JitAction { | ||
public static final String GET_TYPE = "getType"; | ||
public static final String FILTERS = "filters"; | ||
|
||
private final JitGetType getType; | ||
private final JsonSchemaValidator validator; | ||
private final boolean requestedByProvider; | ||
private final List<String> urlFilters; | ||
|
||
public JitGetAction( | ||
JitScenarioContext context, | ||
ConformanceAction previousAction, | ||
JitGetType getType, | ||
List<String> urlFilters, | ||
boolean requestedByProvider) { | ||
super( | ||
requestedByProvider ? context.providerPartyName() : context.consumerPartyName(), | ||
requestedByProvider ? context.consumerPartyName() : context.providerPartyName(), | ||
previousAction, | ||
requestedByProvider | ||
? "Send GET %s by %s".formatted(getType.getName(), urlFilters) | ||
: "Receive GET %s by %s".formatted(getType.getName(), urlFilters)); | ||
this.getType = getType; | ||
this.urlFilters = urlFilters; | ||
this.requestedByProvider = requestedByProvider; | ||
validator = context.componentFactory().getMessageSchemaValidator(getType.getJitSchema()); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
ObjectNode jsonNode = super.asJsonNode(); | ||
jsonNode.put(GET_TYPE, getType.name()); | ||
jsonNode.putPOJO(FILTERS, urlFilters); | ||
return jsonNode; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return "Get %s (GET) request".formatted(getType); | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
if (dsp == null) return Stream.of(); | ||
ActionCheck checksForTimestamp = | ||
JitChecks.createChecksForTimestamp( | ||
JitRole::isProvider, getMatchedExchangeUuid(), expectedApiVersion, dsp); | ||
if (requestedByProvider) { | ||
return Stream.of( | ||
new UrlPathCheck(JitRole::isProvider, getMatchedExchangeUuid(), getType.getUrlPath()), | ||
new HttpMethodCheck(JitRole::isProvider, getMatchedExchangeUuid(), JitStandard.GET), | ||
new ResponseStatusCheck(JitRole::isConsumer, getMatchedExchangeUuid(), 200), | ||
new ApiHeaderCheck( | ||
JitRole::isProvider, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
JitRole::isConsumer, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
new JsonSchemaCheck( | ||
JitRole::isConsumer, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
validator), | ||
checksForTimestamp); | ||
} | ||
// Consumer sends request | ||
return Stream.of( | ||
new UrlPathCheck(JitRole::isConsumer, getMatchedExchangeUuid(), getType.getUrlPath()), | ||
new HttpMethodCheck(JitRole::isConsumer, getMatchedExchangeUuid(), JitStandard.GET), | ||
new ResponseStatusCheck(JitRole::isProvider, getMatchedExchangeUuid(), 200), | ||
new ApiHeaderCheck( | ||
JitRole::isConsumer, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
JitRole::isProvider, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
new JsonSchemaCheck( | ||
JitRole::isProvider, getMatchedExchangeUuid(), HttpMessageType.RESPONSE, validator), | ||
checksForTimestamp); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
jit/src/main/java/org/dcsa/conformance/standards/jit/model/JitGetPortCallFilters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.dcsa.conformance.standards.jit.model; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public record JitGetPortCallFilters( | ||
String portCallID, | ||
String portVisitReference, | ||
String UNLocationCode, | ||
String vesselIMONumber, | ||
String vesselName, | ||
String MMSINumber) { | ||
|
||
public static List<String> props() { | ||
return Arrays.stream(JitGetPortCallFilters.class.getDeclaredFields()) | ||
.map(Field::getName) | ||
.toList(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
jit/src/main/java/org/dcsa/conformance/standards/jit/model/JitGetPortServiceCallFilters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.dcsa.conformance.standards.jit.model; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public record JitGetPortServiceCallFilters( | ||
String terminalCallID, String portCallServiceID, String portCallServiceType) { | ||
|
||
public static List<String> props() { | ||
return Arrays.stream(JitGetPortServiceCallFilters.class.getDeclaredFields()) | ||
.map(Field::getName) | ||
.toList(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
jit/src/main/java/org/dcsa/conformance/standards/jit/model/JitGetTerminalCallFilters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.dcsa.conformance.standards.jit.model; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public record JitGetTerminalCallFilters( | ||
String portCallID, | ||
String terminalCallID, | ||
String carrierServiceName, | ||
String carrierServiceCode, | ||
String universalServiceReference, | ||
String terminalCallReference, | ||
String carrierImportVoyageNumber, | ||
String carrierExportVoyageNumber, | ||
String universalImportVoyageReference, | ||
String universalExportVoyageReference) { | ||
|
||
public static List<String> props() { | ||
return Arrays.stream(JitGetTerminalCallFilters.class.getDeclaredFields()) | ||
.map(Field::getName) | ||
.toList(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
jit/src/main/java/org/dcsa/conformance/standards/jit/model/JitGetTimestampCallFilters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.dcsa.conformance.standards.jit.model; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public record JitGetTimestampCallFilters( | ||
String timestampID_Estimated, | ||
String timestampID_Requested, | ||
String timestampID_Planned, | ||
String timestampID_Actual, | ||
String portCallServiceID, | ||
String classifierCode) { | ||
|
||
public static List<String> props() { | ||
return Arrays.stream(JitGetTimestampCallFilters.class.getDeclaredFields()) | ||
.map(Field::getName) | ||
.toList(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
jit/src/main/java/org/dcsa/conformance/standards/jit/model/JitGetType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.dcsa.conformance.standards.jit.model; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.dcsa.conformance.standards.jit.JitStandard; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum JitGetType { | ||
PORT_CALLS( | ||
"Port Calls", | ||
JitSchema.PORT_CALLS, | ||
JitStandard.PORT_CALL_URL.substring(0, JitStandard.PORT_CALL_URL.length() - 1)), | ||
TERMINAL_CALLS( | ||
"Terminal Calls", | ||
JitSchema.TERMINAL_CALLS, | ||
JitStandard.TERMINAL_CALL_URL.substring(0, JitStandard.TERMINAL_CALL_URL.length() - 1)), | ||
PORT_CALL_SERVICES( | ||
"Port Call Services", | ||
JitSchema.PORT_CALL_SERVICES, | ||
JitStandard.PORT_CALL_SERVICES_URL.substring( | ||
0, JitStandard.PORT_CALL_SERVICES_URL.length() - 1)), | ||
TIMESTAMPS( | ||
"Timestamps", | ||
JitSchema.TIMESTAMPS, | ||
JitStandard.TIMESTAMP_URL.substring(0, JitStandard.TIMESTAMP_URL.length() - 1)), | ||
VESSEL_STATUSES( | ||
"Vessel Statuses", | ||
JitSchema.VESSEL_STATUSES, | ||
JitStandard.VESSEL_STATUS_URL.substring(0, JitStandard.VESSEL_STATUS_URL.length() - 1)); | ||
|
||
private final String name; | ||
private final JitSchema jitSchema; | ||
private final String urlPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.