use of org.sagebionetworks.bridge.models.crc.gbf.external.ShippingConfirmations in project BridgeServer2 by Sage-Bionetworks.
the class CRCController method getLabShipmentConfirmations.
// Waiting for integration workflow to be finalized
// @GetMapping(path = "v1/cuimc/participants/labshipments/confirmations")
public ShippingConfirmations getLabShipmentConfirmations(@RequestParam String startDate, @RequestParam String endDate) throws JsonProcessingException {
httpBasicAuthentication();
LocalDate startDateObj = getLocalDateOrDefault(startDate, null);
LocalDate endDateObj = getLocalDateOrDefault(endDate, null);
ShippingConfirmations shippingConfirmations = gbfOrderService.requestShippingConfirmations(startDateObj, endDateObj);
return shippingConfirmations;
}
use of org.sagebionetworks.bridge.models.crc.gbf.external.ShippingConfirmations in project BridgeServer2 by Sage-Bionetworks.
the class GBFOrderServiceTest method getShippingConfirmations.
@Test
public void getShippingConfirmations() throws IOException {
ShippingConfirmation shippingConfirmation1 = new ShippingConfirmation();
shippingConfirmation1.OrderNumber = "1";
ShippingConfirmation.Item item1a = new ShippingConfirmation.Item();
item1a.ItemNumber = "Item 1a";
shippingConfirmation1.Item = Lists.newArrayList(item1a);
ShippingConfirmation shippingConfirmation2 = new ShippingConfirmation();
shippingConfirmation1.OrderNumber = "2";
ShippingConfirmation.Item item2a = new ShippingConfirmation.Item();
item2a.ItemNumber = "Item 2a";
shippingConfirmation2.Item = Lists.newArrayList(item2a);
ShippingConfirmations shippingConfirmations = new ShippingConfirmations();
shippingConfirmations.shippingConfirmation = Lists.newArrayList(shippingConfirmation1, shippingConfirmation2);
ConfirmShippingResponse confirmShippingResponse = new ConfirmShippingResponse(xmlMapper.writeValueAsString(shippingConfirmations));
HttpEntity mockEntity = mock(HttpEntity.class);
doReturn(IOUtils.toInputStream(jsonMapper.writeValueAsString(confirmShippingResponse), UTF_8)).when(mockEntity).getContent();
StatusLine mockStatusLine = mock(StatusLine.class);
doReturn(200).when(mockStatusLine).getStatusCode();
HttpResponse mockResponse = mock(HttpResponse.class);
doReturn(mockStatusLine).when(mockResponse).getStatusLine();
doReturn(mockEntity).when(mockResponse).getEntity();
ArgumentCaptor<ConfirmShippingRequest> confirmShippingRequestArgumentCaptor = ArgumentCaptor.forClass(ConfirmShippingRequest.class);
doReturn(mockResponse).when(service).postJson(eq(CONFIRMATION_URL), any(), confirmShippingRequestArgumentCaptor.capture());
LocalDate startDate = LocalDate.now().minusDays(20);
LocalDate endDate = LocalDate.now().plusDays(3);
ShippingConfirmations shippingConfirmationsResult = service.requestShippingConfirmations(startDate, endDate);
assertEquals(shippingConfirmation1, shippingConfirmationsResult.shippingConfirmation.get(0));
assertEquals(shippingConfirmation2, shippingConfirmationsResult.shippingConfirmation.get(1));
ConfirmShippingRequest confirmShippingRequest = confirmShippingRequestArgumentCaptor.getValue();
assertEquals(startDate, confirmShippingRequest.startDate);
assertEquals(endDate, confirmShippingRequest.endDate);
verify(service).handleGbfHttpStatusErrors(any());
verify(service).postJson(eq(CONFIRMATION_URL), any(), any());
}
use of org.sagebionetworks.bridge.models.crc.gbf.external.ShippingConfirmations in project BridgeServer2 by Sage-Bionetworks.
the class CRCControllerTest method getShippingConfirmation.
@Test
public void getShippingConfirmation() throws Exception {
when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
when(mockAccountService.authenticate(any(), any())).thenReturn(account);
when(mockAccountService.getAccount(ACCOUNT_ID)).thenReturn(Optional.of(account));
LocalDate startDate = LocalDate.now().minusDays(10);
LocalDate endDate = LocalDate.now();
ShippingConfirmations shippingConfirmations = mock(ShippingConfirmations.class);
when(mockGBFOrderService.requestShippingConfirmations(eq(startDate), eq(endDate))).thenReturn(shippingConfirmations);
controller.getLabShipmentConfirmations(startDate.toString(), endDate.toString());
verify(mockRequest).getHeader(AUTHORIZATION);
verify(mockAccountService).authenticate(any(), any());
verify(mockGBFOrderService).requestShippingConfirmations(eq(startDate), eq(endDate));
}
Aggregations