use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryServiceTest method shouldLeavePreviousSohAsNullWhenSubmitPhysicalInventoryIfNoStockCardFound.
@Test
public void shouldLeavePreviousSohAsNullWhenSubmitPhysicalInventoryIfNoStockCardFound() throws Exception {
PhysicalInventoryDto physicalInventoryDto = newInventoryForSubmit();
when(stockCardRepository.findByProgramIdAndFacilityIdAndOrderableIdAndLotId(physicalInventoryDto.getProgramId(), physicalInventoryDto.getFacilityId(), lineItemDto.getOrderableId(), lineItemDto.getLotId())).thenReturn(null);
physicalInventoryService.submitPhysicalInventory(physicalInventoryDto, UUID.randomUUID());
verify(physicalInventoryRepository, times(1)).save(inventoryArgumentCaptor.capture());
verify(stockCard, never()).shallowCopy();
verifyPhysicalInventorySavedWithoutSohAndAsDraft();
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryControllerIntegrationTest method generateDraft.
private PhysicalInventoryDto generateDraft() {
PhysicalInventoryDto inventory = new PhysicalInventoryDto();
inventory.setFacilityId(UUID.randomUUID());
inventory.setProgramId(UUID.randomUUID());
return inventory;
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryControllerIntegrationTest method shouldGetChosenDraftWhenExists.
// GET /api/physicalInventories
@Test
public void shouldGetChosenDraftWhenExists() {
// given
PhysicalInventoryDto expectedDraft = generatePhysicalInventory();
UUID programId = expectedDraft.getProgramId();
UUID facilityId = expectedDraft.getFacilityId();
when(physicalInventoryService.findPhysicalInventory(programId, facilityId, true)).thenReturn(Collections.singletonList(expectedDraft));
// when
List resultCollection = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).queryParam(PROGRAM_PARAM, programId).queryParam(FACILITY_PARAM, facilityId).queryParam("isDraft", true).when().get(RESOURCE_URL).then().statusCode(200).extract().as(List.class);
// then
assertEquals(1, resultCollection.size());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryControllerIntegrationTest method shouldReturnBadRequestOnCreateEmptyDraftWhenEntityInvalid.
@Test
public void shouldReturnBadRequestOnCreateEmptyDraftWhenEntityInvalid() {
// given
PhysicalInventoryDto expectedDraft = generateDraft();
when(physicalInventoryService.createNewDraft(expectedDraft)).thenThrow(new ValidationMessageException(ERROR_PROGRAM_ID_MISSING));
// when
restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON).body(expectedDraft).when().post(RESOURCE_URL).then().statusCode(400);
// then
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryControllerIntegrationTest method shouldReturnOnePhysicalInventory.
// GET /api/physicalInventories/{id}
@Test
public void shouldReturnOnePhysicalInventory() {
// given
PhysicalInventoryDto expectedInventory = generatePhysicalInventory();
UUID piId = UUID.randomUUID();
when(physicalInventoriesRepository.findOne(piId)).thenReturn(expectedInventory.toPhysicalInventoryForDraft());
// when
PhysicalInventoryDto response = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).pathParam("id", piId).when().get(ID_URL).then().statusCode(200).extract().as(expectedInventory.getClass());
// then
assertEquals(expectedInventory.getId(), response.getId());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
Aggregations