use of org.openlmis.stockmanagement.util.RequestParameters in project openlmis-stockmanagement by OpenLMIS.
the class ApprovedProductReferenceDataServiceTest method shouldReturnFullMapOfOrderableFulfills.
@Test
public void shouldReturnFullMapOfOrderableFulfills() {
UUID programId = randomUUID();
RequestParameters parameters = RequestParameters.init();
parameters.set("programId", programId);
ApprovedProductDto approvedProduct = generateInstance();
UUID facilityId = randomUUID();
mockPageResponseEntity(approvedProduct);
Page<OrderableDto> result = service.getApprovedProducts(facilityId, programId, null);
assertEquals(1, result.getTotalElements());
assertEquals(approvedProduct.getOrderable(), result.getContent().get(0));
verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), refEq(new DynamicPageTypeReference<>(ApprovedProductDto.class)));
URI uri = uriCaptor.getValue();
assertThat(uri.toString(), not(containsString("orderableId")));
assertAuthHeader(entityCaptor.getValue());
assertNull(entityCaptor.getValue().getBody());
}
use of org.openlmis.stockmanagement.util.RequestParameters in project openlmis-stockmanagement by OpenLMIS.
the class ApprovedProductReferenceDataServiceTest method shouldReturnMapOfOrderableFulfillsForGivenOrderables.
@Test
public void shouldReturnMapOfOrderableFulfillsForGivenOrderables() {
UUID programId = randomUUID();
List<UUID> orderableIds = asList(randomUUID(), randomUUID());
RequestParameters parameters = RequestParameters.init();
parameters.set("programId", programId);
parameters.set("orderableId", orderableIds);
ApprovedProductDto approvedProduct = generateInstance();
UUID facilityId = randomUUID();
mockPageResponseEntity(approvedProduct);
Page<OrderableDto> result = service.getApprovedProducts(facilityId, programId, orderableIds);
assertEquals(1, result.getTotalElements());
assertEquals(approvedProduct.getOrderable(), result.getContent().get(0));
verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), refEq(new DynamicPageTypeReference<>(ApprovedProductDto.class)));
URI uri = uriCaptor.getValue();
assertThat(uri.toString(), containsString("orderableId=" + orderableIds.get(0)));
assertThat(uri.toString(), containsString("orderableId=" + orderableIds.get(1)));
assertAuthHeader(entityCaptor.getValue());
assertNull(entityCaptor.getValue().getBody());
}
Aggregations