Here are the examples of the java api class com.orientechnologies.orient.core.record.impl.ODocument taken from open source projects.
1. SQLSelectByLinkedPropertyIndexReuseTest#fillDataSet()
Project: orientdb
File: SQLSelectByLinkedPropertyIndexReuseTest.java
File: SQLSelectByLinkedPropertyIndexReuseTest.java
/** * William James and James Bell work together on the same diploma. */ private void fillDataSet() { ODocument curator1 = database.newInstance("lpirtCurator"); curator1.field("name", "Someone"); curator1.field("salary", 2000); final ODocument group1 = database.newInstance("lpirtGroup"); group1.field("name", "PZ-08-1"); group1.field("curator", curator1); group1.save(); final ODocument diploma1 = database.newInstance("lpirtDiploma"); diploma1.field("GPA", 3.); diploma1.field("name", "diploma1"); diploma1.field("thesis", "Researching and visiting universities before making a final decision is very " + "beneficial because you student be able to experience the campus, meet the professors, and truly " + "understand the traditions of the university."); final ODocument transcript = database.newInstance("lpirtTranscript"); transcript.field("id", "1"); final ODocument skill = database.newInstance("lpirtSkill"); skill.field("name", "math"); final ODocument student1 = database.newInstance("lpirtStudent"); student1.field("name", "John Smith"); student1.field("group", group1); student1.field("diploma", diploma1); student1.field("transcript", transcript); student1.field("skill", skill); student1.save(); ODocument curator2 = database.newInstance("lpirtCurator"); curator2.field("name", "Someone else"); curator2.field("salary", 500); final ODocument group2 = database.newInstance("lpirtGroup"); group2.field("name", "PZ-08-2"); group2.field("curator", curator2); group2.save(); final ODocument diploma2 = database.newInstance("lpirtDiploma"); diploma2.field("GPA", 5.); diploma2.field("name", "diploma2"); diploma2.field("thesis", "While both Northerners and Southerners believed they fought against tyranny and " + "oppression, Northerners focused on the oppression of slaves while Southerners defended their own " + "right to self-government."); final ODocument student2 = database.newInstance("lpirtStudent"); student2.field("name", "Jane Smith"); student2.field("group", group2); student2.field("diploma", diploma2); student2.save(); ODocument curator3 = database.newInstance("lpirtCurator"); curator3.field("name", "Someone else"); curator3.field("salary", 600); final ODocument group3 = database.newInstance("lpirtGroup"); group3.field("name", "PZ-08-3"); group3.field("curator", curator3); group3.save(); final ODocument diploma3 = database.newInstance("lpirtDiploma"); diploma3.field("GPA", 4.); diploma3.field("name", "diploma3"); diploma3.field("thesis", "College student shouldn't have to take a required core curriculum, and many core " + "courses are graded too stiffly."); final ODocument student3 = database.newInstance("lpirtStudent"); student3.field("name", "James Bell"); student3.field("group", group3); student3.field("diploma", diploma3); student3.save(); final ODocument student4 = database.newInstance("lpirtStudent"); student4.field("name", "Roger Connor"); student4.field("group", group3); student4.save(); final ODocument student5 = database.newInstance("lpirtStudent"); student5.field("name", "William James"); student5.field("group", group3); student5.field("diploma", diploma3); student5.save(); }
2. OConflictManagementTest#testAutomergeStrategyWithLinks()
Project: orientdb
File: OConflictManagementTest.java
File: OConflictManagementTest.java
public void testAutomergeStrategyWithLinks() { database.setConflictStrategy("automerge"); ODocument rootDoc = new ODocument().field("name", "Jay").save(); ODocument linkedDoc = new ODocument().field("product", "Amiga").save(); rootDoc.field("relationships", new OIdentifiable[] { linkedDoc }, OType.LINKSET); rootDoc.save(); ODocument copy = rootDoc.copy(); ODocument linkedDoc2 = new ODocument().field("company", "Commodore").save(); rootDoc.field("relationships", new OIdentifiable[] { linkedDoc, linkedDoc2 }, OType.LINKSET); rootDoc.save(); ODocument linkedDoc3 = new ODocument().field("company", "Atari").save(); copy.field("relationships", new OIdentifiable[] { linkedDoc, linkedDoc3 }, OType.LINKSET); copy.save(); ODocument reloadedDoc = (ODocument) rootDoc.reload(); Assert.assertEquals(((Collection) reloadedDoc.field("relationships")).size(), 3); Collection<OIdentifiable> rels = reloadedDoc.field("relationships"); Assert.assertTrue(rels.contains(linkedDoc)); Assert.assertTrue(rels.contains(linkedDoc2)); Assert.assertTrue(rels.contains(linkedDoc3)); }
3. OrientTokenHandler#serializeWebPayload()
Project: orientdb
File: OrientTokenHandler.java
File: OrientTokenHandler.java
protected byte[] serializeWebPayload(final OJwtPayload payload) throws Exception { if (payload == null) throw new IllegalArgumentException("Token payload is null"); final ODocument doc = new ODocument(); doc.field("iss", payload.getIssuer()); doc.field("exp", payload.getExpiry()); doc.field("iat", payload.getIssuedAt()); doc.field("nbf", payload.getNotBefore()); doc.field("sub", payload.getDatabase()); doc.field("aud", payload.getAudience()); doc.field("jti", payload.getTokenId()); doc.field("uidc", ((OrientJwtPayload) payload).getUserRid().getClusterId()); doc.field("uidp", ((OrientJwtPayload) payload).getUserRid().getClusterPosition()); doc.field("bdtyp", ((OrientJwtPayload) payload).getDatabaseType()); return doc.toJSON().getBytes("UTF-8"); }
4. SQLFindReferencesTest#populateDatabase()
Project: orientdb
File: SQLFindReferencesTest.java
File: SQLFindReferencesTest.java
private void populateDatabase() { ODocument car = new ODocument(CAR); car.field("plate", "JINF223S"); ODocument johnDoe = new ODocument(WORKER); johnDoe.field("name", "John"); johnDoe.field("surname", "Doe"); johnDoe.field("car", car); johnDoe.save(); johnDoeID = johnDoe.getIdentity().copy(); ODocument janeDoe = new ODocument(WORKER); janeDoe.field("name", "Jane"); janeDoe.field("surname", "Doe"); janeDoe.save(); janeDoeID = janeDoe.getIdentity().copy(); ODocument chuckNorris = new ODocument(WORKER); chuckNorris.field("name", "Chuck"); chuckNorris.field("surname", "Norris"); chuckNorris.save(); chuckNorrisID = chuckNorris.getIdentity().copy(); ODocument jackBauer = new ODocument(WORKER); jackBauer.field("name", "Jack"); jackBauer.field("surname", "Bauer"); jackBauer.save(); jackBauerID = jackBauer.getIdentity().copy(); ODocument ctu = new ODocument(WORKPLACE); ctu.field("name", "CTU"); ctu.field("boss", jackBauer); List<ODocument> workplace1Workers = new ArrayList<ODocument>(); workplace1Workers.add(chuckNorris); workplace1Workers.add(janeDoe); ctu.field("workers", workplace1Workers); ctu.save(); ctuID = ctu.getIdentity().copy(); ODocument fbi = new ODocument(WORKPLACE); fbi.field("name", "FBI"); fbi.field("boss", chuckNorris); List<ODocument> workplace2Workers = new ArrayList<ODocument>(); workplace2Workers.add(chuckNorris); workplace2Workers.add(jackBauer); fbi.field("workers", workplace2Workers); fbi.save(); fbiID = fbi.getIdentity().copy(); car.field("owner", jackBauer); car.save(); carID = car.getIdentity().copy(); }
5. ORidBagAtomicUpdateTest#testAddInternalDocumentsAndSubDocumentsWithCME()
Project: orientdb
File: ORidBagAtomicUpdateTest.java
File: ORidBagAtomicUpdateTest.java
public void testAddInternalDocumentsAndSubDocumentsWithCME() { final ODocument cmeDoc = new ODocument(); cmeDoc.save(); database.begin(); ODocument rootDoc = new ODocument(); ORidBag ridBag = new ORidBag(); rootDoc.field("ridBag", ridBag); ODocument docOne = new ODocument(); docOne.save(); ODocument docTwo = new ODocument(); docTwo.save(); ridBag.add(docOne); ridBag.add(docTwo); rootDoc.save(); database.commit(); long recordsCount = database.countClusterElements(database.getDefaultClusterId()); rootDoc = database.load(rootDoc.getIdentity()); ridBag = rootDoc.field("ridBag"); database.getLocalCache().clear(); ODocument staleCMEDoc = database.load(cmeDoc.getIdentity()); Assert.assertNotSame(staleCMEDoc, cmeDoc); cmeDoc.field("v", "v"); cmeDoc.save(); database.begin(); ODocument docThree = new ODocument(); docThree.save(); ODocument docFour = new ODocument(); docFour.save(); ridBag.add(docThree); ridBag.add(docFour); rootDoc.save(); ODocument docThreeOne = new ODocument(); docThreeOne.save(); ODocument docThreeTwo = new ODocument(); docThreeTwo.save(); ORidBag ridBagThree = new ORidBag(); ridBagThree.add(docThreeOne); ridBagThree.add(docThreeTwo); docThree.field("ridBag", ridBagThree); docThree.save(); ODocument docFourOne = new ODocument(); docFourOne.save(); ODocument docFourTwo = new ODocument(); docFourTwo.save(); ORidBag ridBagFour = new ORidBag(); ridBagFour.add(docFourOne); ridBagFour.add(docFourTwo); docFour.field("ridBag", ridBagFour); docFour.save(); staleCMEDoc.field("v", "vn"); staleCMEDoc.save(); try { database.commit(); Assert.fail(); } catch (OConcurrentModificationException e) { } Assert.assertEquals(database.countClusterElements(database.getDefaultClusterId()), recordsCount); List<OIdentifiable> addedDocs = new ArrayList<OIdentifiable>(Arrays.asList(docOne, docTwo)); rootDoc = database.load(rootDoc.getIdentity()); ridBag = rootDoc.field("ridBag"); Iterator<OIdentifiable> iterator = ridBag.iterator(); Assert.assertTrue(addedDocs.remove(iterator.next())); Assert.assertTrue(addedDocs.remove(iterator.next())); }
6. DateTest#testDateConversion()
Project: orientdb
File: DateTest.java
File: DateTest.java
@Test public void testDateConversion() throws ParseException { final long begin = System.currentTimeMillis(); ODocument doc1 = new ODocument("Order"); doc1.field("context", "test"); doc1.field("date", new Date()); doc1.save(); ODocument doc2 = new ODocument("Order"); doc2.field("context", "test"); doc2.field("date", System.currentTimeMillis()); doc2.save(); doc2.reload(); Assert.assertTrue(doc2.field("date", OType.DATE) instanceof Date); doc2.reload(); Assert.assertTrue(doc2.field("date", Date.class) instanceof Date); List<ODocument> result = database.command(new OSQLSynchQuery<ODocument>("select * from Order where date >= ? and context = 'test'")).execute(begin); Assert.assertEquals(result.size(), 2); }
7. LinkSetIndexTest#testIndexLinkSetRemove()
Project: orientdb
File: LinkSetIndexTest.java
File: LinkSetIndexTest.java
public void testIndexLinkSetRemove() { final ODocument docOne = new ODocument(); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.save(); final ODocument document = new ODocument("LinkSetIndexTestClass"); final Set<OIdentifiable> linkSet = new HashSet<OIdentifiable>(); linkSet.add(docOne); linkSet.add(docTwo); document.field("linkSet", linkSet); document.save(); document.delete(); List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkSetIndex")).execute(); Assert.assertNotNull(result); Assert.assertEquals(result.size(), 0); }
8. LinkListIndexTest#testIndexCollectionRemove()
Project: orientdb
File: LinkListIndexTest.java
File: LinkListIndexTest.java
public void testIndexCollectionRemove() { final ODocument docOne = new ODocument(); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.save(); final ODocument document = new ODocument("LinkListIndexTestClass"); document.field("linkCollection", new ArrayList<ORID>(Arrays.asList(docOne.getIdentity(), docTwo.getIdentity()))); document.save(); document.delete(); List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkCollectionIndex")).execute(); Assert.assertNotNull(result); Assert.assertEquals(result.size(), 0); }
9. LinkListIndexTest#testIndexCollection()
Project: orientdb
File: LinkListIndexTest.java
File: LinkListIndexTest.java
public void testIndexCollection() { final ODocument docOne = new ODocument(); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.save(); final ODocument document = new ODocument("LinkListIndexTestClass"); document.field("linkCollection", new ArrayList<ORID>(Arrays.asList(docOne.getIdentity(), docTwo.getIdentity()))); document.save(); List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkCollectionIndex")).execute(); Assert.assertNotNull(result); Assert.assertEquals(result.size(), 2); for (ODocument d : result) { Assert.assertTrue(d.containsField("key")); Assert.assertTrue(d.containsField("rid")); if (!d.field("key").equals(docOne.getIdentity()) && !d.field("key").equals(docTwo.getIdentity())) { Assert.fail("Unknown key found: " + d.field("key")); } } }
10. LinkBagIndexTest#testIndexRidBagRemove()
Project: orientdb
File: LinkBagIndexTest.java
File: LinkBagIndexTest.java
public void testIndexRidBagRemove() { final ODocument docOne = new ODocument(); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.save(); final ODocument document = new ODocument("RidBagIndexTestClass"); final ORidBag ridBag = new ORidBag(); ridBag.add(docOne); ridBag.add(docTwo); document.field("ridBag", ridBag); document.save(); document.delete(); List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:ridBagIndex")).execute(); Assert.assertNotNull(result); Assert.assertEquals(result.size(), 0); }
11. ClassIndexManagerTest#testIndexOnPropertiesFromClassAndSuperclass()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testIndexOnPropertiesFromClassAndSuperclass() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); docOne.field("prop0", "doc1-prop0"); docOne.field("prop1", "doc1-prop1"); docOne.save(); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); docTwo.field("prop0", "doc2-prop0"); docTwo.field("prop1", "doc2-prop1"); docTwo.save(); final OSchema schema = database.getMetadata().getSchema(); final OClass oClass = schema.getClass("classIndexManagerTestClass"); final OIndex<?> oIndex = oClass.getClassIndex("classIndexManagerTestIndexOnPropertiesFromClassAndSuperclass"); Assert.assertEquals(oIndex.getSize(), 2); }
12. ClassIndexManagerTest#testCollectionCompositeUpdateBothAssignedNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeUpdateBothAssignedNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", (Object) null); doc.field("prop1", (Object) null); doc.save(); Assert.assertEquals(index.getSize(), 0); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
13. ClassIndexManagerTest#testUpdateDocumentWithoutClass()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testUpdateDocumentWithoutClass() { final Collection<? extends OIndex<?>> beforeIndexes = database.getMetadata().getIndexManager().getIndexes(); final Map<String, Long> indexSizeMap = new HashMap<String, Long>(); for (final OIndex<?> index : beforeIndexes) indexSizeMap.put(index.getName(), index.getSize()); final ODocument docOne = new ODocument(); docOne.field("prop1", "a"); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.field("prop1", "b"); docTwo.save(); docOne.field("prop1", "a"); docOne.save(); final Collection<? extends OIndex<?>> afterIndexes = database.getMetadata().getIndexManager().getIndexes(); for (final OIndex<?> index : afterIndexes) Assert.assertEquals(index.getSize(), indexSizeMap.get(index.getName()).longValue()); }
14. ClassIndexManagerTest#testPropertiesCheckUniqueIndexDubKeyIsNullUpdateInTX()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testPropertiesCheckUniqueIndexDubKeyIsNullUpdateInTX() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); database.begin(); docOne.field("prop1", "a"); docOne.save(); docTwo.field("prop1", "b"); docTwo.save(); docTwo.field("prop1", (String) null); docTwo.save(); database.commit(); }
15. ClassIndexManagerTest#testPropertiesCheckUniqueIndexDubKeyIsNullUpdate()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testPropertiesCheckUniqueIndexDubKeyIsNullUpdate() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); docOne.field("prop1", "a"); docOne.save(); docTwo.field("prop1", "b"); docTwo.save(); docTwo.field("prop1", (String) null); docTwo.save(); }
16. ByteArrayKeyTest#testAutomaticCompositeUsageInTX()
Project: orientdb
File: ByteArrayKeyTest.java
File: ByteArrayKeyTest.java
public void testAutomaticCompositeUsageInTX() { byte[] key1 = new byte[] { 7, 8, 9 }; byte[] key2 = new byte[] { 10, 11, 12 }; database.begin(); ODocument doc1 = new ODocument("CompositeByteArrayKeyTest"); doc1.field("byteArrayKey", key1); doc1.field("intKey", 1); doc1.save(); ODocument doc2 = new ODocument("CompositeByteArrayKeyTest"); doc2.field("byteArrayKey", key2); doc2.field("intKey", 2); doc2.save(); database.commit(); OIndex<?> index = database.getMetadata().getIndexManager().getIndex("compositeByteArrayKey"); Assert.assertEquals(index.get(new OCompositeKey(key1, 1)), doc1); Assert.assertEquals(index.get(new OCompositeKey(key2, 2)), doc2); }
17. ByteArrayKeyTest#testAutomaticCompositeUsage()
Project: orientdb
File: ByteArrayKeyTest.java
File: ByteArrayKeyTest.java
public void testAutomaticCompositeUsage() { byte[] key1 = new byte[] { 1, 2, 3 }; byte[] key2 = new byte[] { 4, 5, 6 }; ODocument doc1 = new ODocument("CompositeByteArrayKeyTest"); doc1.field("byteArrayKey", key1); doc1.field("intKey", 1); doc1.save(); ODocument doc2 = new ODocument("CompositeByteArrayKeyTest"); doc2.field("byteArrayKey", key2); doc2.field("intKey", 2); doc2.save(); OIndex<?> index = database.getMetadata().getIndexManager().getIndex("compositeByteArrayKey"); Assert.assertEquals(index.get(new OCompositeKey(key1, 1)), doc1); Assert.assertEquals(index.get(new OCompositeKey(key2, 2)), doc2); }
18. OHazelcastPlugin#getLocalNodeConfiguration()
Project: orientdb
File: OHazelcastPlugin.java
File: OHazelcastPlugin.java
@Override public ODocument getLocalNodeConfiguration() { final ODocument nodeCfg = new ODocument(); nodeCfg.field("id", getLocalNodeId()); nodeCfg.field("name", getLocalNodeName()); nodeCfg.field("startedOn", startedOn); nodeCfg.field("status", getNodeStatus()); List<Map<String, Object>> listeners = new ArrayList<Map<String, Object>>(); nodeCfg.field("listeners", listeners, OType.EMBEDDEDLIST); for (OServerNetworkListener listener : serverInstance.getNetworkListeners()) { final Map<String, Object> listenerCfg = new HashMap<String, Object>(); listeners.add(listenerCfg); listenerCfg.put("protocol", listener.getProtocolType().getSimpleName()); listenerCfg.put("listen", listener.getListeningAddress(true)); } nodeCfg.field("databases", getManagedDatabases()); return nodeCfg; }
19. ORidBagAtomicUpdateTest#testAddTwoSavedDocuments()
Project: orientdb
File: ORidBagAtomicUpdateTest.java
File: ORidBagAtomicUpdateTest.java
public void testAddTwoSavedDocuments() { long recordsCount = database.countClusterElements(database.getDefaultClusterId()); database.begin(); ODocument rootDoc = new ODocument(); ORidBag ridBag = new ORidBag(); rootDoc.field("ridBag", ridBag); ODocument docOne = new ODocument(); docOne.save(); ODocument docTwo = new ODocument(); docTwo.save(); ridBag.add(docOne); ridBag.add(docTwo); rootDoc.save(); database.rollback(); Assert.assertEquals(database.countClusterElements(database.getDefaultClusterId()), recordsCount); }
20. ClassIndexManagerTest#testCollectionCompositeDeleteBothSimpleCollectionFieldNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteBothSimpleCollectionFieldNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", (Object) null); doc.field("prop1", (Object) null); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
21. ClassIndexManagerTest#testCollectionCompositeDeleteBothCollectionSimpleFieldAssigend()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteBothCollectionSimpleFieldAssigend() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", Arrays.asList(1, 3)); doc.field("prop1", "test2"); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
22. ClassIndexManagerTest#testCollectionCompositeUpdateCollectionWasAssignedNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeUpdateCollectionWasAssignedNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", (Object) null); doc.save(); Assert.assertEquals(index.getSize(), 0); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
23. ClassIndexManagerTest#testCollectionCompositeUpdateSimpleFieldNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeUpdateSimpleFieldNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop1", (Object) null); doc.save(); Assert.assertEquals(index.getSize(), 0); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
24. ClassIndexManagerTest#testCollectionCompositeUpdateCollectionWasAssigned()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeUpdateCollectionWasAssigned() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", Arrays.asList(1, 3)); doc.save(); Assert.assertEquals(index.get(new OCompositeKey("test1", 1)), doc.getIdentity()); Assert.assertEquals(index.get(new OCompositeKey("test1", 3)), doc.getIdentity()); Assert.assertEquals(index.getSize(), 2); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
25. ClassIndexManagerTest#testCollectionCompositeUpdateSimpleField()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeUpdateSimpleField() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop1", "test2"); doc.save(); Assert.assertEquals(index.get(new OCompositeKey("test2", 1)), doc.getIdentity()); Assert.assertEquals(index.get(new OCompositeKey("test2", 2)), doc.getIdentity()); Assert.assertEquals(index.getSize(), 2); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
26. EmbeddedObjectSerializationTest#testEmbeddedObjectSerialization()
Project: orientdb
File: EmbeddedObjectSerializationTest.java
File: EmbeddedObjectSerializationTest.java
public void testEmbeddedObjectSerialization() { final ODocument originalDoc = new ODocument(); final OCompositeKey compositeKey = new OCompositeKey(123, "56", new Date(), new ORecordId("#0:12")); originalDoc.field("compositeKey", compositeKey); originalDoc.field("int", 12); originalDoc.field("val", "test"); originalDoc.save(); final ODocument loadedDoc = database.load(originalDoc.getIdentity(), "*:-1", true); Assert.assertNotSame(loadedDoc, originalDoc); final OCompositeKey loadedCompositeKey = loadedDoc.field("compositeKey"); Assert.assertEquals(loadedCompositeKey, compositeKey); originalDoc.delete(); }
27. CRUDDocumentValidationTest#validationMandatoryNullableNoCloseDb()
Project: orientdb
File: CRUDDocumentValidationTest.java
File: CRUDDocumentValidationTest.java
@Test(dependsOnMethods = "validationMandatoryNullableCloseDb") public void validationMandatoryNullableNoCloseDb() throws ParseException { ODocument doc = new ODocument("MyTestClass"); doc.field("keyField", "K3"); doc.field("dateTimeField", (Date) null); doc.field("stringField", (String) null); doc.save(); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM MyTestClass WHERE keyField = ?"); List<ODocument> result = database.query(query, "K3"); Assert.assertEquals(1, result.size()); doc = result.get(0); doc.field("keyField", "K3N"); doc.save(); }
28. CRUDDocumentValidationTest#validationMandatoryNullableCloseDb()
Project: orientdb
File: CRUDDocumentValidationTest.java
File: CRUDDocumentValidationTest.java
@Test(dependsOnMethods = "testUpdateDocDefined") public void validationMandatoryNullableCloseDb() throws ParseException { ODocument doc = new ODocument("MyTestClass"); doc.field("keyField", "K2"); doc.field("dateTimeField", (Date) null); doc.field("stringField", (String) null); doc.save(); database.close(); database.open("admin", "admin"); OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("SELECT FROM MyTestClass WHERE keyField = ?"); List<ODocument> result = database.query(query, "K2"); Assert.assertEquals(1, result.size()); doc = result.get(0); doc.field("keyField", "K2N"); doc.save(); }
29. CRUDDocumentPhysicalTest#testEmbeddeDocumentInTx()
Project: orientdb
File: CRUDDocumentPhysicalTest.java
File: CRUDDocumentPhysicalTest.java
@Test(dependsOnMethods = "cleanAll") public void testEmbeddeDocumentInTx() { ODocument bank = database.newInstance("Account"); database.begin(); bank.field("Name", "MyBank"); ODocument bank2 = database.newInstance("Account"); bank.field("embedded", bank2, OType.EMBEDDED); bank.save(); database.commit(); database.close(); database.open("admin", "admin"); bank.reload(); Assert.assertTrue(((ODocument) bank.field("embedded")).isEmbedded()); Assert.assertFalse(((ODocument) bank.field("embedded")).getIdentity().isPersistent()); bank.delete(); }
30. CRUDDocumentPhysicalTest#testDirtyChild()
Project: orientdb
File: CRUDDocumentPhysicalTest.java
File: CRUDDocumentPhysicalTest.java
@Test public void testDirtyChild() { ODocument parent = new ODocument(); ODocument child1 = new ODocument(); ODocumentInternal.addOwner(child1, parent); parent.field("child1", child1); Assert.assertTrue(child1.hasOwners()); ODocument child2 = new ODocument(); ODocumentInternal.addOwner(child2, child1); child1.field("child2", child2); Assert.assertTrue(child2.hasOwners()); // BEFORE FIRST TOSTREAM Assert.assertTrue(parent.isDirty()); parent.toStream(); // AFTER TOSTREAM Assert.assertTrue(parent.isDirty()); // CHANGE FIELDS VALUE (Automaticaly set dirty this child) child1.field("child2", new ODocument()); Assert.assertTrue(parent.isDirty()); }
31. CRUDDocumentPhysicalTest#testLazyLoadingByLink()
Project: orientdb
File: CRUDDocumentPhysicalTest.java
File: CRUDDocumentPhysicalTest.java
public void testLazyLoadingByLink() { ODocument coreDoc = new ODocument(); ODocument linkDoc = new ODocument(); coreDoc.field("link", linkDoc); coreDoc.save(); ODocument coreDocCopy = database.load(coreDoc.getIdentity(), "*:-1", true); Assert.assertNotSame(coreDocCopy, coreDoc); coreDocCopy.setLazyLoad(false); Assert.assertTrue(coreDocCopy.field("link") instanceof ORecordId); coreDocCopy.setLazyLoad(true); Assert.assertTrue(coreDocCopy.field("link") instanceof ODocument); }
32. LinkListIndexTest#testIndexCollectionSQL()
Project: orientdb
File: LinkListIndexTest.java
File: LinkListIndexTest.java
public void testIndexCollectionSQL() { final ODocument docOne = new ODocument(); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.save(); final ODocument document = new ODocument("LinkListIndexTestClass"); document.field("linkCollection", new ArrayList<ORID>(Arrays.asList(docOne.getIdentity(), docTwo.getIdentity()))); document.save(); List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select * from LinkListIndexTestClass where linkCollection contains ?"), docOne.getIdentity()); Assert.assertNotNull(result); Assert.assertEquals(result.size(), 1); Assert.assertEquals(Arrays.asList(docOne.getIdentity(), docTwo.getIdentity()), result.get(0).<List>field("linkCollection")); }
33. LinkListIndexTest#testIndexCollectionRemoveInTx()
Project: orientdb
File: LinkListIndexTest.java
File: LinkListIndexTest.java
public void testIndexCollectionRemoveInTx() throws Exception { final ODocument docOne = new ODocument(); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.save(); final ODocument document = new ODocument("LinkListIndexTestClass"); document.field("linkCollection", new ArrayList<ORID>(Arrays.asList(docOne.getIdentity(), docTwo.getIdentity()))); document.save(); try { database.begin(); document.delete(); database.commit(); } catch (Exception e) { database.rollback(); throw e; } List<ODocument> result = database.command(new OCommandSQL("select key, rid from index:linkCollectionIndex")).execute(); Assert.assertNotNull(result); Assert.assertEquals(result.size(), 0); }
34. IndexTest#testEmptyNotUniqueIndex()
Project: orientdb
File: IndexTest.java
File: IndexTest.java
public void testEmptyNotUniqueIndex() { OClass emptyNotUniqueIndexClazz = database.getMetadata().getSchema().createClass("EmptyNotUniqueIndexTest"); emptyNotUniqueIndexClazz.createProperty("prop", OType.STRING); final OIndex notUniqueIndex = emptyNotUniqueIndexClazz.createIndex("EmptyNotUniqueIndexTestIndex", INDEX_TYPE.NOTUNIQUE_HASH_INDEX, "prop"); ODocument document = new ODocument("EmptyNotUniqueIndexTest"); document.field("prop", "keyOne"); document.save(); document = new ODocument("EmptyNotUniqueIndexTest"); document.field("prop", "keyTwo"); document.save(); Assert.assertFalse(notUniqueIndex.contains("RandomKeyOne")); Assert.assertTrue(notUniqueIndex.contains("keyOne")); Assert.assertFalse(notUniqueIndex.contains("RandomKeyTwo")); Assert.assertTrue(notUniqueIndex.contains("keyTwo")); }
35. IndexTest#testIndexInCompositeQuery()
Project: orientdb
File: IndexTest.java
File: IndexTest.java
@Test public void testIndexInCompositeQuery() { OClass classOne = database.getMetadata().getSchema().createClass("CompoundSQLIndexTest1"); OClass classTwo = database.getMetadata().getSchema().createClass("CompoundSQLIndexTest2"); classTwo.createProperty("address", OType.LINK, classOne); classTwo.createIndex("CompoundSQLIndexTestIndex", INDEX_TYPE.UNIQUE, "address"); ODocument docOne = new ODocument("CompoundSQLIndexTest1"); docOne.field("city", "Montreal"); docOne.save(); ODocument docTwo = new ODocument("CompoundSQLIndexTest2"); docTwo.field("address", docOne); docTwo.save(); List<ODocument> result = database.getUnderlying().query(new OSQLSynchQuery<ODocument>("select from CompoundSQLIndexTest2 where address in (select from CompoundSQLIndexTest1 where city='Montreal')")); Assert.assertEquals(result.size(), 1); Assert.assertEquals(result.get(0).getIdentity(), docTwo.getIdentity()); }
36. FetchPlanTest#beforeMeth()
Project: orientdb
File: FetchPlanTest.java
File: FetchPlanTest.java
@BeforeMethod public void beforeMeth() throws Exception { database.getMetadata().getSchema().createClass("FetchClass"); database.getMetadata().getSchema().createClass("SecondFetchClass").createProperty("surname", OType.STRING).setMandatory(true); database.getMetadata().getSchema().createClass("OutInFetchClass"); ODocument singleLinked = new ODocument(); database.save(singleLinked); ODocument doc = new ODocument("FetchClass"); doc.field("name", "first"); database.save(doc); ODocument doc1 = new ODocument("FetchClass"); doc1.field("name", "second"); doc1.field("linked", singleLinked); database.save(doc1); ODocument doc2 = new ODocument("FetchClass"); doc2.field("name", "third"); List<ODocument> linkList = new ArrayList<ODocument>(); linkList.add(doc); linkList.add(doc1); doc2.field("linkList", linkList); doc2.field("linked", singleLinked); Set<ODocument> linkSet = new HashSet<ODocument>(); linkSet.add(doc); linkSet.add(doc1); doc2.field("linkSet", linkSet); database.save(doc2); ODocument doc3 = new ODocument("FetchClass"); doc3.field("name", "forth"); doc3.field("ref", doc2); doc3.field("linkSet", linkSet); doc3.field("linkList", linkList); database.save(doc3); ODocument doc4 = new ODocument("SecondFetchClass"); doc4.field("name", "fifth"); doc4.field("surname", "test"); database.save(doc4); ODocument doc5 = new ODocument("SecondFetchClass"); doc5.field("name", "sixth"); doc5.field("surname", "test"); database.save(doc5); ODocument doc6 = new ODocument("OutInFetchClass"); ORidBag out = new ORidBag(); out.add(doc2); out.add(doc3); doc6.field("out_friend", out); ORidBag in = new ORidBag(); in.add(doc4); in.add(doc5); doc6.field("in_friend", in); doc6.field("name", "myName"); database.save(doc6); database.getLocalCache().clear(); }
37. SQLUpdateTest#updateWithNamedParameters()
Project: orientdb
File: SQLUpdateTest.java
File: SQLUpdateTest.java
@Test public void updateWithNamedParameters() { ODocument doc = new ODocument("Data"); doc.field("name", "Raf"); doc.field("city", "Torino"); doc.field("gender", "fmale"); doc.save(); OCommandSQL updatecommand = new OCommandSQL("update Data set gender = :gender , city = :city where name = :name"); Map<String, Object> params = new HashMap<String, Object>(); params.put("gender", "f"); params.put("city", "TOR"); params.put("name", "Raf"); database.command(updatecommand).execute(params); List<ODocument> result = database.query(new OSQLSynchQuery<Object>("select * from Data")); ODocument oDoc = result.get(0); Assert.assertEquals("Raf", oDoc.field("name")); Assert.assertEquals("TOR", oDoc.field("city")); Assert.assertEquals("f", oDoc.field("gender")); }
38. CollateTest#testQueryNotNullCi()
Project: orientdb
File: CollateTest.java
File: CollateTest.java
public void testQueryNotNullCi() { final OSchema schema = database.getMetadata().getSchema(); OClass clazz = schema.createClass("collateTestNotNull"); OProperty csp = clazz.createProperty("bar", OType.STRING); csp.setCollate(OCaseInsensitiveCollate.NAME); ODocument document = new ODocument("collateTestNotNull"); document.field("bar", "baz"); document.save(); document = new ODocument("collateTestNotNull"); document.field("nobar", true); document.save(); List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from collateTestNotNull where bar is null")); Assert.assertEquals(result.size(), 1); result = database.query(new OSQLSynchQuery<ODocument>("select from collateTestNotNull where bar is not null")); Assert.assertEquals(result.size(), 1); }
39. ClassIndexManagerTest#testCollectionCompositeDeleteCollectionFieldChangedSimpleFieldNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteCollectionFieldChangedSimpleFieldNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); List<Integer> docList = doc.field("prop2"); docList.add(3); docList.add(4); docList.remove(1); doc.field("prop1", (Object) null); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
40. ClassIndexManagerTest#testCollectionCompositeDeleteCollectionFieldNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteCollectionFieldNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", (Object) null); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
41. ClassIndexManagerTest#testCollectionCompositeDeleteSimpleFieldNull()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteSimpleFieldNull() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop1", (Object) null); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
42. ClassIndexManagerTest#testCollectionCompositeDeleteBothCollectionSimpleFieldChanged()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteBothCollectionSimpleFieldChanged() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); List<Integer> docList = doc.field("prop2"); docList.add(3); docList.add(4); docList.remove(1); doc.field("prop1", "test2"); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
43. ClassIndexManagerTest#testCollectionCompositeDeleteCollectionFieldAssigend()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteCollectionFieldAssigend() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop2", Arrays.asList(1, 3)); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
44. ClassIndexManagerTest#testCollectionCompositeDeleteSimpleFieldAssigend()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteSimpleFieldAssigend() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); doc.field("prop1", "test2"); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
45. ClassIndexManagerTest#testDeleteUpdatedDocumentOrigNullFieldIndexRecordDeleted()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testDeleteUpdatedDocumentOrigNullFieldIndexRecordDeleted() { final ODocument doc = new ODocument("classIndexManagerTestClass"); doc.field("prop1", "a"); doc.field("prop2", (Object) null); doc.save(); final OSchema schema = database.getMetadata().getSchema(); final OClass oClass = schema.getClass("classIndexManagerTestClass"); final OIndex<?> propOneIndex = oClass.getClassIndex("classIndexManagerTestClass.prop1"); final OIndex<?> compositeIndex = oClass.getClassIndex("classIndexManagerComposite"); Assert.assertEquals(propOneIndex.getSize(), 1); Assert.assertEquals(compositeIndex.getSize(), 0); doc.field("prop2", 2); doc.delete(); Assert.assertEquals(propOneIndex.getSize(), 0); Assert.assertEquals(compositeIndex.getSize(), 0); }
46. ClassIndexManagerTest#testCreateDocumentWithoutClass()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCreateDocumentWithoutClass() { final Collection<? extends OIndex<?>> beforeIndexes = database.getMetadata().getIndexManager().getIndexes(); final Map<String, Long> indexSizeMap = new HashMap<String, Long>(); for (final OIndex<?> index : beforeIndexes) indexSizeMap.put(index.getName(), index.getSize()); final ODocument docOne = new ODocument(); docOne.field("prop1", "a"); docOne.save(); final ODocument docTwo = new ODocument(); docTwo.field("prop1", "a"); docTwo.save(); final Collection<? extends OIndex<?>> afterIndexes = database.getMetadata().getIndexManager().getIndexes(); for (final OIndex<?> index : afterIndexes) Assert.assertEquals(index.getSize(), indexSizeMap.get(index.getName()).longValue()); }
47. ClassIndexManagerTest#testPropertiesCheckUniqueIndexDubKeysUpdate()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testPropertiesCheckUniqueIndexDubKeysUpdate() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); boolean exceptionThrown = false; docOne.field("prop1", "a"); docOne.save(); docTwo.field("prop1", "b"); docTwo.save(); try { docTwo.field("prop1", "a"); docTwo.save(); } catch (OResponseProcessingException e) { Assert.assertTrue(e.getCause() instanceof ORecordDuplicatedException); exceptionThrown = true; } catch (ORecordDuplicatedException e) { exceptionThrown = true; } Assert.assertTrue(exceptionThrown); }
48. ClassIndexManagerTest#testPropertiesCheckUniqueIndexDubKeyIsNullCreateInTx()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testPropertiesCheckUniqueIndexDubKeyIsNullCreateInTx() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); database.begin(); docOne.field("prop1", "a"); docOne.save(); docTwo.field("prop1", (String) null); docTwo.save(); database.commit(); }
49. ByteArrayKeyTest#testAutomaticUsage()
Project: orientdb
File: ByteArrayKeyTest.java
File: ByteArrayKeyTest.java
public void testAutomaticUsage() { byte[] key1 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1 }; ODocument doc1 = new ODocument("ByteArrayKeyTest"); doc1.field("byteArrayKey", key1); doc1.save(); byte[] key2 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 2 }; ODocument doc2 = new ODocument("ByteArrayKeyTest"); doc2.field("byteArrayKey", key2); doc2.save(); OIndex<?> index = database.getMetadata().getIndexManager().getIndex("byteArrayKeyIndex"); Assert.assertEquals(index.get(key1), doc1); Assert.assertEquals(index.get(key2), doc2); }
50. OServerCommandAbstract#sendJsonError()
Project: orientdb
File: OServerCommandAbstract.java
File: OServerCommandAbstract.java
protected void sendJsonError(OHttpResponse iResponse, final int iCode, final String iReason, final String iContentType, final Object iContent, final String iHeaders) throws IOException { ODocument response = new ODocument(); ODocument error = new ODocument(); error.field("code", iCode); error.field("reason", iReason); error.field("content", iContent); List<ODocument> errors = new ArrayList<ODocument>(); errors.add(error); response.field("errors", errors); iResponse.send(iCode, iReason, OHttpUtils.CONTENT_JSON, response.toJSON("prettyPrint"), iHeaders); }
51. LuceneInsertUpdateSingleDocumentNoTxTest#testInsertUpdateTransactionWithIndex()
Project: orientdb
File: LuceneInsertUpdateSingleDocumentNoTxTest.java
File: LuceneInsertUpdateSingleDocumentNoTxTest.java
@Test public void testInsertUpdateTransactionWithIndex() throws Exception { databaseDocumentTx.close(); databaseDocumentTx.open("admin", "admin"); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); schema.reload(); ODocument doc = new ODocument("City"); doc.field("name", ""); ODocument doc1 = new ODocument("City"); doc1.field("name", ""); doc = databaseDocumentTx.save(doc); doc1 = databaseDocumentTx.save(doc1); doc = databaseDocumentTx.load(doc); doc1 = databaseDocumentTx.load(doc1); doc.field("name", "Rome"); doc1.field("name", "Rome"); databaseDocumentTx.save(doc); databaseDocumentTx.save(doc1); OIndex idx = schema.getClass("City").getClassIndex("City.name"); Collection<?> coll = (Collection<?>) idx.get("Rome"); Assert.assertEquals(coll.size(), 2); Assert.assertEquals(idx.getSize(), 2); }
52. TestLinkedDocumentInMap#testLinkedValue()
Project: orientdb
File: TestLinkedDocumentInMap.java
File: TestLinkedDocumentInMap.java
@Test public void testLinkedValue() { db.getMetadata().getSchema().createClass("PersonTest"); db.command(new OCommandSQL("delete from PersonTest")).execute(); ODocument jaimeDoc = new ODocument("PersonTest"); jaimeDoc.field("name", "jaime"); jaimeDoc.save(); ODocument tyrionDoc = new ODocument("PersonTest"); tyrionDoc.fromJSON("{\"@type\":\"d\",\"name\":\"tyrion\",\"emergency_contact\":[{\"relationship\":\"brother\",\"contact\":" + jaimeDoc.toJSON() + "}]}"); tyrionDoc.save(); List<Map<String, OIdentifiable>> res = tyrionDoc.field("emergency_contact"); Map<String, OIdentifiable> doc = res.get(0); Assert.assertTrue(doc.get("contact").getIdentity().isValid()); db.close(); db.open("admin", "admin"); List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from " + tyrionDoc.getIdentity())); res = result.get(0).field("emergency_contact"); doc = res.get(0); Assert.assertTrue(doc.get("contact").getIdentity().isValid()); }
53. OConflictManagementTest#testAutomergeStrategy()
Project: orientdb
File: OConflictManagementTest.java
File: OConflictManagementTest.java
public void testAutomergeStrategy() { database.setConflictStrategy("automerge"); ODocument rootDoc = new ODocument().field("name", "Jay").save(); ODocument copy = rootDoc.copy(); rootDoc.field("name", "Jay1"); rootDoc.save(); copy.field("name", "Jay1"); copy.save(); }
54. OConflictManagementTest#testContentStrategy()
Project: orientdb
File: OConflictManagementTest.java
File: OConflictManagementTest.java
public void testContentStrategy() { database.setConflictStrategy("content"); ODocument rootDoc = new ODocument().field("name", "Jay").save(); ODocument copy = rootDoc.copy(); rootDoc.field("name", "Jay1"); rootDoc.save(); copy.field("name", "Jay1"); copy.save(); }
55. OCommandExecutorSQLSelectTest#initCollateOnLinked()
Project: orientdb
File: OCommandExecutorSQLSelectTest.java
File: OCommandExecutorSQLSelectTest.java
private void initCollateOnLinked(ODatabaseDocumentTx db) { db.command(new OCommandSQL("CREATE CLASS CollateOnLinked")).execute(); db.command(new OCommandSQL("CREATE CLASS CollateOnLinked2")).execute(); db.command(new OCommandSQL("CREATE PROPERTY CollateOnLinked.name String")).execute(); db.command(new OCommandSQL("ALTER PROPERTY CollateOnLinked.name collate ci")).execute(); ODocument doc = new ODocument("CollateOnLinked"); doc.field("name", "foo"); doc.save(); ODocument doc2 = new ODocument("CollateOnLinked2"); doc2.field("linked", doc.getIdentity()); doc2.save(); }
56. UniqueIndexTest#testUniqueOnUpdate()
Project: orientdb
File: UniqueIndexTest.java
File: UniqueIndexTest.java
@Test() public void testUniqueOnUpdate() { final OSchema schema = db.getMetadata().getSchema(); OClass userClass = schema.createClass("User"); userClass.createProperty("MailAddress", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE); ODocument john = new ODocument("User"); john.field("MailAddress", "[email protected]"); db.save(john); ODocument jane = new ODocument("User"); jane.field("MailAddress", "[email protected]"); ODocument id = jane.save(); db.save(jane); try { ODocument toUp = db.load(id.getIdentity()); toUp.field("MailAddress", "[email protected]"); db.save(toUp); Assert.fail("Expected record duplicate exception"); } catch (ORecordDuplicatedException ex) { } ODocument fromDb = db.load(id.getIdentity()); Assert.assertEquals(fromDb.field("MailAddress"), "[email protected]"); }
57. TestImportRewriteLinks#testNestedLinkRewrite()
Project: orientdb
File: TestImportRewriteLinks.java
File: TestImportRewriteLinks.java
@Test public void testNestedLinkRewrite() { // Fx for remove dirty database in the thread local ODatabaseRecordThreadLocal.INSTANCE.remove(); OIndex<OIdentifiable> mapper = Mockito.mock(OIndex.class); Mockito.when(mapper.get(new ORecordId(10, 4))).thenReturn(new ORecordId(10, 3)); ODocument doc = new ODocument(); ODocument emb = new ODocument(); doc.field("emb", emb, OType.EMBEDDED); ODocument emb1 = new ODocument(); emb.field("emb1", emb1, OType.EMBEDDED); emb1.field("link", new ORecordId(10, 4)); ODatabaseImport.rewriteLinksInDocument(doc, mapper); Assert.assertEquals(emb1.field("link"), new ORecordId(10, 3)); }
58. TransactionAtomicTest#testMVCC()
Project: orientdb
File: TransactionAtomicTest.java
File: TransactionAtomicTest.java
@Test public void testMVCC() throws IOException { ODocument doc = new ODocument("Account"); doc.field("version", 0); doc.save(); doc.setDirty(); doc.field("testmvcc", true); doc.getRecordVersion().increment(); try { doc.save(); Assert.assertTrue(false); } catch (OResponseProcessingException e) { Assert.assertTrue(e.getCause() instanceof OConcurrentModificationException); } catch (OConcurrentModificationException e) { Assert.assertTrue(true); } }
59. StringsTest#testDocumentSelfReference()
Project: orientdb
File: StringsTest.java
File: StringsTest.java
public void testDocumentSelfReference() { ODocument document = new ODocument(); document.field("selfref", document); ODocument docTwo = new ODocument(); docTwo.field("ref", document); document.field("ref", docTwo); String value = document.toString(); Assert.assertEquals(value, "{selfref:<recursion:rid=#-1:-1>,ref:{ref:<recursion:rid=#-1:-1>}}"); }
60. ORidBagTest#testCycle()
Project: orientdb
File: ORidBagTest.java
File: ORidBagTest.java
public void testCycle() { ODocument docOne = new ODocument(); ORidBag ridBagOne = new ORidBag(); ODocument docTwo = new ODocument(); ORidBag ridBagTwo = new ORidBag(); docOne.field("ridBag", ridBagOne); docTwo.field("ridBag", ridBagTwo); ridBagOne.add(docTwo); ridBagTwo.add(docOne); docOne.save(); docOne = database.load(docOne.getIdentity(), "*:-1", false); ridBagOne = docOne.field("ridBag"); docTwo = database.load(docTwo.getIdentity(), "*:-1", false); ridBagTwo = docTwo.field("ridBag"); Assert.assertEquals(ridBagOne.iterator().next(), docTwo); Assert.assertEquals(ridBagTwo.iterator().next(), docOne); }
61. SchemaTest#testRenameClass()
Project: orientdb
File: SchemaTest.java
File: SchemaTest.java
@Test public void testRenameClass() { OClass oClass = database.getMetadata().getSchema().createClass("RenameClassTest"); ODocument document = new ODocument("RenameClassTest"); document.save(); document.reset(); document.setClassName("RenameClassTest"); document.save(); List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>("select from RenameClassTest")); Assert.assertEquals(result.size(), 2); oClass.set(OClass.ATTRIBUTES.NAME, "RenameClassTest2"); database.getLocalCache().clear(); result = database.query(new OSQLSynchQuery<ODocument>("select from RenameClassTest2")); Assert.assertEquals(result.size(), 2); }
62. ComplexTypesTest#testBigDecimal()
Project: orientdb
File: ComplexTypesTest.java
File: ComplexTypesTest.java
@Test public void testBigDecimal() { ODocument newDoc = new ODocument(); newDoc.field("integer", new BigInteger("10")); newDoc.field("decimal_integer", new BigDecimal(10)); newDoc.field("decimal_float", new BigDecimal("10.34")); database.save(newDoc); final ORID rid = newDoc.getIdentity(); database.close(); database = new ODatabaseDocumentTx(url).open("admin", "admin"); ODocument loadedDoc = database.load(rid); Assert.assertEquals(((Number) loadedDoc.field("integer")).intValue(), 10); Assert.assertEquals(loadedDoc.field("decimal_integer"), new BigDecimal(10)); Assert.assertEquals(loadedDoc.field("decimal_float"), new BigDecimal("10.34")); }
63. ClassIndexManagerTest#testCollectionCompositeDeleteCollectionFieldChanged()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeDeleteCollectionFieldChanged() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); List<Integer> docList = doc.field("prop2"); docList.add(3); docList.add(4); docList.remove(1); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
64. ClassIndexManagerTest#testCollectionCompositeNullCollectionFieldCreation()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeNullCollectionFieldCreation() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", (Object) null); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 0); doc.delete(); }
65. ClassIndexManagerTest#testCollectionCompositeNullSimpleFieldCreation()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeNullSimpleFieldCreation() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", (Object) null); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 0); doc.delete(); }
66. ClassIndexManagerTest#testCollectionCompositeCreation()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testCollectionCompositeCreation() { final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass"); doc.field("prop1", "test1"); doc.field("prop2", Arrays.asList(1, 2)); doc.save(); final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection"); Assert.assertEquals(index.getSize(), 2); Assert.assertEquals(index.get(new OCompositeKey("test1", 1)), doc.getIdentity()); Assert.assertEquals(index.get(new OCompositeKey("test1", 2)), doc.getIdentity()); doc.delete(); Assert.assertEquals(index.getSize(), 0); }
67. ClassIndexManagerTest#testNoClassIndexesUpdate()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testNoClassIndexesUpdate() { final ODocument doc = new ODocument("classIndexManagerTestClassTwo"); doc.field("prop1", "a"); doc.save(); doc.field("prop1", "b"); doc.save(); final OSchema schema = database.getMetadata().getSchema(); final OClass oClass = schema.getClass("classIndexManagerTestClass"); final Collection<OIndex<?>> indexes = oClass.getIndexes(); for (final OIndex<?> index : indexes) { Assert.assertEquals(index.getSize(), 0); } }
68. ClassIndexManagerTest#testDeleteUpdatedDocumentNullFieldIndexRecordDeleted()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testDeleteUpdatedDocumentNullFieldIndexRecordDeleted() { final ODocument doc = new ODocument("classIndexManagerTestClass"); doc.field("prop1", "a"); doc.field("prop2", (Object) null); doc.save(); final OSchema schema = database.getMetadata().getSchema(); final OClass oClass = schema.getClass("classIndexManagerTestClass"); final OIndex<?> propOneIndex = oClass.getClassIndex("classIndexManagerTestClass.prop1"); final OIndex<?> compositeIndex = oClass.getClassIndex("classIndexManagerComposite"); Assert.assertEquals(propOneIndex.getSize(), 1); Assert.assertEquals(compositeIndex.getSize(), 0); doc.delete(); Assert.assertEquals(propOneIndex.getSize(), 0); Assert.assertEquals(compositeIndex.getSize(), 0); }
69. HttpDocumentTest#updateFull()
Project: orientdb
File: HttpDocumentTest.java
File: HttpDocumentTest.java
public void updateFull() throws IOException { post("document/" + getDatabaseName()).payload("{name:'Jay', surname:'Miner',age:0}", CONTENT.JSON).exec(); Assert.assertEquals(getResponse().getStatusLine().getStatusCode(), 201); final ODocument created = new ODocument().fromJSON(getResponse().getEntity().getContent()); Assert.assertEquals(created.field("name"), "Jay"); Assert.assertEquals(created.field("surname"), "Miner"); Assert.assertEquals(created.field("age"), 0); Assert.assertEquals(created.getVersion(), 1); created.field("name", "Jay2"); created.field("surname", "Miner2"); created.field("age", 1); put("document/" + getDatabaseName() + "/" + created.getIdentity().toString().substring(1)).payload(created.toJSON(), CONTENT.JSON).exec(); Assert.assertEquals(getResponse().getStatusLine().getStatusCode(), 200); final ODocument updated = new ODocument().fromJSON(getResponse().getEntity().getContent()); Assert.assertEquals(updated.field("name"), "Jay2"); Assert.assertEquals(updated.field("surname"), "Miner2"); Assert.assertEquals(updated.field("age"), 1); Assert.assertEquals(updated.getVersion(), 2); }
70. OrientDbCreationHelper#createArticleWithAttachmentSplitted()
Project: orientdb
File: OrientDbCreationHelper.java
File: OrientDbCreationHelper.java
public static ODocument createArticleWithAttachmentSplitted(ODatabaseDocumentTx db) throws IOException { ODocument article = new ODocument("Article"); Calendar instance = Calendar.getInstance(TimeZone.getTimeZone("UTC")); Date time = instance.getTime(); article.field("date", time, OType.DATE); article.field("uuid", 1000000); article.field("title", "the title 2"); article.field("content", "the content 2"); if (new File("./src/test/resources/file.pdf").exists()) article.field("attachment", loadFile(db, "./src/test/resources/file.pdf", 256)); db.save(article); return article; }
71. JSONTest#testListToJSON()
Project: orientdb
File: JSONTest.java
File: JSONTest.java
@Test public void testListToJSON() { final ArrayList<ODocument> list = new ArrayList<ODocument>(); ODocument first = new ODocument().field("name", "Luca"); ODocument second = new ODocument().field("name", "Marcus"); list.add(first); list.add(second); String jsonResult = OJSONWriter.listToJSON(list, null); ODocument doc = new ODocument(); doc.fromJSON("{\"result\": " + jsonResult + "}"); Collection<ODocument> result = doc.field("result"); Assert.assertTrue(result instanceof Collection); Assert.assertEquals(result.size(), 2); for (ODocument resultDoc : result) { Assert.assertTrue(first.hasSameContentOf(resultDoc) || second.hasSameContentOf(resultDoc)); } }
72. DocumentTrackingTest#testReload()
Project: orientdb
File: DocumentTrackingTest.java
File: DocumentTrackingTest.java
public void testReload() { final ODocument document = new ODocument("DocumentTrackingTestClass"); final List<String> list = new ArrayList<String>(); list.add("value1"); document.field("embeddedlist", list); document.field("val", 1); document.save(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); final List<String> trackedList = document.field("embeddedlist"); trackedList.add("value2"); document.reload(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); Assert.assertNull(document.getCollectionTimeLine("embeddedlist")); }
73. DocumentTrackingTest#testUnload()
Project: orientdb
File: DocumentTrackingTest.java
File: DocumentTrackingTest.java
public void testUnload() { final ODocument document = new ODocument("DocumentTrackingTestClass"); final List<String> list = new ArrayList<String>(); list.add("value1"); document.field("embeddedlist", list); document.field("val", 1); document.save(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); final List<String> trackedList = document.field("embeddedlist"); trackedList.add("value2"); document.unload(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); Assert.assertNull(document.getCollectionTimeLine("embeddedlist")); }
74. DocumentTrackingTest#testClear()
Project: orientdb
File: DocumentTrackingTest.java
File: DocumentTrackingTest.java
public void testClear() { final ODocument document = new ODocument("DocumentTrackingTestClass"); final List<String> list = new ArrayList<String>(); list.add("value1"); document.field("embeddedlist", list); document.field("val", 1); document.save(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); final List<String> trackedList = document.field("embeddedlist"); trackedList.add("value2"); document.clear(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertTrue(document.isDirty()); Assert.assertNull(document.getCollectionTimeLine("embeddedlist")); }
75. DocumentTrackingTest#testReset()
Project: orientdb
File: DocumentTrackingTest.java
File: DocumentTrackingTest.java
public void testReset() { final ODocument document = new ODocument("DocumentTrackingTestClass"); final List<String> list = new ArrayList<String>(); list.add("value1"); document.field("embeddedlist", list); document.field("val", 1); document.save(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); final List<String> trackedList = document.field("embeddedlist"); trackedList.add("value2"); document.reset(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertTrue(document.isDirty()); Assert.assertNull(document.getCollectionTimeLine("embeddedlist")); }
76. DocumentTrackingTest#testTrackingChangesSwitchedOff()
Project: orientdb
File: DocumentTrackingTest.java
File: DocumentTrackingTest.java
public void testTrackingChangesSwitchedOff() { final ODocument document = new ODocument("DocumentTrackingTestClass"); final List<String> list = new ArrayList<String>(); list.add("value1"); document.field("embeddedlist", list); document.field("val", 1); document.save(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); final List<String> trackedList = document.field("embeddedlist"); trackedList.add("value2"); document.setTrackingChanges(false); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertTrue(document.isDirty()); Assert.assertNull(document.getCollectionTimeLine("embeddedlist")); }
77. DocumentTrackingTest#testRemoveField()
Project: orientdb
File: DocumentTrackingTest.java
File: DocumentTrackingTest.java
public void testRemoveField() { final ODocument document = new ODocument("DocumentTrackingTestClass"); final List<String> list = new ArrayList<String>(); list.add("value1"); document.field("embeddedlist", list); document.field("val", 1); document.save(); Assert.assertEquals(document.getDirtyFields(), new String[] {}); Assert.assertFalse(document.isDirty()); final List<String> trackedList = document.field("embeddedlist"); trackedList.add("value2"); document.removeField("embeddedlist"); Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedlist" }); Assert.assertTrue(document.isDirty()); Assert.assertNull(document.getCollectionTimeLine("embeddedlist")); }
78. OConflictManagementTest#testVersionStrategy()
Project: orientdb
File: OConflictManagementTest.java
File: OConflictManagementTest.java
public void testVersionStrategy() { database.setConflictStrategy("version"); ODocument rootDoc = new ODocument().field("name", "Jay").save(); ODocument copy = rootDoc.copy(); rootDoc.field("name", "Jay1"); rootDoc.save(); copy.field("name", "Jay2"); try { copy.save(); Assert.assertTrue(false); } catch (OConcurrentModificationException e) { } }
79. OConflictManagementTest#testDefaultStrategy()
Project: orientdb
File: OConflictManagementTest.java
File: OConflictManagementTest.java
public void testDefaultStrategy() { ODocument rootDoc = new ODocument().field("name", "Jay").save(); ODocument copy = rootDoc.copy(); rootDoc.field("name", "Jay1"); rootDoc.save(); copy.field("name", "Jay2"); try { copy.save(); Assert.assertTrue(false); } catch (OConcurrentModificationException e) { } }
80. OTraverseTest#testBreadthTraverse()
Project: orientdb
File: OTraverseTest.java
File: OTraverseTest.java
@Test public void testBreadthTraverse() throws Exception { traverse.setStrategy(OTraverse.STRATEGY.BREADTH_FIRST); final ODocument aa = new ODocument(); final ODocument ab = new ODocument(); final ODocument ba = new ODocument(); final ODocument bb = new ODocument(); final ODocument a = new ODocument(); a.field("aa", aa); a.field("ab", ab); final ODocument b = new ODocument(); b.field("ba", ba); b.field("bb", bb); rootDocument.field("a", a); rootDocument.field("b", b); final ODocument c1 = new ODocument(); final ODocument c1a = new ODocument(); c1.field("c1a", c1a); final ODocument c1b = new ODocument(); c1.field("c1b", c1b); final ODocument c2 = new ODocument(); final ODocument c2a = new ODocument(); c2.field("c2a", c2a); final ODocument c2b = new ODocument(); c2.field("c2b", c2b); final ODocument c3 = new ODocument(); final ODocument c3a = new ODocument(); c3.field("c3a", c3a); final ODocument c3b = new ODocument(); c3.field("c3b", c3b); rootDocument.field("c", new ArrayList<ODocument>(Arrays.asList(c1, c2, c3))); rootDocument.save(); final List<ODocument> expectedResult = Arrays.asList(rootDocument, a, b, aa, ab, ba, bb, c1, c2, c3, c1a, c1b, c2a, c2b, c3a, c3b); final List<OIdentifiable> results = traverse.execute(); compareTraverseResults(expectedResult, results); }
81. OTraverseTest#testDepthTraverse()
Project: orientdb
File: OTraverseTest.java
File: OTraverseTest.java
@Test public void testDepthTraverse() throws Exception { final ODocument aa = new ODocument(); final ODocument ab = new ODocument(); final ODocument ba = new ODocument(); final ODocument bb = new ODocument(); final ODocument a = new ODocument(); a.field("aa", aa); a.field("ab", ab); final ODocument b = new ODocument(); b.field("ba", ba); b.field("bb", bb); rootDocument.field("a", a); rootDocument.field("b", b); final ODocument c1 = new ODocument(); final ODocument c1a = new ODocument(); c1.field("c1a", c1a); final ODocument c1b = new ODocument(); c1.field("c1b", c1b); final ODocument c2 = new ODocument(); final ODocument c2a = new ODocument(); c2.field("c2a", c2a); final ODocument c2b = new ODocument(); c2.field("c2b", c2b); final ODocument c3 = new ODocument(); final ODocument c3a = new ODocument(); c3.field("c3a", c3a); final ODocument c3b = new ODocument(); c3.field("c3b", c3b); rootDocument.field("c", new ArrayList<ODocument>(Arrays.asList(c1, c2, c3))); rootDocument.save(); final List<ODocument> expectedResult = Arrays.asList(rootDocument, a, aa, ab, b, ba, bb, c1, c1a, c1b, c2, c2a, c2b, c3, c3a, c3b); final List<OIdentifiable> results = traverse.execute(); compareTraverseResults(expectedResult, results); }
82. ORidBagAtomicUpdateTest#testAddInternalDocumentsAndSubDocuments()
Project: orientdb
File: ORidBagAtomicUpdateTest.java
File: ORidBagAtomicUpdateTest.java
public void testAddInternalDocumentsAndSubDocuments() { database.begin(); ODocument rootDoc = new ODocument(); ORidBag ridBag = new ORidBag(); rootDoc.field("ridBag", ridBag); ODocument docOne = new ODocument(); docOne.save(); ODocument docTwo = new ODocument(); docTwo.save(); ridBag.add(docOne); ridBag.add(docTwo); rootDoc.save(); database.commit(); long recordsCount = database.countClusterElements(database.getDefaultClusterId()); rootDoc = database.load(rootDoc.getIdentity()); ridBag = rootDoc.field("ridBag"); database.begin(); ODocument docThree = new ODocument(); docThree.save(); ODocument docFour = new ODocument(); docFour.save(); ridBag.add(docThree); ridBag.add(docFour); rootDoc.save(); ODocument docThreeOne = new ODocument(); docThreeOne.save(); ODocument docThreeTwo = new ODocument(); docThreeTwo.save(); ORidBag ridBagThree = new ORidBag(); ridBagThree.add(docThreeOne); ridBagThree.add(docThreeTwo); docThree.field("ridBag", ridBagThree); docThree.save(); ODocument docFourOne = new ODocument(); docFourOne.save(); ODocument docFourTwo = new ODocument(); docFourTwo.save(); ORidBag ridBagFour = new ORidBag(); ridBagFour.add(docFourOne); ridBagFour.add(docFourTwo); docFour.field("ridBag", ridBagFour); docFour.save(); database.rollback(); Assert.assertEquals(database.countClusterElements(database.getDefaultClusterId()), recordsCount); List<OIdentifiable> addedDocs = new ArrayList<OIdentifiable>(Arrays.asList(docOne, docTwo)); rootDoc = database.load(rootDoc.getIdentity()); ridBag = rootDoc.field("ridBag"); Iterator<OIdentifiable> iterator = ridBag.iterator(); Assert.assertTrue(addedDocs.remove(iterator.next())); Assert.assertTrue(addedDocs.remove(iterator.next())); }
83. DocumentTest#testFromMapWithClassAndRid()
Project: orientdb
File: DocumentTest.java
File: DocumentTest.java
public void testFromMapWithClassAndRid() { final ODocument doc = new ODocument("V"); doc.field("name", "Jay"); doc.field("surname", "Miner"); doc.save(); Map<String, Object> map = doc.toMap(); Assert.assertEquals(map.size(), 4); Assert.assertEquals(map.get("name"), "Jay"); Assert.assertEquals(map.get("surname"), "Miner"); Assert.assertEquals(map.get("@class"), "V"); Assert.assertTrue(map.containsKey("@rid")); }
84. DocumentJavaSerializationTest#testBinaryCsvSerialization()
Project: orientdb
File: DocumentJavaSerializationTest.java
File: DocumentJavaSerializationTest.java
@Test public void testBinaryCsvSerialization() throws IOException, ClassNotFoundException { OGlobalConfiguration.DB_DOCUMENT_SERIALIZER.setValue(ORecordSerializerBinary.NAME); ODatabaseDocumentTx.setDefaultSerializer(ORecordSerializerFactory.instance().getFormat(ORecordSerializerBinary.NAME)); ODocument doc = new ODocument(); ORecordInternal.setRecordSerializer(doc, ORecordSerializerFactory.instance().getFormat(ORecordSerializerBinary.NAME)); doc.field("one", "one"); doc.field("two", "two"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(doc); OGlobalConfiguration.DB_DOCUMENT_SERIALIZER.setValue(ORecordSerializerSchemaAware2CSV.NAME); ODatabaseDocumentTx.setDefaultSerializer(ORecordSerializerFactory.instance().getFormat(ORecordSerializerSchemaAware2CSV.NAME)); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); ODocument doc1 = (ODocument) ois.readObject(); assertEquals("one", doc1.field("one")); assertEquals("two", doc1.field("two")); }
85. DocumentJavaSerializationTest#testCsvBinarySerialization()
Project: orientdb
File: DocumentJavaSerializationTest.java
File: DocumentJavaSerializationTest.java
@Test public void testCsvBinarySerialization() throws IOException, ClassNotFoundException { OGlobalConfiguration.DB_DOCUMENT_SERIALIZER.setValue(ORecordSerializerSchemaAware2CSV.NAME); ODatabaseDocumentTx.setDefaultSerializer(ORecordSerializerFactory.instance().getFormat(ORecordSerializerSchemaAware2CSV.NAME)); ODocument doc = new ODocument(); ORecordInternal.setRecordSerializer(doc, ORecordSerializerFactory.instance().getFormat(ORecordSerializerSchemaAware2CSV.NAME)); doc.field("one", "one"); doc.field("two", "two"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(doc); OGlobalConfiguration.DB_DOCUMENT_SERIALIZER.setValue(ORecordSerializerBinary.NAME); ODatabaseDocumentTx.setDefaultSerializer(ORecordSerializerFactory.instance().getFormat(ORecordSerializerBinary.NAME)); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); ODocument doc1 = (ODocument) ois.readObject(); assertEquals("one", doc1.field("one")); assertEquals("two", doc1.field("two")); }
86. DocumentJavaSerializationTest#testSimpleSerialization()
Project: orientdb
File: DocumentJavaSerializationTest.java
File: DocumentJavaSerializationTest.java
@Test public void testSimpleSerialization() throws IOException, ClassNotFoundException { ODocument doc = new ODocument(); doc.field("one", "one"); doc.field("two", "two"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(doc); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); ODocument doc1 = (ODocument) ois.readObject(); assertEquals("one", doc1.field("one")); assertEquals("two", doc1.field("two")); }
87. OMVRBTreeRIDProvider#toDocument()
Project: orientdb
File: OMVRBTreeRIDProvider.java
File: OMVRBTreeRIDProvider.java
public ODocument toDocument() { tree.saveAllNewEntries(); // SERIALIZE AS LINK TO THE TREE STRUCTURE final ODocument doc = (ODocument) record; doc.setClassName(PERSISTENT_CLASS_NAME); doc.field("root", root != null ? root : null); doc.field("keySize", keySize); if (tree.getTemporaryEntries() != null && tree.getTemporaryEntries().size() > 0) doc.field("tempEntries", new ArrayList<ORecord>(tree.getTemporaryEntries().keySet())); return doc; }
88. OStreamSerializerOldRIDContainer#containerToStream()
Project: orientdb
File: OStreamSerializerOldRIDContainer.java
File: OStreamSerializerOldRIDContainer.java
private byte[] containerToStream(OIndexRIDContainer object) { StringBuilder iOutput = new StringBuilder(); iOutput.append(OStringSerializerHelper.LINKSET_PREFIX); object.checkNotEmbedded(); final OIndexRIDContainerSBTree tree = ((OIndexRIDContainerSBTree) object.getUnderlying()); final ODocument document = new ODocument(); document.field("rootIndex", tree.getRootPointer().getPageIndex()); document.field("rootOffset", tree.getRootPointer().getPageOffset()); document.field("file", tree.getName()); iOutput.append(new String(document.toStream())); iOutput.append(OStringSerializerHelper.SET_END); return iOutput.toString().getBytes(); }
89. OHazelcastPlugin#getClusterConfiguration()
Project: orientdb
File: OHazelcastPlugin.java
File: OHazelcastPlugin.java
@Override public ODocument getClusterConfiguration() { if (!enabled) return null; final HazelcastInstance instance = getHazelcastInstance(); if (instance == null) return null; final ODocument cluster = new ODocument(); cluster.field("localName", instance.getName()); cluster.field("localId", instance.getCluster().getLocalMember().getUuid()); // INSERT MEMBERS final List<ODocument> members = new ArrayList<ODocument>(); cluster.field("members", members, OType.EMBEDDEDLIST); // members.add(getLocalNodeConfiguration()); for (Member member : activeNodes.values()) { members.add(getNodeConfigurationById(member.getUuid())); } return cluster; }
90. TestBinaryRecordsQuery#testDeleteFromSelectBinary()
Project: orientdb
File: TestBinaryRecordsQuery.java
File: TestBinaryRecordsQuery.java
@Test public void testDeleteFromSelectBinary() { ORecord rec = database.save(new ORecordBytes("blabla".getBytes()), "BlobCluster"); ORecord rec1 = database.save(new ORecordBytes("blabla".getBytes()), "BlobCluster"); database.getMetadata().getSchema().createClass("RecordPointer"); ODocument doc = new ODocument("RecordPointer"); doc.field("ref", rec); database.save(doc); ODocument doc1 = new ODocument("RecordPointer"); doc1.field("ref", rec1); database.save(doc1); Integer res = database.command(new OCommandSQL("delete from (select expand(ref) from RecordPointer)")).execute(); database.getLocalCache().clear(); assertEquals(2, res.intValue()); rec = database.load(rec.getIdentity()); assertNull(rec); rec = database.load(rec1.getIdentity()); assertNull(rec); }
91. OCommandExecutorSQLUpdateTest#testSingleQuoteStringInNamedParameter()
Project: orientdb
File: OCommandExecutorSQLUpdateTest.java
File: OCommandExecutorSQLUpdateTest.java
@Test public void testSingleQuoteStringInNamedParameter() throws Exception { final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLUpdateTestSingleQuoteStringInNamedParameter"); db.create(); db.command(new OCommandSQL("CREATE class test")).execute(); final ODocument test = new ODocument("test"); test.field("text", "initial value"); db.save(test); ODocument queried = (ODocument) db.query(new OSQLSynchQuery<Object>("SELECT FROM test")).get(0); assertEquals(queried.field("text"), "initial value"); OCommandSQL command = new OCommandSQL("UPDATE test SET text = :text"); Map<String, Object> params = new HashMap<String, Object>(); params.put("text", "quoted 'value' string"); db.command(command).execute(params); queried.reload(); assertEquals(queried.field("text"), "quoted 'value' string"); db.close(); }
92. OCommandExecutorSQLUpdateTest#testQuotedStringInNamedParameter()
Project: orientdb
File: OCommandExecutorSQLUpdateTest.java
File: OCommandExecutorSQLUpdateTest.java
@Test public void testQuotedStringInNamedParameter() throws Exception { final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLUpdateTestQuotedStringInNamedParameter"); db.create(); db.command(new OCommandSQL("CREATE class test")).execute(); final ODocument test = new ODocument("test"); test.field("text", "initial value"); db.save(test); ODocument queried = (ODocument) db.query(new OSQLSynchQuery<Object>("SELECT FROM test")).get(0); assertEquals(queried.field("text"), "initial value"); OCommandSQL command = new OCommandSQL("UPDATE test SET text = :text"); Map<String, Object> params = new HashMap<String, Object>(); params.put("text", "quoted \"value\" string"); db.command(command).execute(params); queried.reload(); assertEquals(queried.field("text"), "quoted \"value\" string"); db.close(); }
93. OCommandExecutorSQLUpdateTest#testSingleQuoteInNamedParameter()
Project: orientdb
File: OCommandExecutorSQLUpdateTest.java
File: OCommandExecutorSQLUpdateTest.java
@Test public void testSingleQuoteInNamedParameter() throws Exception { final ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:OCommandExecutorSQLUpdateTestSingleQuoteInNamedParameter"); db.create(); db.command(new OCommandSQL("CREATE class test")).execute(); final ODocument test = new ODocument("test"); test.field("text", "initial value"); db.save(test); ODocument queried = (ODocument) db.query(new OSQLSynchQuery<Object>("SELECT FROM test")).get(0); assertEquals(queried.field("text"), "initial value"); OCommandSQL command = new OCommandSQL("UPDATE test SET text = :text"); Map<String, Object> params = new HashMap<String, Object>(); params.put("text", "single \""); db.command(command).execute(params); queried.reload(); assertEquals(queried.field("text"), "single \""); db.close(); }
94. OCompositeIndexDefinitionTest#testDocumentToIndexCollectionValueSuccessfulThree()
Project: orientdb
File: OCompositeIndexDefinitionTest.java
File: OCompositeIndexDefinitionTest.java
@Test public void testDocumentToIndexCollectionValueSuccessfulThree() { final ODocument document = new ODocument(); document.field("fOne", 12); document.field("fTwo", Arrays.asList(1, 2)); document.field("fThree", "test"); final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass"); compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); final ArrayList<OCompositeKey> expectedResult = new ArrayList<OCompositeKey>(); expectedResult.add(new OCompositeKey(12, 1, "test")); expectedResult.add(new OCompositeKey(12, 2, "test")); Assert.assertEquals(result, expectedResult); }
95. ORidBagTest#testMassiveChanges()
Project: orientdb
File: ORidBagTest.java
File: ORidBagTest.java
public void testMassiveChanges() { ODocument document = new ODocument(); ORidBag bag = new ORidBag(); assertEmbedded(bag.isEmbedded()); Random random = new Random(); List<OIdentifiable> rids = new ArrayList<OIdentifiable>(); document.field("bag", bag); document.save(); ORID rid = document.getIdentity(); for (int i = 0; i < 10; i++) { document = database.load(rid); document.setLazyLoad(false); bag = document.field("bag"); assertEmbedded(bag.isEmbedded()); massiveInsertionIteration(random, rids, bag); assertEmbedded(bag.isEmbedded()); document.save(); } document.delete(); }
96. IndexConcurrencyTest#AddChild()
Project: orientdb
File: IndexConcurrencyTest.java
File: IndexConcurrencyTest.java
ODocument AddChild(ODocument parent, String name, String identifier) { ODocument child = new ODocument("Person").field("name", name).field("identifier", identifier).field("in", new HashSet<ODocument>()).field("out", new HashSet<ODocument>()); child.save(); elements.put(child.getIdentity(), child); ODocument edge = new ODocument("E").field("in", parent.getIdentity()).field("out", child.getIdentity()); edge.save(); elements.put(edge.getIdentity(), edge); child.<Collection<ODocument>>field("in").add(edge); parent.<Collection<ODocument>>field("out").add(edge); return child; }
97. ClassIndexManagerTest#testPropertiesCheckUniqueIndexInParentDubKeysCreate()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testPropertiesCheckUniqueIndexInParentDubKeysCreate() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); docOne.field("prop0", "a"); docOne.save(); boolean exceptionThrown = false; try { docTwo.field("prop0", "a"); docTwo.save(); } catch (OResponseProcessingException e) { Assert.assertTrue(e.getCause() instanceof ORecordDuplicatedException); exceptionThrown = true; } catch (ORecordDuplicatedException e) { exceptionThrown = true; } Assert.assertTrue(exceptionThrown); }
98. ClassIndexManagerTest#testPropertiesCheckUniqueIndexDubKeysCreate()
Project: orientdb
File: ClassIndexManagerTest.java
File: ClassIndexManagerTest.java
public void testPropertiesCheckUniqueIndexDubKeysCreate() { final ODocument docOne = new ODocument("classIndexManagerTestClass"); final ODocument docTwo = new ODocument("classIndexManagerTestClass"); docOne.field("prop1", "a"); docOne.save(); boolean exceptionThrown = false; try { docTwo.field("prop1", "a"); docTwo.save(); } catch (OResponseProcessingException e) { Assert.assertTrue(e.getCause() instanceof ORecordDuplicatedException); exceptionThrown = true; } catch (ORecordDuplicatedException e) { exceptionThrown = true; } Assert.assertTrue(exceptionThrown); }
99. ODistributedConfiguration#createCluster()
Project: orientdb
File: ODistributedConfiguration.java
File: ODistributedConfiguration.java
public ODocument createCluster(final String iClusterName) { // CREATE IT final ODocument clusters = configuration.field("clusters"); ODocument cluster = clusters.field(iClusterName); if (cluster != null) // ALREADY EXISTS return clusters; cluster = new ODocument(); ODocumentInternal.addOwner(cluster, clusters); clusters.field(iClusterName, cluster, OType.EMBEDDED); initClusterServers(cluster); return cluster; }
100. JSONTest#testList()
Project: orientdb
File: JSONTest.java
File: JSONTest.java
@Test public void testList() throws Exception { ODocument documentSource = new ODocument(); documentSource.fromJSON("{\"list\" : [\"string\", 42]}"); ODocument documentTarget = new ODocument(); documentTarget.fromStream(documentSource.toStream()); OTrackedList<Object> list = documentTarget.field("list", OType.EMBEDDEDLIST); Assert.assertEquals(list.get(0), "string"); Assert.assertEquals(list.get(1), 42); }