Skip to content

Commit

Permalink
refactor(test): reduced usage of legacy query engine in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Oct 23, 2024
1 parent 796f372 commit 96a2388
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.record.OVertex;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import java.io.IOException;
Expand Down Expand Up @@ -366,7 +365,7 @@ public void testDeleteOfVerticesAndEdgesWithDeleteCommandAndUnsafe() {

public void testInsertOfEdgeWithInsertCommand() {
try {
database.command(new OCommandSQL("insert into E set a = 33")).execute();
database.command("insert into E set a = 33").close();
Assert.assertTrue(false);
} catch (OCommandExecutionException e) {
Assert.assertTrue(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,13 @@ public void insertSubQuery() {
@Test(dependsOnMethods = "insertOperator")
public void insertCluster() {
ODocument doc =
database
.command(
new OCommandSQL(
(ODocument)
database
.command(
"insert into Account cluster anotherdefault (id, title) values (10, 'NoSQL"
+ " movement')"))
.execute();
+ " movement')")
.next()
.toElement();

Assert.assertTrue(doc != null);
Assert.assertEquals(
Expand Down Expand Up @@ -628,12 +629,13 @@ public void testAutoConversionOfEmbeddededNoLinkedClass() {
c.createProperty("embeddedNoLinkedClass", OType.EMBEDDED);

ODocument doc =
database
.command(
new OCommandSQL(
(ODocument)
database
.command(
"INSERT INTO TestConvert SET name = 'embeddedNoLinkedClass',"
+ " embeddedNoLinkedClass = {'line1':'123 Fake Street'}"))
.execute();
+ " embeddedNoLinkedClass = {'line1':'123 Fake Street'}")
.next()
.toElement();

Assert.assertTrue(doc.field("embeddedNoLinkedClass") instanceof ODocument);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,23 @@ public void updateCollectionsWithSetOperator() {
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator")
public void updateMapsWithSetOperator() {

ODocument doc =
OElement doc =
database
.command(
new OCommandSQL(
"insert into cluster:default (equaledges, name, properties) values ('no',"
+ " 'circleUpdate', {'round':'eeee', 'blaaa':'zigzag'} )"))
.execute();
"insert into cluster:default (equaledges, name, properties) values ('no',"
+ " 'circleUpdate', {'round':'eeee', 'blaaa':'zigzag'} )")
.next()
.toElement();

Integer records =
Long records =
database
.command(
new OCommandSQL(
"update "
+ doc.getIdentity()
+ " set properties = {'roundOne':'ffff',"
+ " 'bla':'zagzig','testTestTEST':'okOkOK'}"))
.execute();
"update "
+ doc.getIdentity()
+ " set properties = {'roundOne':'ffff',"
+ " 'bla':'zagzig','testTestTEST':'okOkOK'}")
.next()
.getProperty("count");

Assert.assertEquals(records.intValue(), 1);

Expand All @@ -223,23 +223,23 @@ public void updateMapsWithSetOperator() {
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator")
public void updateMapsWithPutOperatorAndWhere() {

ODocument doc =
OElement doc =
database
.command(
new OCommandSQL(
"insert into cluster:default (equaledges, name, properties) values ('no',"
+ " 'updateMapsWithPutOperatorAndWhere', {} )"))
.execute();
"insert into cluster:default (equaledges, name, properties) values ('no',"
+ " 'updateMapsWithPutOperatorAndWhere', {} )")
.next()
.toElement();

Integer records =
Long records =
database
.command(
new OCommandSQL(
"update "
+ doc.getIdentity()
+ " put properties = 'one', 'two' where name ="
+ " 'updateMapsWithPutOperatorAndWhere'"))
.execute();
"update "
+ doc.getIdentity()
+ " set properties['one']= 'two' where name ="
+ " 'updateMapsWithPutOperatorAndWhere'")
.next()
.getProperty("count");

Assert.assertEquals(records.intValue(), 1);

Expand Down Expand Up @@ -286,7 +286,7 @@ public void updateWithWildcardsOnSetAndWhere() {
doc.field("name", "Raf");
doc.field("city", "Torino");
doc.field("gender", "fmale");
doc.save();
database.save(doc);
checkUpdatedDoc(database, "Raf", "Torino", "fmale");

/* THESE COMMANDS ARE OK */
Expand Down Expand Up @@ -468,15 +468,15 @@ public void testEscaping() {
schema.createClass("FormatEscapingTest");

final ODocument document = new ODocument("FormatEscapingTest");
document.save();
database.save(document);

database
.command(
"UPDATE FormatEscapingTest SET test = format('aaa \\' bbb') WHERE @rid = "
+ document.getIdentity())
.close();

document.reload();
database.reload(document);

Assert.assertEquals(document.field("test"), "aaa ' bbb");

Expand All @@ -487,7 +487,7 @@ public void testEscaping() {
+ document.getIdentity())
.close();

document.reload();
database.reload(document);
Assert.assertEquals(document.field("test"), "ccc ' eee");
Assert.assertEquals(document.field("test2"), "aaa ' bbb");

Expand All @@ -497,7 +497,7 @@ public void testEscaping() {
+ document.getIdentity())
.close();

document.reload();
database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \n bbb");

database
Expand All @@ -506,7 +506,7 @@ public void testEscaping() {
+ document.getIdentity())
.close();

document.reload();
database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \r bbb");

database
Expand All @@ -516,7 +516,7 @@ public void testEscaping() {
+ document.getIdentity()))
.execute();

document.reload();
database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \b bbb");

database
Expand All @@ -525,7 +525,7 @@ public void testEscaping() {
+ document.getIdentity())
.close();

document.reload();
database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \t bbb");

database
Expand All @@ -535,7 +535,7 @@ public void testEscaping() {
+ document.getIdentity()))
.execute();

document.reload();
database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \f bbb");
}

Expand Down Expand Up @@ -664,7 +664,8 @@ private List<Long> getValidPositions(int clusterId) {
}

public void testMultiplePut() {
final ODocument v = database.<ODocument>newInstance("V").save();
final ODocument v = database.<ODocument>newInstance("V");
database.save(v);

Long records =
database
Expand All @@ -677,7 +678,7 @@ public void testMultiplePut() {

Assert.assertEquals(records.intValue(), 1);

v.reload();
database.reload(v);

Assert.assertTrue(v.field("embmap") instanceof Map);
Assert.assertEquals(((Map) v.field("embmap")).size(), 2);
Expand Down Expand Up @@ -721,7 +722,7 @@ public void testAutoConversionOfEmbeddededListWithLinkedClass() {
+ " [{'line1':'123 Fake Street'}]")
.close();

doc.reload();
database.reload(doc);

Assert.assertTrue(doc.getProperty("embeddedListWithLinkedClass") instanceof List);
Assert.assertEquals(((Collection) doc.getProperty("embeddedListWithLinkedClass")).size(), 3);
Expand Down

0 comments on commit 96a2388

Please sign in to comment.