Search in sources :

Example 6 with RequestParameters

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());
}
Also used : OrderableDto(org.openlmis.stockmanagement.dto.referencedata.OrderableDto) DynamicPageTypeReference(org.openlmis.stockmanagement.util.DynamicPageTypeReference) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) ApprovedProductDto(org.openlmis.stockmanagement.dto.referencedata.ApprovedProductDto) URI(java.net.URI) RequestParameters(org.openlmis.stockmanagement.util.RequestParameters) Test(org.junit.Test)

Example 7 with RequestParameters

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());
}
Also used : OrderableDto(org.openlmis.stockmanagement.dto.referencedata.OrderableDto) DynamicPageTypeReference(org.openlmis.stockmanagement.util.DynamicPageTypeReference) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) ApprovedProductDto(org.openlmis.stockmanagement.dto.referencedata.ApprovedProductDto) URI(java.net.URI) RequestParameters(org.openlmis.stockmanagement.util.RequestParameters) Test(org.junit.Test)

Aggregations

RequestParameters (org.openlmis.stockmanagement.util.RequestParameters)7 ApprovedProductDto (org.openlmis.stockmanagement.dto.referencedata.ApprovedProductDto)3 OrderableDto (org.openlmis.stockmanagement.dto.referencedata.OrderableDto)3 URI (java.net.URI)2 UUID (java.util.UUID)2 UUID.randomUUID (java.util.UUID.randomUUID)2 Test (org.junit.Test)2 DynamicPageTypeReference (org.openlmis.stockmanagement.util.DynamicPageTypeReference)2 HttpStatusCodeException (org.springframework.web.client.HttpStatusCodeException)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1