Search in sources :

Example 1 with AvailableStockCardFields

use of org.openlmis.stockmanagement.domain.template.AvailableStockCardFields in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplatesRepositoryIntegrationTest method shouldSearchForStockCardTemplateByFacilityTypeAndProgram.

@Test
public void shouldSearchForStockCardTemplateByFacilityTypeAndProgram() throws Exception {
    // given
    StockCardTemplate template = createTemplate();
    stockCardTemplatesRepository.save(template);
    // when
    StockCardTemplate found = stockCardTemplatesRepository.findByProgramIdAndFacilityTypeId(template.getProgramId(), template.getFacilityTypeId());
    // then
    AvailableStockCardFields packSize = found.getStockCardFields().get(0).getAvailableStockCardFields();
    AvailableStockCardLineItemFields docNumber = found.getStockCardLineItemFields().get(0).getAvailableStockCardLineItemFields();
    assertThat(packSize.getName(), is("packSize"));
    assertThat(docNumber.getName(), is("documentNumber"));
}
Also used : StockCardTemplate(org.openlmis.stockmanagement.domain.template.StockCardTemplate) AvailableStockCardFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardFields) AvailableStockCardLineItemFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardLineItemFields) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 2 with AvailableStockCardFields

use of org.openlmis.stockmanagement.domain.template.AvailableStockCardFields in project openlmis-stockmanagement by OpenLMIS.

the class StockCardFieldDto method toModel.

/**
 * Convert to DB model object.
 *
 * @param template   the template that this filed belongs to.
 * @param cardFields all available fields.
 * @return DB model object.
 */
StockCardFields toModel(StockCardTemplate template, List<AvailableStockCardFields> cardFields) {
    StockCardFields stockCardFields = new StockCardFields();
    stockCardFields.setStockCardTemplate(template);
    stockCardFields.setIsDisplayed(isDisplayed);
    stockCardFields.setDisplayOrder(displayOrder);
    stockCardFields.setAvailableStockCardFields(matchByName(cardFields));
    return stockCardFields;
}
Also used : AvailableStockCardFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardFields) StockCardFields(org.openlmis.stockmanagement.domain.template.StockCardFields)

Example 3 with AvailableStockCardFields

use of org.openlmis.stockmanagement.domain.template.AvailableStockCardFields in project openlmis-stockmanagement by OpenLMIS.

the class StockCardTemplateDataBuilder method createTemplate.

/**
 * Create test object for stock card template.
 *
 * @return created object.
 */
public static StockCardTemplate createTemplate() {
    StockCardTemplate template = new StockCardTemplate();
    template.setFacilityTypeId(UUID.randomUUID());
    template.setProgramId(UUID.randomUUID());
    AvailableStockCardFields packSize = new AvailableStockCardFields();
    packSize.setId(UUID.fromString("7663b4d2-d6da-11e6-bf26-cec0c932ce01"));
    AvailableStockCardLineItemFields docNumber = new AvailableStockCardLineItemFields();
    docNumber.setId(UUID.fromString("b15ad020-d6da-11e6-bf26-cec0c932ce01"));
    template.getStockCardFields().add(new StockCardFields(template, packSize, true, 123));
    template.getStockCardLineItemFields().add(new StockCardLineItemFields(template, docNumber, true, 456));
    return template;
}
Also used : StockCardTemplate(org.openlmis.stockmanagement.domain.template.StockCardTemplate) StockCardLineItemFields(org.openlmis.stockmanagement.domain.template.StockCardLineItemFields) AvailableStockCardLineItemFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardLineItemFields) AvailableStockCardFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardFields) AvailableStockCardLineItemFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardLineItemFields) AvailableStockCardFields(org.openlmis.stockmanagement.domain.template.AvailableStockCardFields) StockCardFields(org.openlmis.stockmanagement.domain.template.StockCardFields)

Aggregations

AvailableStockCardFields (org.openlmis.stockmanagement.domain.template.AvailableStockCardFields)3 AvailableStockCardLineItemFields (org.openlmis.stockmanagement.domain.template.AvailableStockCardLineItemFields)2 StockCardFields (org.openlmis.stockmanagement.domain.template.StockCardFields)2 StockCardTemplate (org.openlmis.stockmanagement.domain.template.StockCardTemplate)2 Test (org.junit.Test)1 StockCardLineItemFields (org.openlmis.stockmanagement.domain.template.StockCardLineItemFields)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1