Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-909: More unsigned error scenarios for PINT #81

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ public static LinkedHashMap<String, PintScenarioListBuilder> createModuleScenari
retryTransfer(PintResponseCode.RECE)
)
),
resetScenarioClass(ScenarioClass.FAIL_W_503).then(
transferDocumentReceiverFailure().then(
resetScenarioClass(ScenarioClass.NO_ISSUES).thenEither(
transferDocument().then(closeTransferAction(PintResponseCode.RECE)),
retryTransfer(1).then(
transferDocument().thenEither(
closeTransferAction(PintResponseCode.RECE),
retryTransfer(PintResponseCode.RECE)
)
)
)
)
),
transferDocument(SenderDocumentTransmissionTypeCode.CORRUPTED_DOCUMENT).then(
retryTransfer(1).then(transferDocument().then(closeTransferAction(PintResponseCode.RECE)))
),
Expand Down Expand Up @@ -192,6 +205,19 @@ private static PintScenarioListBuilder transferDocument(SenderDocumentTransmissi
));
}


private static PintScenarioListBuilder transferDocumentReceiverFailure() {
String sendingPlatform = SENDING_PLATFORM_PARTY_NAME.get();
String receivingPlatform = RECEIVING_PLATFORM_PARTY_NAME.get();
return new PintScenarioListBuilder(
previousAction -> new PintTransferAdditionalDocumentFailureAction(
receivingPlatform,
sendingPlatform,
(PintAction) previousAction,
503
));
}

private static PintScenarioListBuilder noAction() {
return new PintScenarioListBuilder(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.dcsa.conformance.standards.eblinterop.action;

import static org.dcsa.conformance.standards.eblinterop.checks.PintChecks.*;

import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.function.Supplier;
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.checks.AdditionalDocumentUrlPathAndContentCheck;
import org.dcsa.conformance.standards.eblinterop.models.DynamicScenarioParameters;
import org.dcsa.conformance.standards.eblinterop.party.PintRole;

@Getter
@Slf4j
public class PintTransferAdditionalDocumentFailureAction extends PintAction {

public PintTransferAdditionalDocumentFailureAction(
String receivingPlatform,
String sendingPlatform,
PintAction previousAction,
int expectedStatus
) {
super(
sendingPlatform,
receivingPlatform,
previousAction,
"TransferAdditionalDocument(%d)".formatted(expectedStatus),
expectedStatus
);
}

@Override
public String getHumanReadablePrompt() {
return ("Send transfer-transaction request");
}

@Override
public ObjectNode asJsonNode() {
var node = super.asJsonNode();
node.put("senderDocumentTransmissionTypeCode", SenderDocumentTransmissionTypeCode.VALID_DOCUMENT.name());
node.set("rsp", getRsp().toJson());
node.set("ssp", getSsp().toJson());
node.set("dsp", getDsp().toJson());
return node;
}

@Override
public ConformanceCheck createCheck(String expectedApiVersion) {
return new ConformanceCheck(getActionTitle()) {
@Override
protected Stream<? extends ConformanceCheck> createSubChecks() {
Supplier<DynamicScenarioParameters> dspSupplier = () -> getDsp();
return Stream.of(
new AdditionalDocumentUrlPathAndContentCheck(
PintRole::isSendingPlatform,
getMatchedExchangeUuid(),
delayedValue(dspSupplier, DynamicScenarioParameters::envelopeReference)),
new ResponseStatusCheck(
PintRole::isReceivingPlatform, getMatchedExchangeUuid(), expectedStatus),
new ApiHeaderCheck(
PintRole::isSendingPlatform,
getMatchedExchangeUuid(),
HttpMessageType.REQUEST,
expectedApiVersion)
);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ public ConformanceResponse handleEnvelopeRequest(ConformanceRequest request) {
var tdr = this.envelopeReferences.get(envelopeReference);
if (tdr != null) {
var receiveState = TDReceiveState.fromPersistentStore(persistentMap, tdr);
var cannedResponse = receiveState.cannedResponse(request);
if (cannedResponse != null) {
return cannedResponse;
}

String computedChecksum = "";
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected Map<Class<? extends ConformanceAction>, Consumer<JsonNode>> getActionP
Map.entry(PintInitiateTransferUnsignedErrorAction.class, this::initiateTransferRequest),
Map.entry(ManipulateTransactionsAction.class, this::manipulateTransactions),
Map.entry(PintTransferAdditionalDocumentAction.class, this::transferActionDocument),
Map.entry(PintTransferAdditionalDocumentFailureAction.class, this::transferActionDocument),
Map.entry(PintRetryTransferAction.class, this::retryTransfer),
Map.entry(PintRetryTransferAndCloseAction.class, this::retryTransfer),
Map.entry(PintCloseTransferAction.class, this::finishTransfer)
Expand Down
Loading