Skip to content

Commit

Permalink
refactor(test): removed usage of deprecated APIs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Nov 4, 2024
1 parent 1e4112b commit 51dec89
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.OElement;
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.util.ArrayList;
Expand Down Expand Up @@ -511,10 +510,9 @@ public void testEscaping() {

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

database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \b bbb");
Expand All @@ -530,10 +528,9 @@ public void testEscaping() {

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

database.reload(document);
Assert.assertEquals(document.field("test"), "aaa \f bbb");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.orientechnologies.orient.core.sql.OCommandSQLParsingException;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.orientechnologies.orient.core.storage.cluster.OOfflineClusterException;
import java.io.IOException;
import java.util.HashSet;
Expand Down Expand Up @@ -781,39 +780,31 @@ public void testCaseSensitivePropNames() {
schema.dropClass(className);
}

private void swapClusters(ODatabaseDocumentInternal databaseDocumentTx, int i) {
databaseDocumentTx
private void swapClusters(ODatabaseDocumentInternal session, int i) {
session
.command("CREATE CLASS TestRenameClusterNew extends TestRenameClusterOriginal clusters 2")
.close();

databaseDocumentTx
.command("INSERT INTO TestRenameClusterNew (iteration) VALUES(" + i + ")")
.close();
session.command("INSERT INTO TestRenameClusterNew (iteration) VALUES(" + i + ")").close();

databaseDocumentTx
session
.command("ALTER CLASS TestRenameClusterOriginal removecluster TestRenameClusterOriginal")
.close();
databaseDocumentTx
.command("ALTER CLASS TestRenameClusterNew removecluster TestRenameClusterNew")
.close();
databaseDocumentTx.command("DROP CLASS TestRenameClusterNew").close();
databaseDocumentTx
session.command("ALTER CLASS TestRenameClusterNew removecluster TestRenameClusterNew").close();
session.command("DROP CLASS TestRenameClusterNew").close();
session
.command("ALTER CLASS TestRenameClusterOriginal addcluster TestRenameClusterNew")
.close();
databaseDocumentTx.command("DROP CLUSTER TestRenameClusterOriginal").close();
databaseDocumentTx
.command(
new OCommandSQL("ALTER CLUSTER TestRenameClusterNew name TestRenameClusterOriginal"))
.execute();
session.command("DROP CLUSTER TestRenameClusterOriginal").close();
session.command("ALTER CLUSTER TestRenameClusterNew name TestRenameClusterOriginal").close();

databaseDocumentTx.getLocalCache().clear();
session.getLocalCache().clear();

List<ODocument> result =
databaseDocumentTx.query(
new OSQLSynchQuery<ODocument>("select * from TestRenameClusterOriginal"));
List<OResult> result =
session.query("select * from TestRenameClusterOriginal").stream().toList();
Assert.assertEquals(result.size(), 1);

ODocument document = result.get(0);
Assert.assertEquals(document.<Object>field("iteration"), i);
OResult document = result.get(0);
Assert.assertEquals(document.<Object>getProperty("iteration"), i);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void testSecurityAccessWriter() throws IOException {
reopendb("writer", "writer");

try {
new ODocument().save("internal");
database.save(new ODocument(), "internal");
Assert.assertTrue(false);
} catch (OSecurityAccessException e) {
Assert.assertTrue(true);
Expand Down

0 comments on commit 51dec89

Please sign in to comment.