use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.
the class PersistenceDescriptorValidatorTest method createValidDescriptor.
private PersistenceDescriptorModel createValidDescriptor() {
PersistenceDescriptorModel descriptor = new PersistenceDescriptorModel();
descriptor.setVersion(VERSION);
PersistenceUnitModel unit = new PersistenceUnitModel();
descriptor.setPersistenceUnit(unit);
unit.setJtaDataSource(JTA_DATASOURCE);
unit.setName(PERSISTENCE_UNIT_NAME);
unit.setProvider(PERSISTENCE_PROVIDER);
unit.setTransactionType(TransactionType.JTA);
List<Property> properties = new ArrayList<>();
properties.add(new Property("name1", "value1"));
properties.add(new Property("name2", "value2"));
unit.setProperties(properties);
List<PersistableDataObject> classes = new ArrayList<>();
classes.add(new PersistableDataObject(PersistableClass1.class.getName()));
classes.add(new PersistableDataObject(PersistableClass2.class.getName()));
classes.add(new PersistableDataObject(PersistableClass3.class.getName()));
descriptor.getPersistenceUnit().setClasses(classes);
return descriptor;
}
use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.
the class PersistenceDescriptorValidatorTest method testValidateNonPersistableClass.
@Test
public void testValidateNonPersistableClass() {
// add a non persistable class
descriptor.getPersistenceUnit().getClasses().add(new PersistableDataObject(NonPersistableClass1.class.getName()));
List<ValidationMessage> result = validator.validate(path, descriptor);
ValidationMessage expectedMessage;
// validation for the non persistable class should fail.
expectedMessage = newErrorMessage(PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE_ID, MessageFormat.format(PersistenceDescriptorValidationMessages.CLASS_NOT_PERSISTABLE, NonPersistableClass1.class.getName()), NonPersistableClass1.class.getName());
assertTrue(result.contains(expectedMessage));
}
use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.
the class PersistenceDescriptorXMLMarshallerTest method expectedDescriptor.
private PersistenceDescriptorModel expectedDescriptor() {
PersistenceDescriptorModel descriptor = new PersistenceDescriptorModel();
descriptor.setVersion("2.1");
PersistenceUnitModel persistenceUnit = new PersistenceUnitModel();
descriptor.setPersistenceUnit(persistenceUnit);
persistenceUnit.setName("org.test.persistence-unit");
persistenceUnit.setDescription("org.test.description");
persistenceUnit.setProvider("org.test.Provider");
persistenceUnit.setJtaDataSource("java:jboss/datasources/ExampleDS");
persistenceUnit.getMappingFile().add("META-INF/Mapping1.xml");
persistenceUnit.getMappingFile().add("META-INF/Mapping2.xml");
persistenceUnit.getJarFile().add("file1.jar");
persistenceUnit.getJarFile().add("file2.jar");
persistenceUnit.getClasses().add(new PersistableDataObject("org.test.Entity1"));
persistenceUnit.getClasses().add(new PersistableDataObject("org.test.Entity2"));
persistenceUnit.setExcludeUnlistedClasses(true);
persistenceUnit.setSharedCacheMode(CachingType.ALL);
persistenceUnit.setValidationMode(ValidationMode.AUTO);
persistenceUnit.setTransactionType(TransactionType.JTA);
persistenceUnit.addProperty(new Property("property1", "property1_value"));
persistenceUnit.addProperty(new Property("property2", "property2_value"));
return descriptor;
}
use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.
the class PersistencePresenter method add.
public void add(final String className) {
persistableDataObjectsListPresenter.add(new PersistableDataObject(className));
fireChangeEvent();
}
use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistableDataObject in project kie-wb-common by kiegroup.
the class PersistencePresenterTest method newPersistenceDescriptorEditorContent.
private PersistenceDescriptorEditorContent newPersistenceDescriptorEditorContent() {
final PersistenceDescriptorEditorContent content = new PersistenceDescriptorEditorContent();
final PersistenceDescriptorModel model = new PersistenceDescriptorModel();
model.setVersion("2.0");
final PersistenceUnitModel unitModel = new PersistenceUnitModel();
model.setPersistenceUnit(unitModel);
unitModel.setName("UnitName");
unitModel.setTransactionType(TransactionType.JTA);
unitModel.setProvider("ProviderClass");
unitModel.setJtaDataSource("JTADataSource");
unitModel.setClasses(Arrays.asList(new PersistableDataObject("Class1"), new PersistableDataObject("Class2")));
content.setDescriptorModel(model);
content.setOverview(new Overview());
return content;
}
Aggregations