Skip to content

Commit

Permalink
Add unit tests about metadata in the SendOrderUsecase
Browse files Browse the repository at this point in the history
  • Loading branch information
halprin committed Nov 3, 2023
1 parent b699da7 commit 7e18a90
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gov.hhs.cdc.trustedintermediary.etor.orders

import gov.hhs.cdc.trustedintermediary.OrderMock
import gov.hhs.cdc.trustedintermediary.context.TestApplicationContext
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetaDataStep
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetaData
import spock.lang.Specification

Expand Down Expand Up @@ -32,6 +33,32 @@ class SendOrderUsecaseTest extends Specification {
1 * mockSender.sendOrder(_)
}

def "metadata is registered for converting to OML"() {
given:
TestApplicationContext.register(OrderConverter, Mock(OrderConverter))
TestApplicationContext.register(OrderSender, Mock(OrderSender))
TestApplicationContext.injectRegisteredImplementations()

when:
SendOrderUseCase.getInstance().convertAndSend(new OrderMock(null, null, null))

then:
1 * SendOrderUseCase.getInstance().metaData.put(_, EtorMetaDataStep.ORDER_CONVERTED_TO_OML)
}

def "metadata is registered for adding the contact section to an order"() {
given:
TestApplicationContext.register(OrderConverter, Mock(OrderConverter))
TestApplicationContext.register(OrderSender, Mock(OrderSender))
TestApplicationContext.injectRegisteredImplementations()

when:
SendOrderUseCase.getInstance().convertAndSend(new OrderMock(null, null, null))

then:
1 * SendOrderUseCase.getInstance().metaData.put(_, EtorMetaDataStep.CONTACT_SECTION_ADDED_TO_PATIENT)
}

def "send fails to send"() {
given:
def mockOrder = new OrderMock(null, null, null)
Expand Down

0 comments on commit 7e18a90

Please sign in to comment.