Search in sources :

Example 6 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property in project kie-wb-common by kiegroup.

the class DOM2PersistenceDescriptorVisitor method visitProperties.

private void visitProperties(PersistenceUnitModel persistenceUnit, NodeList nodes) {
    List<Property> properties = new ArrayList<Property>();
    persistenceUnit.setProperties(properties);
    if (nodes != null && nodes.getLength() > 0) {
        Element element = (Element) nodes.item(0);
        NodeList propertyNodes = element.getElementsByTagName(PersistenceDescriptorXMLMarshaller.PROPERTY);
        if (propertyNodes != null && propertyNodes.getLength() > 0) {
            for (int i = 0; i < propertyNodes.getLength(); i++) {
                visitProperty(properties, (Element) propertyNodes.item(i));
            }
        }
    }
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property)

Example 7 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property in project kie-wb-common by kiegroup.

the class DOM2PersistenceDescriptorVisitor method visitProperty.

private void visitProperty(List<Property> properties, Element item) {
    Property property = new Property(item.getAttribute(PersistenceDescriptorXMLMarshaller.NAME), item.getAttribute(PersistenceDescriptorXMLMarshaller.VALUE));
    properties.add(property);
}
Also used : Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property)

Example 8 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property in project kie-wb-common by kiegroup.

the class PersistencePresenterTest method testAddProperty.

@Test
public void testAddProperty() {
    final Property property = new Property("Name", "Value");
    persistencePresenter.add(property);
    verify(propertiesListPresenter).add(eq(property));
    verify(persistencePresenter).fireChangeEvent();
}
Also used : Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property) Test(org.junit.Test)

Example 9 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property in project kie-wb-common by kiegroup.

the class PropertiesItemPresenterTest method testSetup.

@Test
public void testSetup() {
    propertiesItemPresenter.setup(new Property("Name", "Value"), mock(PersistencePresenter.class));
    verify(view).init(eq(propertiesItemPresenter));
    verify(view).setName(eq("Name"));
    verify(view).setValue(eq("Value"));
}
Also used : Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property) PersistencePresenter(org.kie.workbench.common.screens.library.client.settings.persistence.PersistencePresenter) Test(org.junit.Test)

Example 10 with Property

use of org.kie.workbench.common.screens.datamodeller.model.persistence.Property in project kie-wb-common by kiegroup.

the class PersistenceDescriptorValidatorTest method testValidatePropertyWithMissingName.

@Test
public void testValidatePropertyWithMissingName() {
    // add a property with no name
    descriptor.getPersistenceUnit().addProperty(new Property(null, "someValue"));
    List<ValidationMessage> result = validator.validate(path, descriptor);
    ValidationMessage expectedMessage;
    // validation for the property with missing name should fail.
    expectedMessage = newErrorMessage(PersistenceDescriptorValidationMessages.INDEXED_PROPERTY_NAME_EMPTY_ID, MessageFormat.format(PersistenceDescriptorValidationMessages.INDEXED_PROPERTY_NAME_EMPTY, "3"), "3");
    assertTrue(result.contains(expectedMessage));
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) Property(org.kie.workbench.common.screens.datamodeller.model.persistence.Property) Test(org.junit.Test)

Aggregations

Property (org.kie.workbench.common.screens.datamodeller.model.persistence.Property)11 Test (org.junit.Test)4 PersistenceDescriptorModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)3 PersistenceUnitModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel)3 ArrayList (java.util.ArrayList)2 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)2 Element (org.w3c.dom.Element)2 PersistencePresenter (org.kie.workbench.common.screens.library.client.settings.persistence.PersistencePresenter)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 NodeList (org.w3c.dom.NodeList)1