-
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.
DT-271: Add scenario for receiver validation
- Loading branch information
Showing
7 changed files
with
206 additions
and
11 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
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
77 changes: 77 additions & 0 deletions
77
...n/java/org/dcsa/conformance/standards/eblinterop/action/PintReceiverValidationAction.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,77 @@ | ||
package org.dcsa.conformance.standards.eblinterop.action; | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import java.util.stream.Stream; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.dcsa.conformance.core.check.*; | ||
import org.dcsa.conformance.core.traffic.HttpMessageType; | ||
import org.dcsa.conformance.standards.eblinterop.party.PintRole; | ||
|
||
@Getter | ||
@Slf4j | ||
public class PintReceiverValidationAction extends PintAction { | ||
private final JsonSchemaValidator responseSchemaValidator; | ||
|
||
public PintReceiverValidationAction( | ||
String sourcePartyName, | ||
String targetPartyName, | ||
PintAction previousAction, | ||
int responseCode, | ||
JsonSchemaValidator responseSchemaValidator | ||
) { | ||
super( | ||
sourcePartyName, | ||
targetPartyName, | ||
previousAction, | ||
"ReceiverValidation(%d)".formatted(responseCode), | ||
responseCode | ||
); | ||
this.responseSchemaValidator = responseSchemaValidator; | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("Request receiver validation for: " + getDsp().receiverValidation().toString()); | ||
} | ||
|
||
@Override | ||
public ObjectNode asJsonNode() { | ||
var node = super.asJsonNode(); | ||
node.set("dsp", getDsp().toJson()); | ||
return node; | ||
} | ||
|
||
@Override | ||
public ConformanceCheck createCheck(String expectedApiVersion) { | ||
return new ConformanceCheck(getActionTitle()) { | ||
@Override | ||
protected Stream<? extends ConformanceCheck> createSubChecks() { | ||
|
||
return Stream.of( | ||
new HttpMethodCheck(PintRole::isSendingPlatform, getMatchedExchangeUuid(), "POST"), | ||
new UrlPathCheck( | ||
PintRole::isSendingPlatform, getMatchedExchangeUuid(), "/receiver-validation"), | ||
new ResponseStatusCheck( | ||
PintRole::isReceivingPlatform, getMatchedExchangeUuid(), expectedStatus), | ||
new ApiHeaderCheck( | ||
PintRole::isSendingPlatform, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.REQUEST, | ||
expectedApiVersion), | ||
new ApiHeaderCheck( | ||
PintRole::isReceivingPlatform, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
expectedApiVersion), | ||
new JsonSchemaCheck( | ||
PintRole::isReceivingPlatform, | ||
getMatchedExchangeUuid(), | ||
HttpMessageType.RESPONSE, | ||
responseSchemaValidator | ||
) | ||
); | ||
} | ||
}; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...ormance/standards/eblinterop/action/SupplyValidationEndpointScenarioParametersAction.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,55 @@ | ||
package org.dcsa.conformance.standards.eblinterop.action; | ||
|
||
import static org.dcsa.conformance.core.toolkit.JsonToolkit.OBJECT_MAPPER; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Getter | ||
@Slf4j | ||
public class SupplyValidationEndpointScenarioParametersAction extends PintAction { | ||
|
||
public SupplyValidationEndpointScenarioParametersAction( | ||
String platformPartyName, | ||
String carrierPartyName, | ||
PintAction previousAction) { | ||
super( | ||
carrierPartyName, | ||
platformPartyName, | ||
previousAction, | ||
"SupplyValidationEndpointScenarioParameters", | ||
-1); | ||
} | ||
|
||
@Override | ||
public boolean isInputRequired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void handlePartyInput(JsonNode partyInput) { | ||
super.handlePartyInput(partyInput); | ||
setDsp(getDsp().withReceiverValidation(partyInput)); | ||
} | ||
|
||
public static ObjectNode getJsonForPrompt() { | ||
var partyDef = OBJECT_MAPPER.createObjectNode(); | ||
partyDef.put("codeListProvider", "ZZZ") | ||
.put("partyCode", "valid-party") | ||
.put("codeListName", "CTK"); | ||
return partyDef; | ||
} | ||
|
||
@Override | ||
public JsonNode getJsonForHumanReadablePrompt() { | ||
return getJsonForPrompt(); | ||
} | ||
|
||
@Override | ||
public String getHumanReadablePrompt() { | ||
return ("Provide parameters for the receiver validation endpoint"); | ||
} | ||
|
||
} |
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