Skip to content

Commit

Permalink
Merge branch 'master' into experience/16062/unskip-daily-data
Browse files Browse the repository at this point in the history
  • Loading branch information
etanb authored Oct 10, 2024
2 parents 0de971d + ffbe8be commit 5a90362
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 18 deletions.
18 changes: 3 additions & 15 deletions prime-router/src/test/kotlin/common/ReportNodeBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ReportGraphBuilder {
private lateinit var theTopic: Topic
private lateinit var theFormat: MimeFormat
private lateinit var theSender: Sender
private lateinit var theNextAction: TaskAction
private var theNextAction: TaskAction? = null

fun topic(topic: Topic) {
this.theTopic = topic
Expand Down Expand Up @@ -85,13 +85,7 @@ class ReportGraphBuilder {
.setItemCount(theSubmission.theItemCount)
.setExternalName("test-external-name")
.setBodyUrl(theSubmission.theReportBlobUrl)
.setNextAction(
if (::theNextAction.isInitialized) {
theNextAction
} else {
theSubmission.reportGraphNodes.firstOrNull()?.theAction
}
)
.setNextAction(theNextAction ?: theSubmission.reportGraphNodes.firstOrNull()?.theAction)
.setCreatedAt(OffsetDateTime.now())
dbAccess.insertReportFile(
reportFile, txn, action
Expand Down Expand Up @@ -142,13 +136,7 @@ class ReportGraphBuilder {
.setExternalName("test-external-name")
.setBodyUrl(node.theReportBlobUrl)
.setTransportResult(node.theTransportResult)
.setNextAction(
if (node.theNextAction != null) {
node.theNextAction
} else {
node.reportGraphNodes.firstOrNull()?.theAction
}
)
.setNextAction(node.theNextAction ?: node.reportGraphNodes.firstOrNull()?.theAction)
.setCreatedAt(graph.node.createdAt.plusMinutes(1))

if (node.receiver != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,128 @@ class SubmissionFunctionIntegrationTests {

@Test
fun `it should return a history for partially delivered submission`() {
val submittedReport = reportGraph {
topic(Topic.FULL_ELR)
format(MimeFormat.HL7)
sender(UniversalPipelineTestUtils.hl7Sender)

submission {
action(TaskAction.receive)
reportGraphNode {
action(TaskAction.convert)
log(ActionLog(InvalidParamMessage("log"), type = ActionLogLevel.warning))
reportGraphNode {
action(TaskAction.destination_filter)
reportGraphNode {
action(TaskAction.none)
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[1])
itemCount(0)
}
}
reportGraphNode {
action(TaskAction.destination_filter)
reportGraphNode {
action(TaskAction.receiver_filter)
reportGraphNode {
action(TaskAction.translate)
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[0])
reportGraphNode {
action(TaskAction.send)
transportResult("Success")
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[0])
}
}
}
reportGraphNode {
action(TaskAction.receiver_filter)
reportGraphNode {
action(TaskAction.none)
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[1])
itemCount(0)
}
}
}
}
}
}.generate(ReportStreamTestDatabaseContainer.testDatabaseAccess)

val httpRequestMessage = MockHttpRequestMessage()

val func = setupSubmissionFunction()

val history = func
.getReportDetailedHistory(httpRequestMessage, submittedReport.node.reportId.toString())
assertThat(history).isNotNull()
val historyNode = JacksonMapperUtilities.defaultMapper.readTree(history.body.toString())
assertThat(
historyNode.get("overallStatus").asText()
).isEqualTo(DetailedSubmissionHistory.Status.PARTIALLY_DELIVERED.toString())
assertThat(historyNode.get("destinations").size()).isEqualTo(2)
assertThat(historyNode.get("errors").size()).isEqualTo(0)
assertThat(historyNode.get("warnings").size()).isEqualTo(1)
}

// this test remains to prevent breaking queries against old submissions that used the legacy route step
@Test
fun `it should return a history for an partially delivered submission (for legacy route step)`() {
val submittedReport = reportGraph {
topic(Topic.FULL_ELR)
format(MimeFormat.HL7)
sender(UniversalPipelineTestUtils.hl7Sender)

submission {
action(TaskAction.receive)
reportGraphNode {
action(TaskAction.convert)
log(ActionLog(InvalidParamMessage("log"), type = ActionLogLevel.warning))
reportGraphNode {
action(TaskAction.route)
reportGraphNode {
action(TaskAction.none)
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[1])
itemCount(0)
}
}
reportGraphNode {
action(TaskAction.route)
reportGraphNode {
action(TaskAction.translate)
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[0])
reportGraphNode {
action(TaskAction.send)
transportResult("Success")
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[0])
}
}
reportGraphNode {
action(TaskAction.none)
receiver(UniversalPipelineTestUtils.universalPipelineOrganization.receivers[1])
itemCount(0)
}
}
}
}
}.generate(ReportStreamTestDatabaseContainer.testDatabaseAccess)

val httpRequestMessage = MockHttpRequestMessage()

val func = setupSubmissionFunction()

val history = func
.getReportDetailedHistory(httpRequestMessage, submittedReport.node.reportId.toString())
assertThat(history).isNotNull()
val historyNode = JacksonMapperUtilities.defaultMapper.readTree(history.body.toString())
assertThat(
historyNode.get("overallStatus").asText()
).isEqualTo(DetailedSubmissionHistory.Status.PARTIALLY_DELIVERED.toString())
assertThat(historyNode.get("destinations").size()).isEqualTo(2)
assertThat(historyNode.get("errors").size()).isEqualTo(0)
assertThat(historyNode.get("warnings").size()).isEqualTo(1)
}

// TODO: https://github.com/CDCgov/prime-reportstream/issues/16054
@Test
fun `it should return a history for an in-flight submission`() {
val submittedReport = reportGraph {
topic(Topic.FULL_ELR)
format(MimeFormat.HL7)
Expand Down Expand Up @@ -126,15 +248,16 @@ class SubmissionFunctionIntegrationTests {
val historyNode = JacksonMapperUtilities.defaultMapper.readTree(history.body.toString())
assertThat(
historyNode.get("overallStatus").asText()
).isEqualTo(DetailedSubmissionHistory.Status.PARTIALLY_DELIVERED.toString())
).isEqualTo(DetailedSubmissionHistory.Status.PARTIALLY_DELIVERED.toString()) // TODO: should be RECEIVED
assertThat(historyNode.get("destinations").size()).isEqualTo(2)
assertThat(historyNode.get("errors").size()).isEqualTo(0)
assertThat(historyNode.get("warnings").size()).isEqualTo(1)
}

// TODO: https://github.com/CDCgov/prime-reportstream/issues/16054
// this test remains to prevent breaking queries against old submissions that used the legacy route step
@Test
fun `it should return a history for partially delivered submission (for legacy route step)`() {
fun `it should return a history for an in-flight submission (for legacy route step)`() {
val submittedReport = reportGraph {
topic(Topic.FULL_ELR)
format(MimeFormat.HL7)
Expand Down Expand Up @@ -184,7 +307,7 @@ class SubmissionFunctionIntegrationTests {
val historyNode = JacksonMapperUtilities.defaultMapper.readTree(history.body.toString())
assertThat(
historyNode.get("overallStatus").asText()
).isEqualTo(DetailedSubmissionHistory.Status.PARTIALLY_DELIVERED.toString())
).isEqualTo(DetailedSubmissionHistory.Status.PARTIALLY_DELIVERED.toString()) // TODO: should be RECEIVED
assertThat(historyNode.get("destinations").size()).isEqualTo(2)
assertThat(historyNode.get("errors").size()).isEqualTo(0)
assertThat(historyNode.get("warnings").size()).isEqualTo(1)
Expand Down

0 comments on commit 5a90362

Please sign in to comment.