Search in sources :

Example 1 with ODocumentLinksDataProvider

use of ru.ydn.wicket.wicketorientdb.model.ODocumentLinksDataProvider in project wicket-orientdb by OrienteerBAP.

the class TestModels method testODocumentLinksDataProvider.

@Test
public void testODocumentLinksDataProvider() {
    ODocument doc1 = new ODocument("ClassA");
    doc1.field("name", "doc1Ext");
    doc1.save();
    ODocument doc2 = new ODocument("ClassA");
    doc2.field("name", "doc2Ext");
    doc2.field("other", Arrays.asList(doc1));
    try {
        ODocumentModel documentModel = new ODocumentModel(doc2);
        OPropertyModel propertyModel = new OPropertyModel("ClassA", "other");
        ODocumentLinksDataProvider provider = new ODocumentLinksDataProvider(documentModel, propertyModel);
        assertEquals(1, provider.size());
        assertEquals(doc1, provider.iterator(0, 1).next());
        doc2.save();
        provider.detach();
        assertEquals(1, provider.size());
        assertEquals(doc1, provider.iterator(0, 1).next());
    } finally {
        doc1.delete();
        doc2.delete();
    }
}
Also used : ODocumentLinksDataProvider(ru.ydn.wicket.wicketorientdb.model.ODocumentLinksDataProvider) OPropertyModel(ru.ydn.wicket.wicketorientdb.model.OPropertyModel) ODocumentModel(ru.ydn.wicket.wicketorientdb.model.ODocumentModel) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Aggregations

ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 Test (org.junit.Test)1 ODocumentLinksDataProvider (ru.ydn.wicket.wicketorientdb.model.ODocumentLinksDataProvider)1 ODocumentModel (ru.ydn.wicket.wicketorientdb.model.ODocumentModel)1 OPropertyModel (ru.ydn.wicket.wicketorientdb.model.OPropertyModel)1