use of org.sagebionetworks.bridge.spring.controllers.CRCController.SHIPMENT_REPORT in project BridgeServer2 by Sage-Bionetworks.
the class CRCControllerTest method placeOrderForHealthCode.
@Test
public void placeOrderForHealthCode() {
when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
when(mockAccountService.authenticate(any(), any())).thenReturn(account);
setupShippingAddress();
ArgumentCaptor<AccountId> accountIdCaptor = ArgumentCaptor.forClass(AccountId.class);
when(mockAccountService.getAccount(accountIdCaptor.capture())).thenReturn(Optional.of(account));
DateRangeResourceList<? extends ReportData> results = new DateRangeResourceList<>(ImmutableList.of());
doReturn(results).when(mockReportService).getParticipantReport(APP_ID, TEST_USER_ID, SHIPMENT_REPORT, HEALTH_CODE, JAN1, JAN2);
controller.postLabShipmentRequest("healthcode:" + HEALTH_CODE);
verify(mockAccountService).authenticate(any(), any());
verify(mockAccountService, atLeastOnce()).getAccount(accountIdCaptor.capture());
assertTrue(accountIdCaptor.getAllValues().stream().anyMatch(accountId -> accountId.getHealthCode().equals(HEALTH_CODE)));
verify(mockReportService).saveParticipantReport(eq(APP_ID), eq(TEST_USER_ID), eq(SHIPMENT_REPORT), eq(HEALTH_CODE), reportCaptor.capture());
verify(controller).internalLabShipmentRequest(any(), any());
ReportData capturedReport = reportCaptor.getValue();
String orderId = capturedReport.getData().get(SHIPMENT_REPORT_KEY_ORDER_ID).asText();
assertTrue(orderId.startsWith(ACCOUNT_ID.getId()));
}
Aggregations