Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Merge pull request #560 from CDCgov/story/491_test_refactoring
Browse files Browse the repository at this point in the history
Story/491 test refactoring
  • Loading branch information
tjohnson7021 authored Oct 6, 2023
2 parents 24986be + 8d053e4 commit 1622aca
Showing 1 changed file with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,44 @@ class OrderTest extends Specification {

def "check that contact info is added to order before sending to report stream"() {
when:
def response = orderClient.submit(labOrderJsonFileString, true)
orderClient.submit(labOrderJsonFileString, true)
def sentPayload = SentPayloadReader.read()
def parsedSentPayload = JsonParsing.parse(sentPayload)
def parsedLabOrderJsonFile = JsonParsing.parse(labOrderJsonFileString)

then:
response.getCode() == 200

//test that the MessageHeader's event is now an OML_O21
parsedSentPayload.entry[0].resource.resourceType == "MessageHeader"
parsedSentPayload.entry[0].resource.eventCoding.code == "O21"
parsedSentPayload.entry[0].resource.eventCoding.display.contains("OML")
parsedSentPayload.entry[24].resource.contact.name.text.contains("SADIE S SMITH")
}

def "check that the rest of the message is unchanged except the parts we changed"() {
when:
orderClient.submit(labOrderJsonFileString, true)
def sentPayload = SentPayloadReader.read()
def parsedSentPayload = JsonParsing.parse(sentPayload)
def parsedLabOrderJsonFile = JsonParsing.parse(labOrderJsonFileString)

//test that everything else is the same except the MessageHeader's event
then:
//test that everything else is the same except the MessageHeader's event and Patient contact
parsedSentPayload.entry[0].resource.remove("eventCoding")
parsedLabOrderJsonFile.entry[0].resource.remove("eventCoding")
parsedSentPayload.entry[24].resource.remove("contact")

parsedSentPayload == parsedLabOrderJsonFile
}

def "check that message type is converted to OML_O21"() {
when:
orderClient.submit(labOrderJsonFileString, true)
def sentPayload = SentPayloadReader.read()
def parsedSentPayload = JsonParsing.parse(sentPayload)


then:
//test that the MessageHeader's event is now an OML_O21
parsedSentPayload.entry[0].resource.resourceType == "MessageHeader"
parsedSentPayload.entry[0].resource.eventCoding.code == "O21"
parsedSentPayload.entry[0].resource.eventCoding.display.contains("OML")
}

def "return a 400 response when request has unexpected format"() {
given:
def invalidJsonRequest = labOrderJsonFileString.substring(1)
Expand Down

0 comments on commit 1622aca

Please sign in to comment.