Skip to content

Commit

Permalink
Results Endpoint Skeleton (#800)
Browse files Browse the repository at this point in the history
* results endpoint skeleton

* unit test

* edit comments
  • Loading branch information
jorg3lopez authored Jan 24, 2024
1 parent f6e03de commit dea5403
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ public class EtorDomainRegistration implements DomainConnector {
static final String DEMOGRAPHICS_API_ENDPOINT = "/v1/etor/demographics";
static final String ORDERS_API_ENDPOINT = "/v1/etor/orders";
static final String METADATA_API_ENDPOINT = "/v1/etor/metadata/{id}";
static final String RESULTS_API_ENDPOINT = "/v1/etor/results";

@Inject PatientDemographicsController patientDemographicsController;
@Inject OrderController orderController;
@Inject ConvertAndSendDemographicsUsecase convertAndSendDemographicsUsecase;
@Inject SendOrderUseCase sendOrderUseCase;

// @Inject ResultController resultController

// @Inject SendResultUseCase sendResultUseCase

@Inject Logger logger;
@Inject DomainResponseHelper domainResponseHelper;
@Inject PartnerMetadataOrchestrator partnerMetadataOrchestrator;
Expand Down Expand Up @@ -220,4 +226,18 @@ DomainResponse handleMetadata(DomainRequest request) {
return domainResponseHelper.constructErrorResponse(500, errorMessage);
}
}

public DomainResponse handleResults(DomainRequest request) {

// Get the result
// Result<?> result
// resultController.parseResults(request)
// sendResultUseCase/ sendOrderUseCase? change name for reuse?

// ResultResponse resultResponse = new ResultResponse(results)
// return domainResponseHelper.constructOkResponse(resultResponse)

logger.logInfo(request.getHeaders().toString());
return new DomainResponse(200);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class EtorDomainRegistrationTest extends Specification {
def setup() {
TestApplicationContext.reset()
TestApplicationContext.init()
TestApplicationContext.injectRegisteredImplementations()
}

def "domain registration has endpoints"() {
Expand All @@ -41,6 +42,7 @@ class EtorDomainRegistrationTest extends Specification {
def demographicsEndpoint = new HttpEndpoint("POST", EtorDomainRegistration.DEMOGRAPHICS_API_ENDPOINT, true)
def ordersEndpoint = new HttpEndpoint("POST", EtorDomainRegistration.ORDERS_API_ENDPOINT, true)
def metadataEndpoint = new HttpEndpoint("GET", EtorDomainRegistration.METADATA_API_ENDPOINT, true)
def resultsEndpoint = new HttpEndpoint("POST", EtorDomainRegistration.RESULTS_API_ENDPOINT, true)

when:
def endpoints = domainRegistration.domainRegistration()
Expand Down Expand Up @@ -448,4 +450,22 @@ class EtorDomainRegistrationTest extends Specification {
then:
actualStatusCode == expectedStatusCode
}

def "results endpoint happy path"() {
given:
def expectedStatusCode = 200

def request = new DomainRequest()
request.headers["recordid"] = "recordId"

def connector = new EtorDomainRegistration()
TestApplicationContext.register(EtorDomainRegistration, connector)
TestApplicationContext.injectRegisteredImplementations()

when:
def res = connector.handleResults(request)
def actualStatusCode = res.getStatusCode()
then:
actualStatusCode == expectedStatusCode
}
}

0 comments on commit dea5403

Please sign in to comment.