use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto 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.dto.referencedata.OrderableDto 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());
}
use of org.openlmis.stockmanagement.dto.referencedata.OrderableDto in project openlmis-stockmanagement by OpenLMIS.
the class OrderableReferenceDataServiceTest method shouldReturnOrderables.
@Test
public void shouldReturnOrderables() {
OrderableDto product = mockPageResponseEntityAndGetDto();
List<OrderableDto> response = service.findAll();
assertThat(response, hasSize(1));
assertThat(response, hasItem(product));
verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), refEq(new DynamicPageTypeReference<>(OrderableDto.class)));
URI uri = uriCaptor.getValue();
assertEquals(serviceUrl + service.getUrl(), uri.toString());
assertAuthHeader(entityCaptor.getValue());
assertNull(entityCaptor.getValue().getBody());
}
Aggregations