Search in sources :

Example 6 with StockCardTemplateDto

use of org.openlmis.stockmanagement.dto.StockCardTemplateDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateServiceTest method shouldGetDefaultStockCardTemplate.

@Test
public void shouldGetDefaultStockCardTemplate() {
    // when
    StockCardTemplateDto template = stockCardTemplateService.getDefaultStockCardTemplate();
    // then:
    assertThat(template.getStockCardFields().size(), is(4));
    assertThat(template.getStockCardLineItemFields().size(), is(5));
    assertThat(template.getStockCardFields().get(0).getName(), is("packSize"));
    assertThat(template.getStockCardLineItemFields().get(0).getName(), is("documentNumber"));
}
Also used : StockCardTemplateDto(org.openlmis.stockmanagement.dto.StockCardTemplateDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with StockCardTemplateDto

use of org.openlmis.stockmanagement.dto.StockCardTemplateDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateServiceTest method shouldNotSaveTemplateWithUnavailableField.

@Test(expected = ValidationMessageException.class)
public void shouldNotSaveTemplateWithUnavailableField() {
    // given
    StockCardTemplateDto templateDto = createTemplateDto();
    templateDto.getStockCardFields().add(new StockCardFieldDto("i do not exist", false, 1));
    // when
    stockCardTemplateService.saveOrUpdate(templateDto);
}
Also used : StockCardTemplateDto(org.openlmis.stockmanagement.dto.StockCardTemplateDto) StockCardFieldDto(org.openlmis.stockmanagement.dto.StockCardFieldDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with StockCardTemplateDto

use of org.openlmis.stockmanagement.dto.StockCardTemplateDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateServiceTest method shouldNotSaveTemplateWithNonExistingProgramAndFacilityType.

@Test(expected = ValidationMessageException.class)
public void shouldNotSaveTemplateWithNonExistingProgramAndFacilityType() {
    // given: program and facility can not be found in ref data service
    doThrow(new ValidationMessageException("errorKey")).when(programFacilityTypeExistenceService).checkProgramAndFacilityTypeExist(any(UUID.class), any(UUID.class));
    StockCardTemplateDto templateDto = createTemplateDto();
    // when
    stockCardTemplateService.saveOrUpdate(templateDto);
}
Also used : StockCardTemplateDto(org.openlmis.stockmanagement.dto.StockCardTemplateDto) ValidationMessageException(org.openlmis.stockmanagement.exception.ValidationMessageException) UUID(java.util.UUID) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with StockCardTemplateDto

use of org.openlmis.stockmanagement.dto.StockCardTemplateDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateServiceTest method shouldThrowValidationExceptionWhenProgramIdMissing.

@Test(expected = ValidationMessageException.class)
public void shouldThrowValidationExceptionWhenProgramIdMissing() throws Exception {
    StockCardTemplateDto templateDto = createTemplateDto();
    templateDto.setProgramId(null);
    // when
    stockCardTemplateService.saveOrUpdate(templateDto);
}
Also used : StockCardTemplateDto(org.openlmis.stockmanagement.dto.StockCardTemplateDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with StockCardTemplateDto

use of org.openlmis.stockmanagement.dto.StockCardTemplateDto in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateServiceTest method shouldThrowValidationExceptionWhenFacilityTypeIdMissing.

@Test(expected = ValidationMessageException.class)
public void shouldThrowValidationExceptionWhenFacilityTypeIdMissing() throws Exception {
    StockCardTemplateDto templateDto = createTemplateDto();
    templateDto.setFacilityTypeId(null);
    // when
    stockCardTemplateService.saveOrUpdate(templateDto);
}
Also used : StockCardTemplateDto(org.openlmis.stockmanagement.dto.StockCardTemplateDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

StockCardTemplateDto (org.openlmis.stockmanagement.dto.StockCardTemplateDto)12 Test (org.junit.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 StockCardFieldDto (org.openlmis.stockmanagement.dto.StockCardFieldDto)5 StockCardLineItemFieldDto (org.openlmis.stockmanagement.dto.StockCardLineItemFieldDto)3 UUID (java.util.UUID)2 ValidationMessageException (org.openlmis.stockmanagement.exception.ValidationMessageException)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1