Search in sources :

Example 21 with OrderableDto

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());
}
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 22 with OrderableDto

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());
}
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 23 with OrderableDto

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

Aggregations

OrderableDto (org.openlmis.stockmanagement.dto.referencedata.OrderableDto)23 UUID (java.util.UUID)16 Test (org.junit.Test)16 UUID.randomUUID (java.util.UUID.randomUUID)8 LotDto (org.openlmis.stockmanagement.dto.referencedata.LotDto)6 StockCard (org.openlmis.stockmanagement.domain.card.StockCard)5 VvmApplicable (org.openlmis.stockmanagement.domain.common.VvmApplicable)5 StockCardDto (org.openlmis.stockmanagement.dto.StockCardDto)5 URI (java.net.URI)4 StockEventProcessContext (org.openlmis.stockmanagement.util.StockEventProcessContext)4 List (java.util.List)3 OrderableLotIdentity (org.openlmis.stockmanagement.domain.identity.OrderableLotIdentity)3 StockEventDto (org.openlmis.stockmanagement.dto.StockEventDto)3 ApprovedProductDto (org.openlmis.stockmanagement.dto.referencedata.ApprovedProductDto)3 FacilityDto (org.openlmis.stockmanagement.dto.referencedata.FacilityDto)3 ProgramDto (org.openlmis.stockmanagement.dto.referencedata.ProgramDto)3 DynamicPageTypeReference (org.openlmis.stockmanagement.util.DynamicPageTypeReference)3 Map (java.util.Map)2 UUID.fromString (java.util.UUID.fromString)2 StockEvent (org.openlmis.stockmanagement.domain.event.StockEvent)2