use of com.haulmont.cuba.gui.data.impl.testmodel1.TestMasterEntity in project cuba by cuba-platform.
the class DsContextApplyChangesTest method createEntities.
private void createEntities() {
master = new TestMasterEntity();
master.setMasterName("master");
detail1 = new TestDetailEntity();
detail1.setDetailName("detail1");
detail1.setMaster(master);
detail1.setParts(new HashSet<TestPartEntity>());
embeddable1 = new TestEmbeddableEntity();
embeddable1.setName("embeddable1");
detail1.setEmbeddable(embeddable1);
master.setDetail(detail1);
}
use of com.haulmont.cuba.gui.data.impl.testmodel1.TestMasterEntity in project cuba by cuba-platform.
the class CollectionDatasourceTest method testRemoveThenAddToPropertyDs.
@Test
public void testRemoveThenAddToPropertyDs() throws Exception {
DatasourceImpl<TestMasterEntity> ds = new DatasourceImpl<>();
ds.setMetaClass(metadata.getClassNN(TestMasterEntity.class));
ds.initialized();
CollectionPropertyDatasourceImpl<TestDetailEntity, UUID> cpds = new CollectionPropertyDatasourceImpl<>();
cpds.masterDs = ds;
cpds.metaProperty = ds.getMetaClass().getProperty("details");
TestMasterEntity masterEntity = new TestMasterEntity();
masterEntity.setMasterName("master");
masterEntity.setDetails(new HashSet<>());
ds.setItem(masterEntity);
TestDetailEntity detailEntity = new TestDetailEntity();
BaseEntityInternalAccess.setNew(detailEntity, false);
BaseEntityInternalAccess.setDetached(detailEntity, true);
detailEntity.setMaster(masterEntity);
detailEntity.setDetailName("detail");
masterEntity.getDetails().add(detailEntity);
cpds.removeItem(detailEntity);
cpds.addItem(detailEntity);
assertEquals(0, cpds.itemsToCreate.size());
assertEquals(1, cpds.itemsToUpdate.size());
assertEquals(0, cpds.itemsToDelete.size());
}
use of com.haulmont.cuba.gui.data.impl.testmodel1.TestMasterEntity in project cuba by cuba-platform.
the class DsContextTest method createEntities.
private void createEntities() {
master = new TestMasterEntity();
master.setMasterName("master");
master.setDetails(new HashSet<TestDetailEntity>());
detail1 = new TestDetailEntity();
detail1.setDetailName("detail1");
detail1.setMaster(master);
detail1.setParts(new HashSet<TestPartEntity>());
embeddable1 = new TestEmbeddableEntity();
embeddable1.setName("embeddable1");
detail1.setEmbeddable(embeddable1);
detail1.setMaster(master);
part1 = new TestPartEntity();
part1.setPartName("part1");
part1.setDetail(detail1);
detail1.getParts().add(part1);
master.getDetails().add(detail1);
detail2 = new TestDetailEntity();
detail2.setDetailName("detail2");
detail2.setMaster(master);
master.getDetails().add(detail2);
}
use of com.haulmont.cuba.gui.data.impl.testmodel1.TestMasterEntity in project cuba by cuba-platform.
the class DsContextTest method testAggregationNewEntity.
@Test
public void testAggregationNewEntity() {
// Master editor
createMasterDsContext();
final TestMasterEntity master = new TestMasterEntity();
master.setMasterName("new_master");
masterDs.setItem(master);
final TestDetailEntity detail = new TestDetailEntity();
detail.setMaster(master);
createDetailDsContext();
setupParentDs(detailsDs, detailDs, detail);
detailDs.getItem().setDetailName("new_detail");
dataService.commitValidator = null;
detailDsContext.commit();
assertEquals(0, dataService.commitCount, "Commit Detail DsContext");
// Commit Master editor
dataService.commitValidator = new TestDataSupplier.CommitValidator() {
@Override
public void validate(CommitContext context) {
assertTrue(containsEntityInstance(context.getCommitInstances(), detail.getId()));
assertTrue(containsEntityInstance(context.getCommitInstances(), master.getId()));
for (Entity entity : context.getCommitInstances()) {
if (entity.getId().equals(detail.getId()))
assertEquals("new_detail", ((TestDetailEntity) entity).getDetailName());
}
}
};
masterDsContext.commit();
assertEquals(1, dataService.commitCount, "Commit Master DsContext");
}
use of com.haulmont.cuba.gui.data.impl.testmodel1.TestMasterEntity in project cuba by cuba-platform.
the class CollectionDatasourceTest method testRemoveThenAdd.
@Test
public void testRemoveThenAdd() throws Exception {
CollectionDatasourceImpl<TestMasterEntity, UUID> cds = new CollectionDatasourceImpl<>();
cds.setMetaClass(metadata.getClassNN(TestMasterEntity.class));
cds.setRefreshMode(CollectionDatasource.RefreshMode.NEVER);
TestMasterEntity entity = new TestMasterEntity();
entity.setMasterName("master");
BaseEntityInternalAccess.setNew(entity, false);
BaseEntityInternalAccess.setDetached(entity, true);
cds.data.put(entity.getId(), entity);
cds.removeItem(entity);
cds.addItem(entity);
assertEquals(0, cds.itemsToCreate.size());
assertEquals(1, cds.itemsToUpdate.size());
assertEquals(0, cds.itemsToDelete.size());
}
Aggregations