use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method shouldRejectWhenIdMismatch.
@Test(expected = ValidationMessageException.class)
public void shouldRejectWhenIdMismatch() {
PhysicalInventoryDto inventory = newInventory();
validator.validateDraft(inventory, randomUUID());
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method shouldRejectWhenEmptyDraftHasNoProgram.
@Test(expected = ValidationMessageException.class)
public void shouldRejectWhenEmptyDraftHasNoProgram() {
PhysicalInventoryDto physicalInventoryDto = new PhysicalInventoryDto();
physicalInventoryDto.setFacilityId(UUID.randomUUID());
validator.validateEmptyDraft(physicalInventoryDto);
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryControllerIntegrationTest method shouldCreateEmptyDraftWhenValid.
// POST /api/physicalInventories
@Test
public void shouldCreateEmptyDraftWhenValid() {
// given
PhysicalInventoryDto request = generateDraft();
PhysicalInventoryDto expectedDraft = new PhysicalInventoryDto();
expectedDraft.setProgramId(request.getProgramId());
expectedDraft.setFacilityId(request.getFacilityId());
expectedDraft.setId(UUID.randomUUID());
when(physicalInventoryService.createNewDraft(request)).thenReturn(expectedDraft);
// when
PhysicalInventoryDto result = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).contentType(APPLICATION_JSON).body(request).when().post(RESOURCE_URL).then().statusCode(201).extract().as(PhysicalInventoryDto.class);
// then
assertEquals(expectedDraft, result);
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 shouldSaveDraftWhenValid.
// PUT /api/physicalInventories/{id}
@Test
public void shouldSaveDraftWhenValid() {
// given
UUID physicalInventoryId = UUID.randomUUID();
PhysicalInventoryDto expectedDraft = generatePhysicalInventory();
when(physicalInventoryService.saveDraft(expectedDraft, physicalInventoryId)).thenReturn(expectedDraft);
// when
PhysicalInventoryDto result = restAssured.given().header(HttpHeaders.AUTHORIZATION, getTokenHeader()).pathParam("id", physicalInventoryId).contentType(APPLICATION_JSON).body(expectedDraft).when().put(ID_URL).then().statusCode(200).extract().as(PhysicalInventoryDto.class);
// then
assertEquals(expectedDraft, result);
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
use of org.openlmis.stockmanagement.dto.PhysicalInventoryDto in project openlmis-stockmanagement by OpenLMIS.
the class PhysicalInventoryValidatorTest method shouldRejectWhenLineItemHasNoOrderable.
@Test(expected = ValidationMessageException.class)
public void shouldRejectWhenLineItemHasNoOrderable() {
// given
PhysicalInventoryDto inventory = newInventory();
inventory.setLineItems(Collections.singletonList(new PhysicalInventoryLineItemDto()));
doNothing().when(vvmValidator).validate(eq(inventory.getLineItems()), anyString(), eq(false));
// when
validator.validateDraft(inventory, inventory.getId());
// then
verify(vvmValidator, atLeastOnce()).validate(eq(inventory.getLineItems()), anyString(), eq(false));
}
Aggregations