diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistration.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistration.java index eb5c648cf..0711d05b7 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistration.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistration.java @@ -153,9 +153,9 @@ public String openApiSpecification() throws UnableToReadOpenApiSpecificationExce DomainResponse handleOrders(DomainRequest request) { return handleMessageRequest( request, - receivedSubmissionId -> { + inboundReportId -> { Order orders = orderController.parseOrders(request); - sendOrderUseCase.convertAndSend(orders, receivedSubmissionId); + sendOrderUseCase.convertAndSend(orders, inboundReportId); return domainResponseHelper.constructOkResponse(new OrderResponse(orders)); }, "order"); @@ -164,9 +164,9 @@ DomainResponse handleOrders(DomainRequest request) { DomainResponse handleResults(DomainRequest request) { return handleMessageRequest( request, - receivedSubmissionId -> { + inboundReportId -> { Result results = resultController.parseResults(request); - sendResultUseCase.convertAndSend(results, receivedSubmissionId); + sendResultUseCase.convertAndSend(results, inboundReportId); return domainResponseHelper.constructOkResponse(new ResultResponse(results)); }, "results"); @@ -186,8 +186,7 @@ DomainResponse handleMetadata(DomainRequest request) { var metadata = metadataOptional.get(); Set messageIdsToLink = - partnerMetadataOrchestrator.findMessagesIdsToLink( - metadata.receivedSubmissionId()); + partnerMetadataOrchestrator.findMessagesIdsToLink(metadata.inboundReportId()); FhirMetadata responseObject = partnerMetadataConverter.extractPublicMetadataToOperationOutcome( @@ -223,12 +222,12 @@ protected DomainResponse handleMessageRequest( DomainRequest request, MessageRequestHandler requestHandler, String messageType) { - String receivedSubmissionId = getReceivedSubmissionId(request); + String inboundReportId = getInboundReportId(request); boolean markMetadataAsFailed = false; String errorMessage = ""; try { - return requestHandler.handle(receivedSubmissionId); + return requestHandler.handle(inboundReportId); } catch (FhirParseException e) { errorMessage = "Unable to parse " + messageType + " request"; logger.logError(errorMessage, e); @@ -243,7 +242,7 @@ protected DomainResponse handleMessageRequest( if (markMetadataAsFailed) { try { partnerMetadataOrchestrator.setMetadataStatusToFailed( - receivedSubmissionId, errorMessage); + inboundReportId, errorMessage); } catch (PartnerMetadataException innerE) { logger.logError("Unable to update metadata status", innerE); } @@ -251,13 +250,13 @@ protected DomainResponse handleMessageRequest( } } - protected String getReceivedSubmissionId(DomainRequest request) { - - String receivedSubmissionId = request.getHeaders().get("recordid"); - if (receivedSubmissionId == null || receivedSubmissionId.isEmpty()) { + protected String getInboundReportId(DomainRequest request) { + // recordid is the inbound report id + String inboundReportId = request.getHeaders().get("recordid"); + if (inboundReportId == null || inboundReportId.isEmpty()) { logger.logError("Missing required header or empty: RecordId"); return null; } - return receivedSubmissionId; + return inboundReportId; } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/RSEndpointClient.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/RSEndpointClient.java index 97d6f3862..d40391523 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/RSEndpointClient.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/RSEndpointClient.java @@ -13,9 +13,9 @@ public interface RSEndpointClient { String requestWatersEndpoint(String body, String bearerToken) throws ReportStreamEndpointClientException; - String requestHistoryEndpoint(String submissionId, String bearerToken) + String requestHistoryEndpoint(String outboundReportId, String bearerToken) throws ReportStreamEndpointClientException; - String requestDeliveryEndpoint(String reportId, String bearerToken) + String requestDeliveryEndpoint(String inboundReportId, String bearerToken) throws ReportStreamEndpointClientException; } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/MessageRequestHandler.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/MessageRequestHandler.java index 640c33ac0..5805ecd76 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/MessageRequestHandler.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/MessageRequestHandler.java @@ -12,10 +12,10 @@ public interface MessageRequestHandler { /** * Parses the request, converts and sends the message * - * @param receivedSubmissionId the ID for the submission returned from ReportStream + * @param inboundReportId the report id created by ReportStream and sent to us in the request * @return the response * @throws FhirParseException if there is an error parsing the FHIR data * @throws UnableToSendMessageException if there is an error sending the message */ - T handle(String receivedSubmissionId) throws FhirParseException, UnableToSendMessageException; + T handle(String inboundReportId) throws FhirParseException, UnableToSendMessageException; } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelper.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelper.java index 20983f086..91bc23a6e 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelper.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelper.java @@ -21,67 +21,66 @@ public static SendMessageHelper getInstance() { private SendMessageHelper() {} - public void savePartnerMetadataForReceivedMessage(PartnerMetadata partnerMetadata) { - if (partnerMetadata.receivedSubmissionId() == null) { + public void savePartnerMetadataForInboundMessage(PartnerMetadata partnerMetadata) { + if (partnerMetadata.inboundReportId() == null) { logger.logWarning( - "Received submissionId is null so not saving metadata for received message"); + "inboundReportId is null so not saving metadata for received message"); return; } try { - partnerMetadataOrchestrator.updateMetadataForReceivedMessage(partnerMetadata); + partnerMetadataOrchestrator.updateMetadataForInboundMessage(partnerMetadata); } catch (PartnerMetadataException e) { logger.logError( - "Unable to save metadata for receivedSubmissionId " - + partnerMetadata.receivedSubmissionId(), + "Unable to save metadata for inboundReportId " + + partnerMetadata.inboundReportId(), e); } } - public void saveSentMessageSubmissionId(String receivedSubmissionId, String sentSubmissionId) { - if (sentSubmissionId == null || receivedSubmissionId == null) { + public void saveOutboundReportId(String inboundReportId, String outboundReportId) { + if (outboundReportId == null || inboundReportId == null) { logger.logWarning( - "Received and/or sent submissionId is null so not saving metadata for sent result"); + "inboundReportId and/or outboundReportId is null so not saving metadata for sent result"); return; } try { - partnerMetadataOrchestrator.updateMetadataForSentMessage( - receivedSubmissionId, sentSubmissionId); + partnerMetadataOrchestrator.updateMetadataForOutboundMessage( + inboundReportId, outboundReportId); } catch (PartnerMetadataException e) { logger.logError( - "Unable to update metadata for received submissionId " - + receivedSubmissionId - + " and sent submissionId " - + sentSubmissionId, + "Unable to update metadata for inboundReportId " + + inboundReportId + + " and outboundReportId " + + outboundReportId, e); } } - public void linkMessage(String receivedSubmissionId) { - if (receivedSubmissionId == null) { - logger.logWarning("Received submissionId is null so not linking messages"); + public void linkMessage(String inboundReportId) { + if (inboundReportId == null) { + logger.logWarning("inboundReportId is null so not linking messages"); return; } try { Set messageIdsToLink = - partnerMetadataOrchestrator.findMessagesIdsToLink(receivedSubmissionId); + partnerMetadataOrchestrator.findMessagesIdsToLink(inboundReportId); if (messageIdsToLink == null || messageIdsToLink.isEmpty()) { return; } - // Add receivedSubmissionId to complete the list of messageIds to link - messageIdsToLink.add(receivedSubmissionId); + // Add inboundReportId to complete the list of messageIds to link + messageIdsToLink.add(inboundReportId); logger.logInfo( - "Found messages to link for receivedSubmissionId {}: {}", - receivedSubmissionId, + "Found messages to link for inboundReportId {}: {}", + inboundReportId, messageIdsToLink); partnerMetadataOrchestrator.linkMessages(messageIdsToLink); } catch (PartnerMetadataException | MessageLinkException e) { - logger.logError( - "Unable to link messages for received submissionId " + receivedSubmissionId, e); + logger.logError("Unable to link messages for inboundReportId " + inboundReportId, e); } } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageUseCase.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageUseCase.java index d44ecf2f5..64e2112c1 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageUseCase.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageUseCase.java @@ -8,6 +8,6 @@ */ public interface SendMessageUseCase { - void convertAndSend(final T message, final String submissionId) + void convertAndSend(final T message, final String inboundReportId) throws UnableToSendMessageException; } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadata.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadata.java index 14bbe2206..8396b6f0a 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadata.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadata.java @@ -6,16 +6,16 @@ /** * The partner-facing metadata. * - * @param receivedSubmissionId The received submission ID. - * @param sentSubmissionId The sent submission ID. + * @param inboundReportId The inbound report ID. + * @param outboundReportId The outbound report ID. * @param timeReceived The time the message was received. * @param timeDelivered The time the message was delivered. * @param hash The hash of the message. * @param deliveryStatus the status of the message based on an enum */ public record PartnerMetadata( - String receivedSubmissionId, - String sentSubmissionId, + String inboundReportId, + String outboundReportId, Instant timeReceived, Instant timeDelivered, String hash, @@ -36,7 +36,7 @@ public record PartnerMetadata( } public PartnerMetadata( - String receivedSubmissionId, + String inboundReportId, String hash, PartnerMetadataMessageType messageType, MessageHdDataType sendingApplicationDetails, @@ -45,7 +45,7 @@ public PartnerMetadata( MessageHdDataType receivingFacilityDetails, String placerOrderNumber) { this( - receivedSubmissionId, + inboundReportId, null, null, null, @@ -60,9 +60,9 @@ public PartnerMetadata( placerOrderNumber); } - public PartnerMetadata(String receivedSubmissionId, PartnerMetadataStatus deliveryStatus) { + public PartnerMetadata(String inboundReportId, PartnerMetadataStatus deliveryStatus) { this( - receivedSubmissionId, + inboundReportId, null, null, null, @@ -77,10 +77,10 @@ public PartnerMetadata(String receivedSubmissionId, PartnerMetadataStatus delive null); } - public PartnerMetadata withSentSubmissionId(String sentSubmissionId) { + public PartnerMetadata withOutboundReportId(String outboundReportId) { return new PartnerMetadata( - this.receivedSubmissionId, - sentSubmissionId, + this.inboundReportId, + outboundReportId, this.timeReceived, this.timeDelivered, this.hash, @@ -96,8 +96,8 @@ public PartnerMetadata withSentSubmissionId(String sentSubmissionId) { public PartnerMetadata withTimeReceived(Instant timeReceived) { return new PartnerMetadata( - this.receivedSubmissionId, - this.sentSubmissionId, + this.inboundReportId, + this.outboundReportId, timeReceived, this.timeDelivered, this.hash, @@ -113,8 +113,8 @@ public PartnerMetadata withTimeReceived(Instant timeReceived) { public PartnerMetadata withTimeDelivered(Instant timeDelivered) { return new PartnerMetadata( - this.receivedSubmissionId, - this.sentSubmissionId, + this.inboundReportId, + this.outboundReportId, this.timeReceived, timeDelivered, this.hash, @@ -130,8 +130,8 @@ public PartnerMetadata withTimeDelivered(Instant timeDelivered) { public PartnerMetadata withDeliveryStatus(PartnerMetadataStatus deliveryStatus) { return new PartnerMetadata( - this.receivedSubmissionId, - this.sentSubmissionId, + this.inboundReportId, + this.outboundReportId, this.timeReceived, this.timeDelivered, this.hash, @@ -147,8 +147,8 @@ public PartnerMetadata withDeliveryStatus(PartnerMetadataStatus deliveryStatus) public PartnerMetadata withFailureMessage(String failureMessage) { return new PartnerMetadata( - this.receivedSubmissionId, - this.sentSubmissionId, + this.inboundReportId, + this.outboundReportId, this.timeReceived, this.timeDelivered, this.hash, diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestrator.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestrator.java index 80dce9132..a70308ec7 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestrator.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestrator.java @@ -41,19 +41,19 @@ public static PartnerMetadataOrchestrator getInstance() { private PartnerMetadataOrchestrator() {} - public void updateMetadataForReceivedMessage(PartnerMetadata partnerMetadata) + public void updateMetadataForInboundMessage(PartnerMetadata partnerMetadata) throws PartnerMetadataException { logger.logInfo( - "Looking up sender name and timeReceived from RS delivery API for receivedSubmissionId: {}", - partnerMetadata.receivedSubmissionId()); + "Looking up sender name and timeReceived from RS delivery API for inboundReportId: {}", + partnerMetadata.inboundReportId()); Instant timeReceived; try { String bearerToken = rsclient.getRsToken(); String responseBody = rsclient.requestDeliveryEndpoint( - partnerMetadata.receivedSubmissionId(), bearerToken); + partnerMetadata.inboundReportId(), bearerToken); Map responseObject = formatter.convertJsonToObject(responseBody, new TypeReference<>() {}); @@ -77,11 +77,11 @@ public void updateMetadataForReceivedMessage(PartnerMetadata partnerMetadata) timeReceived = Instant.parse(timestamp); } catch (Exception e) { - // write the received submission ID so that the rest of the metadata flow works even if + // write the inbound report ID so that the rest of the metadata flow works even if // some data is missing logger.logWarning( "Unable to retrieve metadata from RS delivery API, but writing basic metadata entry anyway for received submission ID {}", - partnerMetadata.receivedSubmissionId()); + partnerMetadata.inboundReportId()); partnerMetadataStorage.saveMetadata(partnerMetadata); throw new PartnerMetadataException( @@ -93,47 +93,46 @@ public void updateMetadataForReceivedMessage(PartnerMetadata partnerMetadata) partnerMetadataStorage.saveMetadata(updatedPartnerMetadata); } - public void updateMetadataForSentMessage(String receivedSubmissionId, String sentSubmissionId) + public void updateMetadataForOutboundMessage(String inboundReportId, String outboundReportId) throws PartnerMetadataException { - if (sentSubmissionId == null) { + if (outboundReportId == null) { return; } Optional optionalPartnerMetadata = - partnerMetadataStorage.readMetadata(receivedSubmissionId); + partnerMetadataStorage.readMetadata(inboundReportId); if (optionalPartnerMetadata.isEmpty()) { - logger.logWarning( - "Metadata not found for receivedSubmissionId: {}", receivedSubmissionId); + logger.logWarning("Metadata not found for inboundReportId: {}", inboundReportId); return; } PartnerMetadata partnerMetadata = optionalPartnerMetadata.get(); - if (sentSubmissionId.equals(partnerMetadata.sentSubmissionId())) { + if (outboundReportId.equals(partnerMetadata.outboundReportId())) { return; } - logger.logInfo("Updating metadata with sentSubmissionId: {}", sentSubmissionId); - partnerMetadata = partnerMetadata.withSentSubmissionId(sentSubmissionId); + logger.logInfo("Updating metadata with outboundReportId: {}", outboundReportId); + partnerMetadata = partnerMetadata.withOutboundReportId(outboundReportId); partnerMetadataStorage.saveMetadata(partnerMetadata); } - public Optional getMetadata(String receivedSubmissionId) + public Optional getMetadata(String inboundReportId) throws PartnerMetadataException { Optional optionalPartnerMetadata = - partnerMetadataStorage.readMetadata(receivedSubmissionId); + partnerMetadataStorage.readMetadata(inboundReportId); if (optionalPartnerMetadata.isEmpty()) { - logger.logInfo("Metadata not found for receivedSubmissionId: {}", receivedSubmissionId); + logger.logInfo("Metadata not found for inboundReportId: {}", inboundReportId); return Optional.empty(); } PartnerMetadata partnerMetadata = optionalPartnerMetadata.get(); - var sentSubmissionId = partnerMetadata.sentSubmissionId(); - if (metadataIsStale(partnerMetadata) && sentSubmissionId != null) { + var outboundReportId = partnerMetadata.outboundReportId(); + if (metadataIsStale(partnerMetadata) && outboundReportId != null) { logger.logInfo( "Receiver name not found in metadata or delivery status still pending, looking up {} from RS history API", - sentSubmissionId); + outboundReportId); String rsStatus; String rsMessage = ""; @@ -141,7 +140,7 @@ public Optional getMetadata(String receivedSubmissionId) try { String bearerToken = rsclient.getRsToken(); String responseBody = - rsclient.requestHistoryEndpoint(sentSubmissionId, bearerToken); + rsclient.requestHistoryEndpoint(outboundReportId, bearerToken); var parsedResponseBody = getDataFromReportStream(responseBody); rsStatus = parsedResponseBody[0]; rsMessage = parsedResponseBody[1]; @@ -168,18 +167,18 @@ public Optional getMetadata(String receivedSubmissionId) return Optional.of(partnerMetadata); } - public void setMetadataStatusToFailed(String submissionId, String errorMessage) + public void setMetadataStatusToFailed(String inboundReportId, String errorMessage) throws PartnerMetadataException { - if (submissionId == null) { + if (inboundReportId == null) { return; } Optional optionalPartnerMetadata = - partnerMetadataStorage.readMetadata(submissionId); + partnerMetadataStorage.readMetadata(inboundReportId); PartnerMetadata partnerMetadata; if (optionalPartnerMetadata.isEmpty()) { // there wasn't any metadata given the submission ID, so make one with the status - partnerMetadata = new PartnerMetadata(submissionId, PartnerMetadataStatus.FAILED); + partnerMetadata = new PartnerMetadata(inboundReportId, PartnerMetadataStatus.FAILED); } else { partnerMetadata = optionalPartnerMetadata.get(); if (partnerMetadata.deliveryStatus().equals(PartnerMetadataStatus.FAILED)) { @@ -188,9 +187,9 @@ public void setMetadataStatusToFailed(String submissionId, String errorMessage) } logger.logInfo( - "Updating metadata delivery status {} with submissionId: {}", + "Updating metadata delivery status {} with inboundReportId: {}", PartnerMetadataStatus.FAILED, - submissionId); + inboundReportId); partnerMetadata = partnerMetadata .withDeliveryStatus(PartnerMetadataStatus.FAILED) @@ -206,7 +205,7 @@ public Map> getConsolidatedMetadata(String senderNam return metadataSet.stream() .collect( Collectors.toMap( - PartnerMetadata::receivedSubmissionId, + PartnerMetadata::inboundReportId, metadata -> { var status = String.valueOf(metadata.deliveryStatus()); var stale = metadataIsStale(metadata); @@ -221,10 +220,10 @@ public Map> getConsolidatedMetadata(String senderNam })); } - public Set findMessagesIdsToLink(String receivedSubmissionId) + public Set findMessagesIdsToLink(String inboundReportId) throws PartnerMetadataException { - return partnerMetadataStorage.readMetadataForMessageLinking(receivedSubmissionId); + return partnerMetadataStorage.readMetadataForMessageLinking(inboundReportId); } public void linkMessages(Set messageIds) throws MessageLinkException { diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataStorage.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataStorage.java index 5137a01f5..0edf5ff7e 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataStorage.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataStorage.java @@ -7,13 +7,13 @@ public interface PartnerMetadataStorage { /** - * This method will retrieve and return the metadata for the given submissionId, if it exists. + * This method will retrieve and return the metadata for the given inboundReportId, if it + * exists. * - * @param receivedSubmissionId The submission Id to read the metadata for. + * @param inboundReportId The inbound report id to read the metadata for. * @return The metadata, if it exists. Otherwise, an empty Optional. */ - Optional readMetadata(String receivedSubmissionId) - throws PartnerMetadataException; + Optional readMetadata(String inboundReportId) throws PartnerMetadataException; /** * This method will do "upserts". If the record doesn't exist, it is created. If the record @@ -31,5 +31,6 @@ Optional readMetadata(String receivedSubmissionId) */ Set readMetadataForSender(String sender) throws PartnerMetadataException; - Set readMetadataForMessageLinking(String submissionId) throws PartnerMetadataException; + Set readMetadataForMessageLinking(String inboundReportId) + throws PartnerMetadataException; } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java index f4ac4ba73..c2087c8a4 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCase.java @@ -28,14 +28,14 @@ public static SendOrderUseCase getInstance() { } @Override - public void convertAndSend(final Order order, String receivedSubmissionId) + public void convertAndSend(final Order order, String inboundReportId) throws UnableToSendMessageException { String hashedOrder = hashHelper.generateHash(order); PartnerMetadata partnerMetadata = new PartnerMetadata( - receivedSubmissionId, + inboundReportId, hashedOrder, PartnerMetadataMessageType.ORDER, order.getSendingApplicationDetails(), @@ -44,15 +44,15 @@ public void convertAndSend(final Order order, String receivedSubmissionId) order.getReceivingFacilityDetails(), order.getPlacerOrderNumber()); - sendMessageHelper.savePartnerMetadataForReceivedMessage(partnerMetadata); + sendMessageHelper.savePartnerMetadataForInboundMessage(partnerMetadata); transformationEngine.runRules(order); String outboundReportId = sender.send(order).orElse(null); logger.logInfo("Sent order reportId: {}", outboundReportId); - sendMessageHelper.linkMessage(receivedSubmissionId); + sendMessageHelper.linkMessage(inboundReportId); - sendMessageHelper.saveSentMessageSubmissionId(receivedSubmissionId, outboundReportId); + sendMessageHelper.saveOutboundReportId(inboundReportId, outboundReportId); } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java index b11dfdac8..d5fb989e0 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCase.java @@ -30,14 +30,14 @@ public static SendResultUseCase getInstance() { } @Override - public void convertAndSend(Result result, String receivedSubmissionId) + public void convertAndSend(Result result, String inboundReportId) throws UnableToSendMessageException { String hashedResult = hashHelper.generateHash(result); PartnerMetadata partnerMetadata = new PartnerMetadata( - receivedSubmissionId, + inboundReportId, hashedResult, PartnerMetadataMessageType.RESULT, result.getSendingApplicationDetails(), @@ -46,15 +46,15 @@ public void convertAndSend(Result result, String receivedSubmissionId) result.getReceivingFacilityDetails(), result.getPlacerOrderNumber()); - sendMessageHelper.savePartnerMetadataForReceivedMessage(partnerMetadata); + sendMessageHelper.savePartnerMetadataForInboundMessage(partnerMetadata); transformationEngine.runRules(result); String outboundReportId = sender.send(result).orElse(null); - logger.logInfo("Sent result reportId: {}", outboundReportId); + logger.logInfo("Sent result outboundReportId: {}", outboundReportId); - sendMessageHelper.linkMessage(receivedSubmissionId); + sendMessageHelper.linkMessage(inboundReportId); - sendMessageHelper.saveSentMessageSubmissionId(receivedSubmissionId, outboundReportId); + sendMessageHelper.saveOutboundReportId(inboundReportId, outboundReportId); } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorage.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorage.java index 08bfc8814..e9016ebc9 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorage.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorage.java @@ -27,8 +27,6 @@ public class DatabasePartnerMetadataStorage implements PartnerMetadataStorage { private static final DatabasePartnerMetadataStorage INSTANCE = new DatabasePartnerMetadataStorage(); - private static final String METADATA_TABLE_RECEIVED_MESSAGE_ID = "received_message_id"; - @Inject DbDao dao; @Inject Logger logger; @@ -73,7 +71,7 @@ public void saveMetadata(final PartnerMetadata metadata) throws PartnerMetadataE try { List columns = createDbColumnsFromMetadata(metadata); - dao.upsertData("metadata", columns, "(" + METADATA_TABLE_RECEIVED_MESSAGE_ID + ")"); + dao.upsertData("metadata", columns, "(received_message_id)"); } catch (SQLException e) { throw new PartnerMetadataException("Error saving metadata", e); } catch (FormatterProcessingException e) { @@ -110,7 +108,7 @@ public Set readMetadataForSender(String sender) } @Override - public Set readMetadataForMessageLinking(String submissionId) + public Set readMetadataForMessageLinking(String inboundReportId) throws PartnerMetadataException { Set metadataSet; @@ -133,7 +131,7 @@ public Set readMetadataForMessageLinking(String submissionId) """); // -- LIMIT 50 This is a potential fix for load test failures // since they link all the ids together; - statement.setString(1, submissionId); + statement.setString(1, inboundReportId); return statement; } catch (SQLException e) { throw new RuntimeException(e); @@ -163,7 +161,7 @@ PartnerMetadata partnerMetadataFromResultSet(ResultSet resultSet) { } return new PartnerMetadata( - resultSet.getString(METADATA_TABLE_RECEIVED_MESSAGE_ID), + resultSet.getString("received_message_id"), resultSet.getString("sent_message_id"), timeReceived, timeDelivered, @@ -192,7 +190,7 @@ PartnerMetadata partnerMetadataFromResultSet(ResultSet resultSet) { String idsFromResult(ResultSet resultSet) { try { - return resultSet.getString(METADATA_TABLE_RECEIVED_MESSAGE_ID); + return resultSet.getString("received_message_id"); } catch (SQLException e) { throw new RuntimeException(e); } @@ -202,11 +200,8 @@ private List createDbColumnsFromMetadata(PartnerMetadata metadata) throws FormatterProcessingException { return List.of( new DbColumn( - METADATA_TABLE_RECEIVED_MESSAGE_ID, - metadata.receivedSubmissionId(), - false, - Types.VARCHAR), - new DbColumn("sent_message_id", metadata.sentSubmissionId(), true, Types.VARCHAR), + "received_message_id", metadata.inboundReportId(), false, Types.VARCHAR), + new DbColumn("sent_message_id", metadata.outboundReportId(), true, Types.VARCHAR), new DbColumn("hash_of_message", metadata.hash(), false, Types.VARCHAR), new DbColumn( "time_received", diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiPartnerMetadataConverter.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiPartnerMetadataConverter.java index 49a8d0198..c0d8182c5 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiPartnerMetadataConverter.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiPartnerMetadataConverter.java @@ -76,13 +76,13 @@ public FhirMetadata extractPublicMetadataToOperationOutcome( .getIssue() .add( createInformationIssueComponent( - "outbound submission id", metadata.sentSubmissionId())); + "outbound submission id", metadata.outboundReportId())); operation .getIssue() .add( createInformationIssueComponent( - "inbound submission id", metadata.receivedSubmissionId())); + "inbound submission id", metadata.inboundReportId())); return new HapiFhirMetadata(operation); } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorage.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorage.java index de8a874b2..69a5818d4 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorage.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorage.java @@ -43,10 +43,10 @@ public static FilePartnerMetadataStorage getInstance() { } @Override - public Optional readMetadata(final String submissionId) + public Optional readMetadata(final String inboundReportId) throws PartnerMetadataException { try { - Path filePath = searchFilePath(submissionId); + Path filePath = searchFilePath(inboundReportId); if (filePath == null || !Files.exists(filePath)) { logger.logWarning("Metadata file not found: {}", filePath); return Optional.empty(); @@ -63,7 +63,7 @@ public Optional readMetadata(final String submissionId) @Override public void saveMetadata(final PartnerMetadata metadata) throws PartnerMetadataException { try { - Path previousMetadataFilePath = searchFilePath(metadata.receivedSubmissionId()); + Path previousMetadataFilePath = searchFilePath(metadata.inboundReportId()); if (previousMetadataFilePath != null) { // delete the pre-existing metadata file so that we don't find the old file when we // search for a given metadata ID @@ -71,22 +71,19 @@ public void saveMetadata(final PartnerMetadata metadata) throws PartnerMetadataE } } catch (IOException e) { throw new PartnerMetadataException( - "Error deleting previous metadata file for " + metadata.receivedSubmissionId(), - e); + "Error deleting previous metadata file for " + metadata.inboundReportId(), e); } Path metadataFilePath = - getFilePath(metadata.receivedSubmissionId() + "-" + metadata.sentSubmissionId()); + getFilePath(metadata.inboundReportId() + "-" + metadata.outboundReportId()); try { String content = formatter.convertToJsonString(metadata); Files.writeString(metadataFilePath, content); logger.logInfo( - "Saved metadata for {} to {}", - metadata.receivedSubmissionId(), - metadataFilePath); + "Saved metadata for {} to {}", metadata.inboundReportId(), metadataFilePath); } catch (IOException | FormatterProcessingException e) { throw new PartnerMetadataException( - "Error saving metadata for " + metadata.receivedSubmissionId(), e); + "Error saving metadata for " + metadata.inboundReportId(), e); } } @@ -108,23 +105,19 @@ public Set readMetadataForSender(String senderUniversalId) } @Override - public Set readMetadataForMessageLinking(String receivedSubmissionId) + public Set readMetadataForMessageLinking(String inboundReportId) throws PartnerMetadataException { try { Set existingMetadata = getPartnerMetadata(); PartnerMetadata match = existingMetadata.stream() - .filter( - metadata -> - metadata.receivedSubmissionId() - .equals(receivedSubmissionId)) + .filter(metadata -> metadata.inboundReportId().equals(inboundReportId)) .findFirst() .orElse(null); if (match == null) { logger.logWarning( - "Matching metadata not found for receivedSubmissionId: {}", - receivedSubmissionId); + "Matching metadata not found for inboundReportId: {}", inboundReportId); return Set.of(); } @@ -138,13 +131,12 @@ public Set readMetadataForMessageLinking(String receivedSubmissionId) .equals( match .receivingFacilityDetails())) - && !metadata.receivedSubmissionId() - .equals(receivedSubmissionId)) - .map(PartnerMetadata::receivedSubmissionId) + && !metadata.inboundReportId().equals(inboundReportId)) + .map(PartnerMetadata::inboundReportId) .collect(Collectors.toSet()); } catch (Exception e) { throw new PartnerMetadataException( - "Failed reading metadata for submissionId: " + receivedSubmissionId, e); + "Failed reading metadata for inboundReportId: " + inboundReportId, e); } } diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/MockRSEndpointClient.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/MockRSEndpointClient.java index 413a54a4d..fdbfe9d95 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/MockRSEndpointClient.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/localfile/MockRSEndpointClient.java @@ -50,7 +50,7 @@ public String requestWatersEndpoint(String body, String bearerToken) } @Override - public String requestHistoryEndpoint(String submissionId, String bearerToken) { + public String requestHistoryEndpoint(String outboundReportId, String bearerToken) { return """ { "timestamp" : "2020-01-01T00:00:00.000Z", @@ -70,7 +70,7 @@ public String requestHistoryEndpoint(String submissionId, String bearerToken) { } @Override - public String requestDeliveryEndpoint(String reportId, String bearerToken) + public String requestDeliveryEndpoint(String inboundReportId, String bearerToken) throws ReportStreamEndpointClientException { return """ { diff --git a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClient.java b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClient.java index a54702561..e8fec6f52 100644 --- a/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClient.java +++ b/etor/src/main/java/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClient.java @@ -109,14 +109,14 @@ public String requestWatersEndpoint(String body, String bearerToken) } @Override - public String requestHistoryEndpoint(String submissionId, String bearerToken) + public String requestHistoryEndpoint(String outboundReportId, String bearerToken) throws ReportStreamEndpointClientException { logger.logInfo("Requesting history API from ReportStream"); Map headers = Map.of("Authorization", "Bearer " + bearerToken); try { - String url = RS_HISTORY_API_URL.replace("{id}", submissionId); + String url = RS_HISTORY_API_URL.replace("{id}", outboundReportId); return client.get(url, headers); } catch (HttpClientException e) { throw new ReportStreamEndpointClientException( @@ -125,14 +125,14 @@ public String requestHistoryEndpoint(String submissionId, String bearerToken) } @Override - public String requestDeliveryEndpoint(String reportId, String bearerToken) + public String requestDeliveryEndpoint(String inboundReportId, String bearerToken) throws ReportStreamEndpointClientException { logger.logInfo("Requesting delivery API from ReportStream"); Map headers = Map.of("Authorization", "Bearer " + bearerToken); try { - String url = RS_DELIVERY_API_URL.replace("{id}", reportId); + String url = RS_DELIVERY_API_URL.replace("{id}", inboundReportId); return client.get(url, headers); } catch (HttpClientException e) { throw new ReportStreamEndpointClientException( diff --git a/etor/src/main/resources/openapi_etor.yaml b/etor/src/main/resources/openapi_etor.yaml index 76dbefe75..be158bf95 100644 --- a/etor/src/main/resources/openapi_etor.yaml +++ b/etor/src/main/resources/openapi_etor.yaml @@ -149,7 +149,7 @@ components: ConsolidatedMetadata: type: map> properties: - receivedSubmissionId: + inboundReportId: type: string properties: value: diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistrationTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistrationTest.groovy index 593fd5816..eaa665ab9 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistrationTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/EtorDomainRegistrationTest.groovy @@ -171,15 +171,15 @@ class EtorDomainRegistrationTest extends Specification { def "metadata endpoint happy path"() { given: def expectedStatusCode = 200 - def receivedSubmissionId = "receivedSubmissionId" - def metadata = new PartnerMetadata("receivedSubmissionId", "hash", PartnerMetadataMessageType.ORDER, sendingApp, sendingFacility, receivingApp, receivingFacility, "placer_order_number") - def linkedMessageIds = Set.of(receivedSubmissionId, "Test1", "Test2") + def inboundReportId = "inboundReportId" + def metadata = new PartnerMetadata("inboundReportId", "hash", PartnerMetadataMessageType.ORDER, sendingApp, sendingFacility, receivingApp, receivingFacility, "placer_order_number") + def linkedMessageIds = Set.of(inboundReportId, "Test1", "Test2") def connector = new EtorDomainRegistration() TestApplicationContext.register(EtorDomainRegistration, connector) def request = new DomainRequest() - request.setPathParams(["id": receivedSubmissionId]) + request.setPathParams(["id": inboundReportId]) def mockPartnerMetadataOrchestrator = Mock(PartnerMetadataOrchestrator) TestApplicationContext.register(PartnerMetadataOrchestrator, mockPartnerMetadataOrchestrator) @@ -202,8 +202,8 @@ class EtorDomainRegistrationTest extends Specification { then: actualStatusCode == expectedStatusCode - 1 * mockPartnerMetadataOrchestrator.getMetadata(receivedSubmissionId) >> Optional.ofNullable(metadata) - 1 * mockPartnerMetadataOrchestrator.findMessagesIdsToLink(receivedSubmissionId) >> linkedMessageIds + 1 * mockPartnerMetadataOrchestrator.getMetadata(inboundReportId) >> Optional.ofNullable(metadata) + 1 * mockPartnerMetadataOrchestrator.findMessagesIdsToLink(inboundReportId) >> linkedMessageIds 1 * mockPartnerMetadataConverter.extractPublicMetadataToOperationOutcome(_ as PartnerMetadata, _ as String, linkedMessageIds) >> Mock(FhirMetadata) 1 * mockResponseHelper.constructOkResponseFromString(_ as String) >> new DomainResponse(expectedStatusCode) } @@ -211,16 +211,16 @@ class EtorDomainRegistrationTest extends Specification { def "metadata endpoint returns metadata even when the submitted ID is different from ID used for linking"() { given: def expectedStatusCode = 200 - def receivedSubmissionId = "receivedSubmissionId" - def sentSubmissionId = "sentSubmissionId" - def metadata = new PartnerMetadata(receivedSubmissionId, "hash", PartnerMetadataMessageType.ORDER, sendingApp, sendingFacility, receivingApp, receivingFacility, "placer_order_number").withSentSubmissionId(sentSubmissionId) - def linkedMessageIds = Set.of(receivedSubmissionId, "Test1", "Test2") + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" + def metadata = new PartnerMetadata(inboundReportId, "hash", PartnerMetadataMessageType.ORDER, sendingApp, sendingFacility, receivingApp, receivingFacility, "placer_order_number").withOutboundReportId(outboundReportId) + def linkedMessageIds = Set.of(inboundReportId, "Test1", "Test2") def connector = new EtorDomainRegistration() TestApplicationContext.register(EtorDomainRegistration, connector) def request = new DomainRequest() - request.setPathParams(["id": sentSubmissionId]) + request.setPathParams(["id": outboundReportId]) def mockPartnerMetadataOrchestrator = Mock(PartnerMetadataOrchestrator) TestApplicationContext.register(PartnerMetadataOrchestrator, mockPartnerMetadataOrchestrator) @@ -243,8 +243,8 @@ class EtorDomainRegistrationTest extends Specification { then: actualStatusCode == expectedStatusCode - 1 * mockPartnerMetadataOrchestrator.getMetadata(sentSubmissionId) >> Optional.ofNullable(metadata) - 1 * mockPartnerMetadataOrchestrator.findMessagesIdsToLink(receivedSubmissionId) >> linkedMessageIds + 1 * mockPartnerMetadataOrchestrator.getMetadata(outboundReportId) >> Optional.ofNullable(metadata) + 1 * mockPartnerMetadataOrchestrator.findMessagesIdsToLink(inboundReportId) >> linkedMessageIds 1 * mockPartnerMetadataConverter.extractPublicMetadataToOperationOutcome(_ as PartnerMetadata, _ as String, linkedMessageIds) >> Mock(FhirMetadata) 1 * mockResponseHelper.constructOkResponseFromString(_ as String) >> new DomainResponse(expectedStatusCode) } @@ -430,7 +430,7 @@ class EtorDomainRegistrationTest extends Specification { 2 * mockLogger.logError(_ as String, _ as Exception) } - def "handleMessageRequest logs an error and continues when the receivedSubmissionId is missing or empty because we want to know when our integration with RS is broken"() { + def "handleMessageRequest logs an error and continues when the inboundReportId is missing or empty because we want to know when our integration with RS is broken"() { given: def connector = new EtorDomainRegistration() TestApplicationContext.register(EtorDomainRegistration, connector) diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelperTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelperTest.groovy index 08deb143d..b8d2bf95c 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelperTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/messages/SendMessageHelperTest.groovy @@ -27,7 +27,7 @@ class SendMessageHelperTest extends Specification { TestApplicationContext.register(Logger, mockLogger) TestApplicationContext.injectRegisteredImplementations() partnerMetadata = new PartnerMetadata( - "receivedId", + "inboundReportId", new Random().nextInt().toString(), PartnerMetadataMessageType.RESULT, sendingApp, @@ -36,15 +36,15 @@ class SendMessageHelperTest extends Specification { receivingFacility, placerOrderNumber) } - def "savePartnerMetadataForReceivedMessage works"() { + def "savePartnerMetadataForInboundMessage works"() { when: - SendMessageHelper.getInstance().savePartnerMetadataForReceivedMessage(partnerMetadata) + SendMessageHelper.getInstance().savePartnerMetadataForInboundMessage(partnerMetadata) then: - 1 * mockOrchestrator.updateMetadataForReceivedMessage(_) + 1 * mockOrchestrator.updateMetadataForInboundMessage(_) } - def "savePartnerMetadataForReceivedMessage should log warnings for null receivedSubmissionId"() { + def "savePartnerMetadataForInboundMessage should log warnings for null inboundReportId"() { when: PartnerMetadata warningPartnerMetadata = new PartnerMetadata( null, @@ -55,57 +55,57 @@ class SendMessageHelperTest extends Specification { receivingApp, receivingFacility, placerOrderNumber) - SendMessageHelper.getInstance().savePartnerMetadataForReceivedMessage(warningPartnerMetadata) + SendMessageHelper.getInstance().savePartnerMetadataForInboundMessage(warningPartnerMetadata) then: 1 * mockLogger.logWarning(_) } - def "savePartnerMetadataForReceivedMessage logs error and continues when updateMetadataForReceivedMessage throws error"() { + def "savePartnerMetadataForInboundMessage logs error and continues when updateMetadataForInboundMessage throws error"() { given: def hashCode = new Random().nextInt() def messageType = PartnerMetadataMessageType.RESULT - mockOrchestrator.updateMetadataForReceivedMessage(partnerMetadata) >> { throw new PartnerMetadataException("Error") } + mockOrchestrator.updateMetadataForInboundMessage(partnerMetadata) >> { throw new PartnerMetadataException("Error") } when: - SendMessageHelper.getInstance().savePartnerMetadataForReceivedMessage(partnerMetadata) + SendMessageHelper.getInstance().savePartnerMetadataForInboundMessage(partnerMetadata) then: 1 * mockLogger.logError(_, _) } - def "saveSentMessageSubmissionId works"() { + def "saveOutboundReportId works"() { given: - def sentSubmissionId = "sentId" - def receivedSubmissionId = "receivedId" - mockOrchestrator.updateMetadataForSentMessage(receivedSubmissionId, _ as String) >> { throw new PartnerMetadataException("Error") } + def outboundReportId = "outboundReportId" + def inboundReportId = "inboundReportId" + mockOrchestrator.updateMetadataForOutboundMessage(inboundReportId, _ as String) >> { throw new PartnerMetadataException("Error") } when: - SendMessageHelper.getInstance().saveSentMessageSubmissionId(receivedSubmissionId, sentSubmissionId) + SendMessageHelper.getInstance().saveOutboundReportId(inboundReportId, outboundReportId) then: - 1 * mockOrchestrator.updateMetadataForSentMessage(_, _) + 1 * mockOrchestrator.updateMetadataForOutboundMessage(_, _) } - def "saveSentMessageSubmissionId should log warnings for null receivedSubmissionId"() { + def saveOutboundReportId() { given: - def receivedSubmissionId = "receivedId" + def inboundReportId = "inboundReportId" when: - SendMessageHelper.getInstance().saveSentMessageSubmissionId(null, receivedSubmissionId) + SendMessageHelper.getInstance().saveOutboundReportId(null, inboundReportId) then: 1 * mockLogger.logWarning(_) } - def "saveSentMessageSubmissionId should log error and continues when updateMetadataForSentMessage throws error"() { + def "saveOutboundReportId should log error and continues when updateMetadataForOutboundMessage throws error"() { given: - def sentSubmissionId = "sentId" - def receivedSubmissionId = "receivedId" - mockOrchestrator.updateMetadataForSentMessage(receivedSubmissionId, _ as String) >> { throw new PartnerMetadataException("Error") } + def outboundReportId = "outboundReportId" + def inboundReportId = "inboundReportId" + mockOrchestrator.updateMetadataForOutboundMessage(inboundReportId, _ as String) >> { throw new PartnerMetadataException("Error") } when: - SendMessageHelper.getInstance().saveSentMessageSubmissionId(receivedSubmissionId, sentSubmissionId) + SendMessageHelper.getInstance().saveOutboundReportId(inboundReportId, outboundReportId) then: 1 * mockLogger.logError(_, _) diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestratorTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestratorTest.groovy index cd81b33fe..b2ed2d3de 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestratorTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataOrchestratorTest.groovy @@ -19,8 +19,8 @@ class PartnerMetadataOrchestratorTest extends Specification { def mockMessageLinkStorage def mockClient def mockFormatter - def receivedSubmissionId = "receivedSubmissionId" - def sentSubmissionId = "sentSubmissionId" + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" def hashCode = "hash" def bearerToken = "token" def placerOrderNumber = "placer_order_number" @@ -48,8 +48,8 @@ class PartnerMetadataOrchestratorTest extends Specification { receivingApp = new MessageHdDataType("receiving_app_name", "receiving_app_id", "receiving_app_type") receivingFacility = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") - testMetadata = new PartnerMetadata(receivedSubmissionId, - sentSubmissionId, + testMetadata = new PartnerMetadata(inboundReportId, + outboundReportId, timeReceived, timeDelivered, hashCode, @@ -73,7 +73,7 @@ class PartnerMetadataOrchestratorTest extends Specification { TestApplicationContext.injectRegisteredImplementations() } - def "updateMetadataForReceivedMessage updates metadata successfully"() { + def "updateMetadataForInboundMessage updates metadata successfully"() { given: TestApplicationContext.register(Formatter, Jackson.getInstance()) @@ -109,8 +109,8 @@ class PartnerMetadataOrchestratorTest extends Specification { """ def expectedMetadata = new PartnerMetadata( - receivedSubmissionId, - sentSubmissionId, + inboundReportId, + outboundReportId, Instant.parse(timestamp), timeDelivered, hashCode, @@ -125,41 +125,41 @@ class PartnerMetadataOrchestratorTest extends Specification { ) when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: 1 * mockClient.getRsToken() >> bearerToken - 1 * mockClient.requestDeliveryEndpoint(receivedSubmissionId, bearerToken) >> rsDeliveryApiResponse + 1 * mockClient.requestDeliveryEndpoint(inboundReportId, bearerToken) >> rsDeliveryApiResponse 1 * mockPartnerMetadataStorage.saveMetadata(expectedMetadata) } - def "updateMetadataForSentMessage test case when sentSubmissionId is null"() { + def "updateMetadataForOutboundMessage test case when outboundReportId is null"() { when: - def sentSubmissionId = null - PartnerMetadataOrchestrator.getInstance().updateMetadataForSentMessage(receivedSubmissionId, sentSubmissionId) + def outboundReportId = null + PartnerMetadataOrchestrator.getInstance().updateMetadataForOutboundMessage(inboundReportId, outboundReportId) then: - 0 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) + 0 * mockPartnerMetadataStorage.readMetadata(inboundReportId) } - def "updateMetadataForSentMessage test case when PartnerMetadata returns no data"() { + def "updateMetadataForOutboundMessage test case when PartnerMetadata returns no data"() { given: - mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.empty() + mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.empty() when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForSentMessage(receivedSubmissionId, sentSubmissionId) + PartnerMetadataOrchestrator.getInstance().updateMetadataForOutboundMessage(inboundReportId, outboundReportId) then: 0 * mockPartnerMetadataStorage.saveMetadata(_ as PartnerMetadata) } - def "updateMetadataForSentMessage ends when sentSubmissionId matches the one provided by PartnerMetadata"() { + def "updateMetadataForOutboundMessage ends when outboundReportId matches the one provided by PartnerMetadata"() { given: - def optional = Optional.of(new PartnerMetadata(receivedSubmissionId, sentSubmissionId, Instant.now(), null, "", PartnerMetadataStatus.FAILED, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber)) - mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> optional + def optional = Optional.of(new PartnerMetadata(inboundReportId, outboundReportId, Instant.now(), null, "", PartnerMetadataStatus.FAILED, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber)) + mockPartnerMetadataStorage.readMetadata(inboundReportId) >> optional when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForSentMessage(receivedSubmissionId, sentSubmissionId) + PartnerMetadataOrchestrator.getInstance().updateMetadataForOutboundMessage(inboundReportId, outboundReportId) then: 0 * mockPartnerMetadataStorage.saveMetadata(_ as PartnerMetadata) @@ -167,33 +167,33 @@ class PartnerMetadataOrchestratorTest extends Specification { def "getMetadata returns empty Optional when data is not found"() { given: - String receivedSubmissionId = "receivedSubmissionId" + String inboundReportId = "inboundReportId" def mockMetadata = Optional.empty() when: - def result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + def result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: !result.isPresent() - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> mockMetadata + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> mockMetadata } - def "updateMetadataForReceivedMessage throws PartnerMetadataException on client error"() { + def "updateMetadataForInboundMessage throws PartnerMetadataException on client error"() { given: mockClient.getRsToken() >> "token" mockClient.requestDeliveryEndpoint(_ as String, _ as String) >> { throw new ReportStreamEndpointClientException("Client error", new Exception()) } when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: 1 * mockPartnerMetadataStorage.saveMetadata(_ as PartnerMetadata) >> { PartnerMetadata metadata -> - assert metadata.receivedSubmissionId() == receivedSubmissionId + assert metadata.inboundReportId() == inboundReportId } thrown(PartnerMetadataException) } - def "updateMetadataForReceivedMessage throws PartnerMetadataException on formatter error"() { + def "updateMetadataForInboundMessage throws PartnerMetadataException on formatter error"() { given: def rsDeliveryApiResponse = "{ASDF}" @@ -202,13 +202,13 @@ class PartnerMetadataOrchestratorTest extends Specification { mockFormatter.convertJsonToObject(rsDeliveryApiResponse, _ as TypeReference) >> { throw new FormatterProcessingException("Formatter error", new Exception()) } when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: thrown(PartnerMetadataException) } - def "updateMetadataForReceivedMessage throws PartnerMetadataException on formatter error due to unexpected response format"() { + def "updateMetadataForInboundMessage throws PartnerMetadataException on formatter error due to unexpected response format"() { given: def wrongFormatResponse = "{\"someotherkey\": \"value\"}" @@ -217,13 +217,13 @@ class PartnerMetadataOrchestratorTest extends Specification { mockFormatter.convertJsonToObject(wrongFormatResponse, _ as TypeReference) >> [someotherkey: "value"] when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: thrown(PartnerMetadataException) } - def "updateMetadataForReceivedMessage throws PartnerMetadataException due to 0 originalIngestions"() { + def "updateMetadataForInboundMessage throws PartnerMetadataException due to 0 originalIngestions"() { given: def wrongFormatResponse = "{\"originalIngestion\": []}" @@ -232,13 +232,13 @@ class PartnerMetadataOrchestratorTest extends Specification { mockFormatter.convertJsonToObject(wrongFormatResponse, _ as TypeReference) >> [originalIngestion: []] when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: thrown(PartnerMetadataException) } - def "updateMetadataForReceivedMessage throws PartnerMetadataException due to null originalIngestion"() { + def "updateMetadataForInboundMessage throws PartnerMetadataException due to null originalIngestion"() { given: def wrongFormatResponse = "{\"someOtherKey\": {}}" @@ -247,13 +247,13 @@ class PartnerMetadataOrchestratorTest extends Specification { mockFormatter.convertJsonToObject(wrongFormatResponse, _ as TypeReference) >> [someOtherKey:{}] when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: thrown(PartnerMetadataException) } - def "updateMetadataForReceivedMessage throws PartnerMetadataException due to empty originalIngestion"() { + def "updateMetadataForInboundMessage throws PartnerMetadataException due to empty originalIngestion"() { given: def wrongFormatResponse = "{\"originalIngestion\": {}}" @@ -262,35 +262,35 @@ class PartnerMetadataOrchestratorTest extends Specification { mockFormatter.convertJsonToObject(wrongFormatResponse, _ as TypeReference) >> [originalIngestion:[]] when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForReceivedMessage(testMetadata) + PartnerMetadataOrchestrator.getInstance().updateMetadataForInboundMessage(testMetadata) then: thrown(PartnerMetadataException) } - def "updateMetadataForSentMessage updates metadata successfully"() { + def "updateMetadataForOutboundMessage updates metadata successfully"() { given: - def partnerMetadata = new PartnerMetadata(receivedSubmissionId, "hash", PartnerMetadataMessageType.ORDER, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) - def updatedPartnerMetadata = partnerMetadata.withSentSubmissionId(sentSubmissionId) + def partnerMetadata = new PartnerMetadata(inboundReportId, "hash", PartnerMetadataMessageType.ORDER, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def updatedPartnerMetadata = partnerMetadata.withOutboundReportId(outboundReportId) when: - PartnerMetadataOrchestrator.getInstance().updateMetadataForSentMessage(receivedSubmissionId, sentSubmissionId) + PartnerMetadataOrchestrator.getInstance().updateMetadataForOutboundMessage(inboundReportId, outboundReportId) then: - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(partnerMetadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(partnerMetadata) 1 * mockPartnerMetadataStorage.saveMetadata(updatedPartnerMetadata) } def "getMetadata throws PartnerMetadataException on client error"() { given: - def partnerMetadata = new PartnerMetadata(receivedSubmissionId, "sentSubmissionId", Instant.now(), null, "hash", PartnerMetadataStatus.PENDING, "failureReason", PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def partnerMetadata = new PartnerMetadata(inboundReportId, "outboundReportId", Instant.now(), null, "hash", PartnerMetadataStatus.PENDING, "failureReason", PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) - mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(partnerMetadata) + mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(partnerMetadata) mockClient.getRsToken() >> "token" mockClient.requestDeliveryEndpoint(_ as String, _ as String) >> { throw new ReportStreamEndpointClientException("Client error", new Exception()) } when: - PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: thrown(PartnerMetadataException) @@ -299,15 +299,15 @@ class PartnerMetadataOrchestratorTest extends Specification { def "getMetadata throws PartnerMetadataException on formatter error"() { given: def rsHistoryApiResponse = "{\"destinations\": [{\"organization_id\": \"org\", \"service\": \"service\"}]}" - def partnerMetadata = new PartnerMetadata(receivedSubmissionId, "sentSubmissionId", Instant.now(), null, "hash", PartnerMetadataStatus.PENDING, "failureReason", PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def partnerMetadata = new PartnerMetadata(inboundReportId, "outboundReportId", Instant.now(), null, "hash", PartnerMetadataStatus.PENDING, "failureReason", PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) - mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(partnerMetadata) + mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(partnerMetadata) mockClient.getRsToken() >> "token" mockClient.requestHistoryEndpoint(_ as String, _ as String) >> rsHistoryApiResponse mockFormatter.convertJsonToObject(rsHistoryApiResponse, _ as TypeReference) >> { throw new FormatterProcessingException("Formatter error", new Exception()) } when: - PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: thrown(PartnerMetadataException) @@ -315,42 +315,42 @@ class PartnerMetadataOrchestratorTest extends Specification { def "getMetadata retrieves metadata successfully with the sender already filled"() { given: - def metadata = new PartnerMetadata(receivedSubmissionId, "sentSubmissionId", Instant.now(), null, "hash", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def metadata = new PartnerMetadata(inboundReportId, "outboundReportId", Instant.now(), null, "hash", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) when: - def result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + def result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == metadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(metadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(metadata) 0 * mockClient.requestHistoryEndpoint(_, _) } - def "getMetadata skips lookup with stale metadata and missing sentSubmissionId"() { + def "getMetadata skips lookup with stale metadata and missing outboundReportId"() { given: - def metadata = new PartnerMetadata(receivedSubmissionId, null, Instant.now(), null, "hash", PartnerMetadataStatus.PENDING, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, "placer_order_number") + def metadata = new PartnerMetadata(inboundReportId, null, Instant.now(), null, "hash", PartnerMetadataStatus.PENDING, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, "placer_order_number") when: - PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(metadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(metadata) 0 * mockClient.requestHistoryEndpoint(_, _) notThrown(PartnerMetadataException) } - def "getMetadata retrieves metadata successfully when receiver is present and sentSubmissionId is missing"() { + def "getMetadata retrieves metadata successfully when receiver is present and outboundReportId is missing"() { given: - def metadata = new PartnerMetadata(receivedSubmissionId, null, Instant.now(), null, "hash", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def metadata = new PartnerMetadata(inboundReportId, null, Instant.now(), null, "hash", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.RESULT, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) when: - def result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + def result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == metadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(metadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(metadata) } def "getMetadata gets receiver if missing from metadata"() { @@ -358,11 +358,11 @@ class PartnerMetadataOrchestratorTest extends Specification { def timeDelivered = Instant.now() def rsHistoryApiResponse = "{\"actualCompletionAt\": \"2023-10-24T19:48:26.921Z\",\"destinations\": [{\"organization_id\": \"org\", \"service\": \"service\"}]}" def receivingFacilityWithMissingUniversalId = new MessageHdDataType("receiving_app_name", null, "receiving_app_type") - def missingReceiverMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.DELIVERED, "", messageType, sendingApp, sendingFacility, receivingApp, receivingFacilityWithMissingUniversalId, placerOrderNumber) - def expectedMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.DELIVERED, "", messageType, sendingApp, sendingFacility, receivingApp, receivingFacilityWithMissingUniversalId, placerOrderNumber) + def missingReceiverMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.DELIVERED, "", messageType, sendingApp, sendingFacility, receivingApp, receivingFacilityWithMissingUniversalId, placerOrderNumber) + def expectedMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.DELIVERED, "", messageType, sendingApp, sendingFacility, receivingApp, receivingFacilityWithMissingUniversalId, placerOrderNumber) mockClient.getRsToken() >> bearerToken - mockClient.requestHistoryEndpoint(sentSubmissionId, bearerToken) >> rsHistoryApiResponse + mockClient.requestHistoryEndpoint(outboundReportId, bearerToken) >> rsHistoryApiResponse mockFormatter.convertJsonToObject(rsHistoryApiResponse, _ as TypeReference) >> [ overallStatus: "Delivered", actualCompletionAt: timeDelivered.toString(), @@ -373,23 +373,23 @@ class PartnerMetadataOrchestratorTest extends Specification { ] when: - Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == expectedMetadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(missingReceiverMetadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(missingReceiverMetadata) 1 * mockPartnerMetadataStorage.saveMetadata(expectedMetadata) } def "getMetadata gets status if still pending in metadata"() { given: def rsHistoryApiResponse = "{\"destinations\": [{\"organization_id\": \"org\", \"service\": \"service\"}]}" - def missingReceiverMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, null, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) - def expectedMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, null, hashCode, PartnerMetadataStatus.FAILED, "", messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def missingReceiverMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, null, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def expectedMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, null, hashCode, PartnerMetadataStatus.FAILED, "", messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) mockClient.getRsToken() >> bearerToken - mockClient.requestHistoryEndpoint(sentSubmissionId, bearerToken) >> rsHistoryApiResponse + mockClient.requestHistoryEndpoint(outboundReportId, bearerToken) >> rsHistoryApiResponse mockFormatter.convertJsonToObject(rsHistoryApiResponse, _ as TypeReference) >> [ overallStatus: "Not Delivering", destinations: [ @@ -399,12 +399,12 @@ class PartnerMetadataOrchestratorTest extends Specification { ] when: - Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == expectedMetadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(missingReceiverMetadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(missingReceiverMetadata) 1 * mockPartnerMetadataStorage.saveMetadata(expectedMetadata) } @@ -412,11 +412,11 @@ class PartnerMetadataOrchestratorTest extends Specification { given: def timeDelivered = Instant.now() def rsHistoryApiResponse = "whatever" - def missingReceiverMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) - def expectedMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.DELIVERED, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def missingReceiverMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def expectedMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hashCode, PartnerMetadataStatus.DELIVERED, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) mockClient.getRsToken() >> bearerToken - mockClient.requestHistoryEndpoint(sentSubmissionId, bearerToken) >> rsHistoryApiResponse + mockClient.requestHistoryEndpoint(outboundReportId, bearerToken) >> rsHistoryApiResponse mockFormatter.convertJsonToObject(rsHistoryApiResponse, _ as TypeReference) >> [ overallStatus: "Delivered", actualCompletionAt: timeDelivered.toString(), @@ -431,22 +431,22 @@ class PartnerMetadataOrchestratorTest extends Specification { ] when: - Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == expectedMetadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(missingReceiverMetadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(missingReceiverMetadata) 1 * mockPartnerMetadataStorage.saveMetadata(expectedMetadata) } def "getMetadata saves pending without delivery time if nobody has delivery times"() { given: def rsHistoryApiResponse = "whatever" - def missingReceiverMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, null, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def missingReceiverMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, null, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) mockClient.getRsToken() >> bearerToken - mockClient.requestHistoryEndpoint(sentSubmissionId, bearerToken) >> rsHistoryApiResponse + mockClient.requestHistoryEndpoint(outboundReportId, bearerToken) >> rsHistoryApiResponse mockFormatter.convertJsonToObject(rsHistoryApiResponse, _ as TypeReference) >> [ overallStatus: "Pending", actualCompletionAt: null, @@ -461,23 +461,23 @@ class PartnerMetadataOrchestratorTest extends Specification { ] when: - Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == missingReceiverMetadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(missingReceiverMetadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(missingReceiverMetadata) 1 * mockPartnerMetadataStorage.saveMetadata(missingReceiverMetadata) } def "getMetadata saves loaded delivered metadata if found"() { given: def rsHistoryApiResponse = "whatever" - def missingReceiverMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, null, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) - def expectedMetadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, null, hashCode, PartnerMetadataStatus.DELIVERED, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def missingReceiverMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, null, hashCode, PartnerMetadataStatus.PENDING, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) + def expectedMetadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, null, hashCode, PartnerMetadataStatus.DELIVERED, null, messageType, sendingApp, sendingFacility, receivingApp, receivingFacility, placerOrderNumber) mockClient.getRsToken() >> bearerToken - mockClient.requestHistoryEndpoint(sentSubmissionId, bearerToken) >> rsHistoryApiResponse + mockClient.requestHistoryEndpoint(outboundReportId, bearerToken) >> rsHistoryApiResponse mockFormatter.convertJsonToObject(rsHistoryApiResponse, _ as TypeReference) >> [ overallStatus: "Delivered", actualCompletionAt: null, @@ -492,12 +492,12 @@ class PartnerMetadataOrchestratorTest extends Specification { ] when: - Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(receivedSubmissionId) + Optional result = PartnerMetadataOrchestrator.getInstance().getMetadata(inboundReportId) then: result.isPresent() result.get() == expectedMetadata - 1 * mockPartnerMetadataStorage.readMetadata(receivedSubmissionId) >> Optional.of(missingReceiverMetadata) + 1 * mockPartnerMetadataStorage.readMetadata(inboundReportId) >> Optional.of(missingReceiverMetadata) 1 * mockPartnerMetadataStorage.saveMetadata(expectedMetadata) } @@ -540,7 +540,7 @@ class PartnerMetadataOrchestratorTest extends Specification { then: 1 * mockPartnerMetadataStorage.saveMetadata(_ as PartnerMetadata) >> { PartnerMetadata partnerMetadata -> assert partnerMetadata.deliveryStatus() == PartnerMetadataStatus.FAILED - assert partnerMetadata.receivedSubmissionId() == submissionId + assert partnerMetadata.inboundReportId() == submissionId } } @@ -714,22 +714,22 @@ class PartnerMetadataOrchestratorTest extends Specification { def "findMessagesIdsToLink returns a list of message ids"() { given: def placerOrderNumber = "placerOrderNumber" - def receivedSubmissionId1 = "1" - def receivedSubmissionId2 = "2" + def inboundReportId1 = "1" + def inboundReportId2 = "2" def sendingAppDetails = new MessageHdDataType("sending_app_name", "sending_app_id", "sending_app_type") def sendingFacilityDetails = new MessageHdDataType("sending_facility_name", "sending_facility_id", "sending_facility_type") def receivingAppDetails = new MessageHdDataType("receiving_app_name", "receiving_app_id", "receiving_app_type") def receivingFacilityDetails = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") - def partnerMetadata1 = new PartnerMetadata(receivedSubmissionId1, "hash1", PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, placerOrderNumber) - def partnerMetadata2 = new PartnerMetadata(receivedSubmissionId2, "hash2", PartnerMetadataMessageType.RESULT, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, placerOrderNumber) - def metadataSetForMessageLinking = Set.of(receivedSubmissionId1, receivedSubmissionId2) - mockPartnerMetadataStorage.readMetadataForMessageLinking(receivedSubmissionId) >> metadataSetForMessageLinking + def partnerMetadata1 = new PartnerMetadata(inboundReportId1, "hash1", PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, placerOrderNumber) + def partnerMetadata2 = new PartnerMetadata(inboundReportId2, "hash2", PartnerMetadataMessageType.RESULT, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, placerOrderNumber) + def metadataSetForMessageLinking = Set.of(inboundReportId1, inboundReportId2) + mockPartnerMetadataStorage.readMetadataForMessageLinking(inboundReportId) >> metadataSetForMessageLinking when: - def result = PartnerMetadataOrchestrator.getInstance().findMessagesIdsToLink(receivedSubmissionId) + def result = PartnerMetadataOrchestrator.getInstance().findMessagesIdsToLink(inboundReportId) then: - result == Set.of(receivedSubmissionId1, receivedSubmissionId2) + result == Set.of(inboundReportId1, inboundReportId2) } def "linkMessages links messages successfully"() { diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataTest.groovy index 28ef621db..7680f7a45 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/metadata/partner/PartnerMetadataTest.groovy @@ -17,8 +17,8 @@ class PartnerMetadataTest extends Specification { def "test constructor"() { given: - def receivedSubmissionId = "receivedSubmissionId" - def sentSubmissionId = "sentSubmissionId" + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" def timeReceived = Instant.now() def timeDelivered = Instant.now() def hash = "abcd" @@ -31,11 +31,11 @@ class PartnerMetadataTest extends Specification { def receivingFacilityDetails = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") when: - def metadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, timeDelivered, hash, PartnerMetadataStatus.DELIVERED, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def metadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hash, PartnerMetadataStatus.DELIVERED, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") then: - metadata.receivedSubmissionId() == receivedSubmissionId - metadata.sentSubmissionId() == sentSubmissionId + metadata.inboundReportId() == inboundReportId + metadata.outboundReportId() == outboundReportId metadata.timeDelivered() == timeDelivered metadata.timeReceived() == timeReceived metadata.hash() == hash @@ -47,27 +47,27 @@ class PartnerMetadataTest extends Specification { metadata.receivingFacilityDetails() == receivingFacilityDetails } - def "test constructor with only received submission ID and status"() { + def "test constructor with only inbound message ID and status"() { given: - def receivedSubmissionId = "receivedSubmissionId" + def inboundReportId = "inboundReportId" def deliverStatus = PartnerMetadataStatus.DELIVERED when: - def metadata = new PartnerMetadata(receivedSubmissionId, deliverStatus) + def metadata = new PartnerMetadata(inboundReportId, deliverStatus) then: - metadata.receivedSubmissionId() == receivedSubmissionId - metadata.sentSubmissionId() == null + metadata.inboundReportId() == inboundReportId + metadata.outboundReportId() == null metadata.timeReceived() == null metadata.timeDelivered() == null metadata.hash() == null metadata.deliveryStatus() == deliverStatus } - def "test withSentSubmissionId to update PartnerMetadata"() { + def 'test withOutboundReportId to update PartnerMetadata'() { given: - def receivedSubmissionId = "receivedSubmissionId" - def sentSubmissionId = "sentSubmissionId" + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" def messageType = PartnerMetadataMessageType.RESULT def timeReceived = Instant.now() def hash = "abcd" @@ -78,14 +78,14 @@ class PartnerMetadataTest extends Specification { def receivingAppDetails = new MessageHdDataType("receiving_app_name", "receiving_app_id", "receiving_app_type") def receivingFacilityDetails = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") - def metadata = new PartnerMetadata(receivedSubmissionId, null, timeReceived, null, hash, status, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def metadata = new PartnerMetadata(inboundReportId, null, timeReceived, null, hash, status, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") when: - def updatedMetadata = metadata.withSentSubmissionId(sentSubmissionId) + def updatedMetadata = metadata.withOutboundReportId(outboundReportId) then: - updatedMetadata.receivedSubmissionId() == receivedSubmissionId - updatedMetadata.sentSubmissionId() == sentSubmissionId + updatedMetadata.inboundReportId() == inboundReportId + updatedMetadata.outboundReportId() == outboundReportId updatedMetadata.timeReceived() == timeReceived updatedMetadata.hash() == hash updatedMetadata.deliveryStatus() == status @@ -97,8 +97,8 @@ class PartnerMetadataTest extends Specification { def "test withDeliveryStatus to update PartnerMetadata"() { given: - def receivedSubmissionId = "receivedSubmissionId" - def sentSubmissionId = "sentSubmissionId" + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" def timeReceived = Instant.now() def timeDelivered = null def messageType = PartnerMetadataMessageType.RESULT @@ -108,15 +108,15 @@ class PartnerMetadataTest extends Specification { def sendingFacilityDetails = new MessageHdDataType("sending_facility_name", "sending_facility_id", "sending_facility_type") def receivingAppDetails = new MessageHdDataType("receiving_app_name", "receiving_app_id", "receiving_app_type") def receivingFacilityDetails = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") - def metadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, timeDelivered, hash, PartnerMetadataStatus.PENDING, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def metadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hash, PartnerMetadataStatus.PENDING, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") when: def newStatus = PartnerMetadataStatus.DELIVERED - def updatedMetadata = metadata.withSentSubmissionId(sentSubmissionId).withDeliveryStatus(newStatus) + def updatedMetadata = metadata.withOutboundReportId(outboundReportId).withDeliveryStatus(newStatus) then: - updatedMetadata.receivedSubmissionId() == receivedSubmissionId - updatedMetadata.sentSubmissionId() == sentSubmissionId + updatedMetadata.inboundReportId() == inboundReportId + updatedMetadata.outboundReportId() == outboundReportId updatedMetadata.timeReceived() == timeReceived updatedMetadata.timeDelivered() == null updatedMetadata.hash() == hash @@ -130,8 +130,8 @@ class PartnerMetadataTest extends Specification { def "test withTimeDelivered to update PartnerMetadata"() { given: - def receivedSubmissionId = "receivedSubmissionId" - def sentSubmissionId = "sentSubmissionId" + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" def timeReceived = Instant.now() def timeDelivered = Instant.now() def messageType = PartnerMetadataMessageType.RESULT @@ -141,14 +141,14 @@ class PartnerMetadataTest extends Specification { def sendingFacilityDetails = new MessageHdDataType("sending_facility_name", "sending_facility_id", "sending_facility_type") def receivingAppDetails = new MessageHdDataType("receiving_app_name", "receiving_app_id", "receiving_app_type") def receivingFacilityDetails = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") - def metadata = new PartnerMetadata(receivedSubmissionId, sentSubmissionId, timeReceived, null, hash, PartnerMetadataStatus.PENDING, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def metadata = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, null, hash, PartnerMetadataStatus.PENDING, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") when: def updatedMetadata = metadata.withTimeDelivered(timeDelivered) then: - updatedMetadata.receivedSubmissionId() == receivedSubmissionId - updatedMetadata.sentSubmissionId() == sentSubmissionId + updatedMetadata.inboundReportId() == inboundReportId + updatedMetadata.outboundReportId() == outboundReportId updatedMetadata.timeReceived() == timeReceived updatedMetadata.timeDelivered() == timeDelivered updatedMetadata.hash() == hash diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCaseTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCaseTest.groovy index ea3fd9fea..b893f2a0e 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCaseTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/orders/SendOrderUseCaseTest.groovy @@ -36,23 +36,23 @@ class SendOrderUseCaseTest extends Specification { def "send sends successfully"() { given: - def receivedSubmissionId = "receivedId" - def sentSubmissionId = "sentId" + def inboundReportId = "inboundReportId" + def outboundReportId = "outboundReportId" def messagesIdsToLink = new HashSet<>(Set.of("messageId1", "messageId2")) def mockOrder = new OrderMock(null, null, null, null, null, null, null, null) TestApplicationContext.injectRegisteredImplementations() when: - SendOrderUseCase.getInstance().convertAndSend(mockOrder, receivedSubmissionId) + SendOrderUseCase.getInstance().convertAndSend(mockOrder, inboundReportId) then: 1 * mockEngine.runRules(mockOrder) - 1 * mockSender.send(mockOrder) >> Optional.of(sentSubmissionId) - 1 * mockOrchestrator.updateMetadataForReceivedMessage(_ as PartnerMetadata) - 1 * mockOrchestrator.updateMetadataForSentMessage(receivedSubmissionId, sentSubmissionId) - 1 * mockOrchestrator.findMessagesIdsToLink(receivedSubmissionId) >> messagesIdsToLink - 1 * mockOrchestrator.linkMessages(messagesIdsToLink + receivedSubmissionId) + 1 * mockSender.send(mockOrder) >> Optional.of(outboundReportId) + 1 * mockOrchestrator.updateMetadataForInboundMessage(_ as PartnerMetadata) + 1 * mockOrchestrator.updateMetadataForOutboundMessage(inboundReportId, outboundReportId) + 1 * mockOrchestrator.findMessagesIdsToLink(inboundReportId) >> messagesIdsToLink + 1 * mockOrchestrator.linkMessages(messagesIdsToLink + inboundReportId) } def "send fails to send"() { @@ -67,9 +67,9 @@ class SendOrderUseCaseTest extends Specification { thrown(UnableToSendMessageException) } - def "convertAndSend should log warnings for null receivedSubmissionId"() { + def "convertAndSend should log warnings for null inboundReportId"() { given: - mockSender.send(_) >> Optional.of("sentSubmissionId") + mockSender.send(_) >> Optional.of("outboundReportId") TestApplicationContext.injectRegisteredImplementations() when: @@ -77,41 +77,41 @@ class SendOrderUseCaseTest extends Specification { then: 3 * mockLogger.logWarning(_) - 0 * mockOrchestrator.updateMetadataForReceivedMessage(_, _) + 0 * mockOrchestrator.updateMetadataForInboundMessage(_, _) } def "convertAndSend logs error and continues when updateMetadataForReceivedOrder throws exception"() { given: def order = Mock(Order) - def receivedSubmissionId = "receivedId" + def inboundReportId = "inboundReportId" - mockOrchestrator.updateMetadataForReceivedMessage(_ as PartnerMetadata) >> { throw new PartnerMetadataException("Error") } + mockOrchestrator.updateMetadataForInboundMessage(_ as PartnerMetadata) >> { throw new PartnerMetadataException("Error") } TestApplicationContext.injectRegisteredImplementations() when: - SendOrderUseCase.getInstance().convertAndSend(order, receivedSubmissionId) + SendOrderUseCase.getInstance().convertAndSend(order, inboundReportId) then: 1 * mockLogger.logError(_, _) 1 * mockEngine.runRules(order) - 1 * mockOrchestrator.findMessagesIdsToLink(receivedSubmissionId) >> Set.of() - 1 * mockSender.send(order) >> Optional.of("sentId") + 1 * mockOrchestrator.findMessagesIdsToLink(inboundReportId) >> Set.of() + 1 * mockSender.send(order) >> Optional.of("outboundReportId") } def "convertAndSend logs error and continues when updating the metadata for the sent order throws exception"() { given: def order = Mock(Order) def partnerMetadataException = new PartnerMetadataException("Error") - mockOrchestrator.updateMetadataForSentMessage("receivedId", _) >> { throw partnerMetadataException} + mockOrchestrator.updateMetadataForOutboundMessage("inboundReportId", _) >> { throw partnerMetadataException} TestApplicationContext.injectRegisteredImplementations() when: - SendOrderUseCase.getInstance().convertAndSend(order, "receivedId") + SendOrderUseCase.getInstance().convertAndSend(order, "inboundReportId") then: 1 * mockEngine.runRules(order) 1 * mockOrchestrator.findMessagesIdsToLink(_ as String) >> Set.of() - 1 * mockSender.send(order) >> Optional.of("sentId") + 1 * mockSender.send(order) >> Optional.of("outboundReportId") 1 * mockLogger.logError(_, partnerMetadataException) } @@ -123,11 +123,11 @@ class SendOrderUseCaseTest extends Specification { mockSender.send(_) >> Optional.empty() when: - SendOrderUseCase.getInstance().convertAndSend(mockOrder, "receivedId") + SendOrderUseCase.getInstance().convertAndSend(mockOrder, "inboundReportId") then: 1 * mockLogger.logWarning(_) 1 * mockOrchestrator.findMessagesIdsToLink(_ as String) >> Set.of() - 0 * mockOrchestrator.updateMetadataForSentMessage(_ as String, _ as String) + 0 * mockOrchestrator.updateMetadataForOutboundMessage(_ as String, _ as String) } } diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCaseTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCaseTest.groovy index febfad029..30fbf7945 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCaseTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/etor/results/SendResultUseCaseTest.groovy @@ -38,57 +38,57 @@ class SendResultUseCaseTest extends Specification { def "convertAndSend works"() { given: def mockResult = new ResultMock(null, "Mock result", null, null, null, null, null) - def receivedSubmissionId = "receivedId" + def inboundReportId = "inboundReportId" when: - SendResultUseCase.getInstance().convertAndSend(mockResult, receivedSubmissionId) + SendResultUseCase.getInstance().convertAndSend(mockResult, inboundReportId) then: 1 * mockEngine.runRules(mockResult) - 1 * mockSender.send(mockResult) >> Optional.of("sentSubmissionId") + 1 * mockSender.send(mockResult) >> Optional.of("outboundReportId") } def "convertAndSend throws exception when send fails"() { given: - def receivedSubmissionId = "receivedId" + def inboundReportId = "inboundReportId" mockSender.send(_) >> { throw new UnableToSendMessageException("DogCow", new NullPointerException()) } when: - SendResultUseCase.getInstance().convertAndSend(Mock(Result), receivedSubmissionId) + SendResultUseCase.getInstance().convertAndSend(Mock(Result), inboundReportId) then: thrown(UnableToSendMessageException) } - def "convertAndSend logs error and continues when updateMetadataForReceivedMessage throws exception"() { + def "convertAndSend logs error and continues when updateMetadataForInboundMessage throws exception"() { given: def result = Mock(Result) - def receivedSubmissionId = "receivedId" - mockOrchestrator.updateMetadataForReceivedMessage(_ as PartnerMetadata) >> { throw new PartnerMetadataException("Error") } + def inboundReportId = "inboundReportId" + mockOrchestrator.updateMetadataForInboundMessage(_ as PartnerMetadata) >> { throw new PartnerMetadataException("Error") } TestApplicationContext.injectRegisteredImplementations() when: - SendResultUseCase.getInstance().convertAndSend(result, receivedSubmissionId) + SendResultUseCase.getInstance().convertAndSend(result, inboundReportId) then: 1 * mockLogger.logError(_, _) 1 * mockEngine.runRules(result) - 1 * mockSender.send(result) >> Optional.of("sentId") + 1 * mockSender.send(result) >> Optional.of("outboundReportId") } - def "convertAndSend logs error and continues when updateMetadataForSentMessage throws exception"() { + def "convertAndSend logs error and continues when updateMetadataForOutboundMessage throws exception"() { given: def result = Mock(Result) - def receivedSubmissionId = "receivedId" - mockOrchestrator.updateMetadataForSentMessage(receivedSubmissionId, _ as String) >> { throw new PartnerMetadataException("Error") } + def inboundReportId = "inboundReportId" + mockOrchestrator.updateMetadataForOutboundMessage(inboundReportId, _ as String) >> { throw new PartnerMetadataException("Error") } TestApplicationContext.injectRegisteredImplementations() when: - SendResultUseCase.getInstance().convertAndSend(result, receivedSubmissionId) + SendResultUseCase.getInstance().convertAndSend(result, inboundReportId) then: 1 * mockEngine.runRules(result) - 1 * mockSender.send(result) >> Optional.of("sentId") + 1 * mockSender.send(result) >> Optional.of("outboundReportId") 1 * mockLogger.logError(_, _) } } diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorageTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorageTest.groovy index 0f32a2e9d..08371d55f 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorageTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/database/DatabasePartnerMetadataStorageTest.groovy @@ -31,7 +31,7 @@ class DatabasePartnerMetadataStorageTest extends Specification { def sendingFacilityDetails = new MessageHdDataType("sending_facility_name", "sending_facility_id", "sending_facility_type") def receivingAppDetails = new MessageHdDataType("receiving_app_name", "receiving_app_id", "receiving_app_type") def receivingFacilityDetails = new MessageHdDataType("receiving_facility_name", "receiving_facility_id", "receiving_facility_type") - def mockMetadata = new PartnerMetadata("receivedSubmissionId", "sentSubmissionId", Instant.now(), Instant.now(), "hash", PartnerMetadataStatus.DELIVERED, "failure reason", PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def mockMetadata = new PartnerMetadata("inboundReportId", "outboundReportId", Instant.now(), Instant.now(), "hash", PartnerMetadataStatus.DELIVERED, "failure reason", PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") def setup() { TestApplicationContext.reset() @@ -52,7 +52,7 @@ class DatabasePartnerMetadataStorageTest extends Specification { mockDao.fetchFirstData(_ as Function, _ as Function) >> mockMetadata when: - def actualResult = DatabasePartnerMetadataStorage.getInstance().readMetadata(mockMetadata.receivedSubmissionId()) + def actualResult = DatabasePartnerMetadataStorage.getInstance().readMetadata(mockMetadata.inboundReportId()) then: actualResult == expectedResult @@ -63,7 +63,7 @@ class DatabasePartnerMetadataStorageTest extends Specification { mockDao.fetchFirstData(_ as Function, _ as Function) >> { throw new SQLException("Something went wrong!") } when: - DatabasePartnerMetadataStorage.getInstance().readMetadata("receivedSubmissionId") + DatabasePartnerMetadataStorage.getInstance().readMetadata("inboundReportId") then: thrown(PartnerMetadataException) @@ -103,8 +103,8 @@ class DatabasePartnerMetadataStorageTest extends Specification { def testMapper = new ObjectMapper() List columns = List.of( - new DbColumn("received_message_id", mockMetadata.receivedSubmissionId(), false, Types.VARCHAR), - new DbColumn("sent_message_id", mockMetadata.sentSubmissionId(), true, Types.VARCHAR), + new DbColumn("received_message_id", mockMetadata.inboundReportId(), false, Types.VARCHAR), + new DbColumn("sent_message_id", mockMetadata.outboundReportId(), true, Types.VARCHAR), new DbColumn("hash_of_message", mockMetadata.hash(), false, Types.VARCHAR), new DbColumn("time_received", Timestamp.from(mockMetadata.timeReceived()),false, Types.TIMESTAMP), new DbColumn("time_delivered", Timestamp.from(mockMetadata.timeDelivered()),true, Types.TIMESTAMP), @@ -200,8 +200,8 @@ class DatabasePartnerMetadataStorageTest extends Specification { given: def testMapper = new ObjectMapper() def mockMetadata = new PartnerMetadata( - "receivedSubmissionId", - "sentSubmissionId", + "inboundReportId", + "outboundReportId", null, null, "hash", @@ -217,8 +217,8 @@ class DatabasePartnerMetadataStorageTest extends Specification { List columns = List.of( - new DbColumn("received_message_id", mockMetadata.receivedSubmissionId(), false, Types.VARCHAR), - new DbColumn("sent_message_id", mockMetadata.sentSubmissionId(), true, Types.VARCHAR), + new DbColumn("received_message_id", mockMetadata.inboundReportId(), false, Types.VARCHAR), + new DbColumn("sent_message_id", mockMetadata.outboundReportId(), true, Types.VARCHAR), new DbColumn("hash_of_message", mockMetadata.hash(), false, Types.VARCHAR), new DbColumn("time_received", null, false, Types.TIMESTAMP), new DbColumn("time_delivered", null,true, Types.TIMESTAMP), @@ -248,7 +248,7 @@ class DatabasePartnerMetadataStorageTest extends Specification { mockDao.fetchManyData(_ as Function, _ as Function, _) >> expectedResult when: - def actualResult = DatabasePartnerMetadataStorage.getInstance().readMetadataForMessageLinking(mockMetadata.receivedSubmissionId()) + def actualResult = DatabasePartnerMetadataStorage.getInstance().readMetadataForMessageLinking(mockMetadata.inboundReportId()) then: actualResult == expectedResult @@ -259,7 +259,7 @@ class DatabasePartnerMetadataStorageTest extends Specification { mockDao.fetchManyData(_ as Function, _ as Function, _) >> { throw new SQLException("Something went wrong!") } when: - DatabasePartnerMetadataStorage.getInstance().readMetadataForMessageLinking("receivedSubmissionId") + DatabasePartnerMetadataStorage.getInstance().readMetadataForMessageLinking("inboundReportId") then: thrown(PartnerMetadataException) @@ -300,8 +300,8 @@ class DatabasePartnerMetadataStorageTest extends Specification { def "partnerMetadataFromResultSet returns partner metadata"() { given: - def receivedMessageId = "12345" - def sentMessageId = "7890" + def inboundReportId = "12345" + def outboundReportId = "7890" def sender = "DogCow" def receiver = "You'll get your just reward" Timestamp timestampForMock = Timestamp.from(Instant.parse("2024-01-03T15:45:33.30Z")) @@ -313,12 +313,12 @@ class DatabasePartnerMetadataStorageTest extends Specification { def reason = "It done Goofed" def messageType = PartnerMetadataMessageType.RESULT def placerOrderNumber = "placer_order_number" - def expected = new PartnerMetadata(receivedMessageId, sentMessageId, timeReceived, timeDelivered, hash, status, reason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, placerOrderNumber) + def expected = new PartnerMetadata(inboundReportId, outboundReportId, timeReceived, timeDelivered, hash, status, reason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, placerOrderNumber) def mockResultSet = Mock(ResultSet) mockResultSet.next() >> true - mockResultSet.getString("received_message_id") >> receivedMessageId - mockResultSet.getString("sent_message_id") >> sentMessageId + mockResultSet.getString("received_message_id") >> inboundReportId + mockResultSet.getString("sent_message_id") >> outboundReportId mockResultSet.getString("sender") >> sender mockResultSet.getString("receiver") >> receiver mockResultSet.getTimestamp("time_received") >> timestampForMock diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiMetadataConverterTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiMetadataConverterTest.groovy index ce98a0951..52bc0df1d 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiMetadataConverterTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiMetadataConverterTest.groovy @@ -36,13 +36,13 @@ class HapiMetadataConverterTest extends Specification { def messageType = PartnerMetadataMessageType.ORDER def messageIds = Set.of("TestId") PartnerMetadata metadata = new PartnerMetadata( - "receivedSubmissionId", "sentSubmissionId", time, time, hash, PartnerMetadataStatus.DELIVERED, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + "inboundReportId", "outboundReportId", time, time, hash, PartnerMetadataStatus.DELIVERED, failureReason, messageType, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") when: - def result = HapiPartnerMetadataConverter.getInstance().extractPublicMetadataToOperationOutcome(metadata, "receivedSubmissionId", messageIds).getUnderlyingOutcome() as OperationOutcome + def result = HapiPartnerMetadataConverter.getInstance().extractPublicMetadataToOperationOutcome(metadata, "inboundReportId", messageIds).getUnderlyingOutcome() as OperationOutcome then: - result.getId() == "receivedSubmissionId" + result.getId() == "inboundReportId" result.getIssue().get(0).diagnostics == messageIds.toString() result.getIssue().get(1).diagnostics == sendingFacilityId result.getIssue().get(2).diagnostics == receivingFacilityId @@ -52,7 +52,7 @@ class HapiMetadataConverterTest extends Specification { result.getIssue().get(6).diagnostics == PartnerMetadataStatus.DELIVERED.toString() result.getIssue().get(7).diagnostics == failureReason result.getIssue().get(8).diagnostics == messageType.toString() - result.getIssue().get(9).diagnostics == "sentSubmissionId" - result.getIssue().get(10).diagnostics == "receivedSubmissionId" + result.getIssue().get(9).diagnostics == "outboundReportId" + result.getIssue().get(10).diagnostics == "inboundReportId" } } diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorageTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorageTest.groovy index ecc94242f..3c289d8f3 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorageTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/localfile/FilePartnerMetadataStorageTest.groovy @@ -31,16 +31,16 @@ class FilePartnerMetadataStorageTest extends Specification { def "save and read metadata successfully"() { given: - def expectedReceivedSubmissionId = "receivedSubmissionId" - def expectedSentSubmissionId = "receivedSubmissionId" - PartnerMetadata metadata = new PartnerMetadata(expectedReceivedSubmissionId, expectedSentSubmissionId, Instant.parse("2023-12-04T18:51:48.941875Z"), Instant.parse("2023-12-04T18:51:48.941875Z"), "abcd", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def expectedInboundReportId = "inboundReportId" + def expectedOutboundReportId = "outboundReportId" + PartnerMetadata metadata = new PartnerMetadata(expectedInboundReportId, expectedOutboundReportId, Instant.parse("2023-12-04T18:51:48.941875Z"), Instant.parse("2023-12-04T18:51:48.941875Z"), "abcd", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") TestApplicationContext.register(Formatter, Jackson.getInstance()) TestApplicationContext.injectRegisteredImplementations() when: FilePartnerMetadataStorage.getInstance().saveMetadata(metadata) - def actualMetadata = FilePartnerMetadataStorage.getInstance().readMetadata(expectedReceivedSubmissionId) + def actualMetadata = FilePartnerMetadataStorage.getInstance().readMetadata(expectedInboundReportId) then: actualMetadata.get() == metadata @@ -48,7 +48,7 @@ class FilePartnerMetadataStorageTest extends Specification { def "saveMetadata throws PartnerMetadataException when unable to save file"() { given: - PartnerMetadata metadata = new PartnerMetadata("receivedSubmissionId", "sentSubmissionId", Instant.now(), Instant.now(), "abcd", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + PartnerMetadata metadata = new PartnerMetadata("inboundReportId", "outboundReportId", Instant.now(), Instant.now(), "abcd", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") def mockFormatter = Mock(Formatter) mockFormatter.convertToJsonString(_ as PartnerMetadata) >> {throw new FormatterProcessingException("error", new Exception())} @@ -65,10 +65,10 @@ class FilePartnerMetadataStorageTest extends Specification { def "saveMetadata overwrites a file if it had been saved before"() { given: - def expectedReceivedSubmissionId = "receivedSubmissionId" - def expectedSentSubmissionId = "sentSubmissionId" - PartnerMetadata metadata1 = new PartnerMetadata(expectedReceivedSubmissionId, expectedSentSubmissionId, Instant.parse("2023-12-04T18:51:48.941875Z"), Instant.parse("2023-12-04T18:51:48.941875Z"), "abcd", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") - PartnerMetadata metadata2 = new PartnerMetadata(expectedReceivedSubmissionId, PartnerMetadataStatus.DELIVERED) + def expectedInboundReportId = "inboundReportId" + def expectedOutboundReportId = "outboundReportId" + PartnerMetadata metadata1 = new PartnerMetadata(expectedInboundReportId, expectedOutboundReportId, Instant.parse("2023-12-04T18:51:48.941875Z"), Instant.parse("2023-12-04T18:51:48.941875Z"), "abcd", PartnerMetadataStatus.DELIVERED, null, PartnerMetadataMessageType.ORDER, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + PartnerMetadata metadata2 = new PartnerMetadata(expectedInboundReportId, PartnerMetadataStatus.DELIVERED) TestApplicationContext.register(Formatter, Jackson.getInstance()) @@ -77,7 +77,7 @@ class FilePartnerMetadataStorageTest extends Specification { when: FilePartnerMetadataStorage.getInstance().saveMetadata(metadata1) FilePartnerMetadataStorage.getInstance().saveMetadata(metadata2) - def actualMetadata = FilePartnerMetadataStorage.getInstance().readMetadata(expectedReceivedSubmissionId) + def actualMetadata = FilePartnerMetadataStorage.getInstance().readMetadata(expectedInboundReportId) then: actualMetadata.get() == metadata2 @@ -92,12 +92,12 @@ class FilePartnerMetadataStorageTest extends Specification { TestApplicationContext.injectRegisteredImplementations() //write something to the hard drive so that the `readMetadata` in the when gets pass the file existence check - def submissionId = "asljfaskljgalsjgjlas" - PartnerMetadata metadata = new PartnerMetadata(submissionId, null, null, null, null, null, null, null, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") + def inboundReportId = "asljfaskljgalsjgjlas" + PartnerMetadata metadata = new PartnerMetadata(inboundReportId, null, null, null, null, null, null, null, sendingAppDetails, sendingFacilityDetails, receivingAppDetails, receivingFacilityDetails, "placer_order_number") FilePartnerMetadataStorage.getInstance().saveMetadata(metadata) when: - FilePartnerMetadataStorage.getInstance().readMetadata(submissionId) + FilePartnerMetadataStorage.getInstance().readMetadata(inboundReportId) then: thrown(PartnerMetadataException) @@ -134,32 +134,32 @@ class FilePartnerMetadataStorageTest extends Specification { TestApplicationContext.injectRegisteredImplementations() when: - def receivedSubmissionId1 = "receivedSubmissionId1" + def inboundReportId1 = "inboundReportId1" def matchingPlacerOrderNumber1 = "placerOrderNumber1" def matchingSendingFacilityDetails1 = new MessageHdDataType("sending_facility_name1", "sending_facility_id1", "sending_facility_type1") - def matchingSendingFacilityDetailsMetadata1 = new PartnerMetadata(receivedSubmissionId1, null, null, null, null, null, null, null, null, matchingSendingFacilityDetails1, null, new MessageHdDataType(null, null, null), matchingPlacerOrderNumber1) + def matchingSendingFacilityDetailsMetadata1 = new PartnerMetadata(inboundReportId1, null, null, null, null, null, null, null, null, matchingSendingFacilityDetails1, null, new MessageHdDataType(null, null, null), matchingPlacerOrderNumber1) def otherMatchingSendingFacilityDetailsMetadata1 = new PartnerMetadata("1", null, null, null, null, null, null, null, null, matchingSendingFacilityDetails1, null, new MessageHdDataType(null, null, null), matchingPlacerOrderNumber1) FilePartnerMetadataStorage.getInstance().saveMetadata(matchingSendingFacilityDetailsMetadata1) FilePartnerMetadataStorage.getInstance().saveMetadata(otherMatchingSendingFacilityDetailsMetadata1) - def metadataSetWithMatchingSendingFacilityDetails = FilePartnerMetadataStorage.getInstance().readMetadataForMessageLinking(receivedSubmissionId1) + def metadataSetWithMatchingSendingFacilityDetails = FilePartnerMetadataStorage.getInstance().readMetadataForMessageLinking(inboundReportId1) then: - metadataSetWithMatchingSendingFacilityDetails.contains(otherMatchingSendingFacilityDetailsMetadata1.receivedSubmissionId()) - !metadataSetWithMatchingSendingFacilityDetails.contains(matchingSendingFacilityDetailsMetadata1.receivedSubmissionId()) + metadataSetWithMatchingSendingFacilityDetails.contains(otherMatchingSendingFacilityDetailsMetadata1.inboundReportId()) + !metadataSetWithMatchingSendingFacilityDetails.contains(matchingSendingFacilityDetailsMetadata1.inboundReportId()) when: - def receivedSubmissionId2 = "receivedSubmissionId2" + def inboundReportId2 = "inboundReportId2" def matchingPlacerOrderNumber2 = "placerOrderNumber2" def matchingSendingFacilityDetails2 = new MessageHdDataType("sending_facility_name2", "sending_facility_id2", "sending_facility_type2") - def matchingSendingFacilityDetailsMetadata2 = new PartnerMetadata(receivedSubmissionId2, null, null, null, null, null, null, null, null, matchingSendingFacilityDetails2, null, new MessageHdDataType(null, null, null), matchingPlacerOrderNumber2) + def matchingSendingFacilityDetailsMetadata2 = new PartnerMetadata(inboundReportId2, null, null, null, null, null, null, null, null, matchingSendingFacilityDetails2, null, new MessageHdDataType(null, null, null), matchingPlacerOrderNumber2) def matchingReceivingFacilityDetailsMetadata2 = new PartnerMetadata("2", null, null, null, null, null, null, null, null, new MessageHdDataType(null, null, null), null, matchingSendingFacilityDetails2, matchingPlacerOrderNumber2) FilePartnerMetadataStorage.getInstance().saveMetadata(matchingSendingFacilityDetailsMetadata2) FilePartnerMetadataStorage.getInstance().saveMetadata(matchingReceivingFacilityDetailsMetadata2) - def metadataSetWithMatchingSendingAndReceivingFacilityDetails = FilePartnerMetadataStorage.getInstance().readMetadataForMessageLinking(receivedSubmissionId2) + def metadataSetWithMatchingSendingAndReceivingFacilityDetails = FilePartnerMetadataStorage.getInstance().readMetadataForMessageLinking(inboundReportId2) then: - metadataSetWithMatchingSendingAndReceivingFacilityDetails.contains(matchingReceivingFacilityDetailsMetadata2.receivedSubmissionId()) - !metadataSetWithMatchingSendingAndReceivingFacilityDetails.contains(matchingSendingFacilityDetailsMetadata2.receivedSubmissionId()) + metadataSetWithMatchingSendingAndReceivingFacilityDetails.contains(matchingReceivingFacilityDetailsMetadata2.inboundReportId()) + !metadataSetWithMatchingSendingAndReceivingFacilityDetails.contains(matchingSendingFacilityDetailsMetadata2.inboundReportId()) } def "readMetadataForMessageLinking returns an empty set when no metadata is found"() { @@ -178,12 +178,12 @@ class FilePartnerMetadataStorageTest extends Specification { TestApplicationContext.register(Formatter, mockFormatter) TestApplicationContext.injectRegisteredImplementations() - def submissionId = "submissionId" - PartnerMetadata metadata = new PartnerMetadata(submissionId, null, null, null, null, null, null, null, null, null, null, null, null) + def inboundReportId = "inboundReportId" + PartnerMetadata metadata = new PartnerMetadata(inboundReportId, null, null, null, null, null, null, null, null, null, null, null, null) FilePartnerMetadataStorage.getInstance().saveMetadata(metadata) when: - FilePartnerMetadataStorage.getInstance().readMetadataForMessageLinking("submissionId") + FilePartnerMetadataStorage.getInstance().readMetadataForMessageLinking("inboundReportId") then: thrown(PartnerMetadataException) diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClientTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClientTest.groovy index 6b4f7f6e4..9ba099d7b 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClientTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/reportstream/ReportStreamEndpointClientTest.groovy @@ -82,8 +82,8 @@ class ReportStreamEndpointClientTest extends Specification { TestApplicationContext.injectRegisteredImplementations() when: - ReportStreamEndpointClient.getInstance().requestHistoryEndpoint("submission_id_1", "fake token") - ReportStreamEndpointClient.getInstance().requestHistoryEndpoint("submission_id_2", "fake token") + ReportStreamEndpointClient.getInstance().requestHistoryEndpoint("report_id_1", "fake token") + ReportStreamEndpointClient.getInstance().requestHistoryEndpoint("report_id_2", "fake token") then: 2 * mockClient.get(_ as String, _ as Map) >> "200" @@ -97,7 +97,7 @@ class ReportStreamEndpointClientTest extends Specification { TestApplicationContext.injectRegisteredImplementations() when: - ReportStreamEndpointClient.getInstance().requestHistoryEndpoint("submission_id", "fake token") + ReportStreamEndpointClient.getInstance().requestHistoryEndpoint("report_id", "fake token") then: thrown(ReportStreamEndpointClientException)