Skip to content

Commit

Permalink
refactor(test): reduced use of deprecated APIs in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Oct 4, 2024
1 parent f567191 commit f6e79e6
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ public void testToJSONWithNoLazyLoadAndClosedDatabase() {
String jsonFull = doc.toJSON();
ORID rid = doc.getIdentity();
database.close();
database.open("admin", "admin");
reopendb("admin", "admin");
doc = database.load(rid);
doc.setLazyLoad(false);
doc.reload("*:0");
database.close();
String jsonLoaded = doc.toJSON();
Assert.assertEquals(jsonLoaded, jsonFull);
database.open("admin", "admin");
reopendb("admin", "admin");
doc = database.load(rid);
doc.setLazyLoad(false);
doc.load("*:0");
Expand All @@ -478,14 +478,14 @@ public void testToJSONWithNoLazyLoadAndClosedDatabase() {
Assert.assertEquals(jsonLoaded, jsonFull);
}

if (database.isClosed()) database.open("admin", "admin");
if (database.isClosed()) reopendb("admin", "admin");

for (ODocument doc : result) {
doc.reload("*:1");
String jsonFull = doc.toJSON();
ORID rid = doc.getIdentity();
database.close();
database.open("admin", "admin");
reopendb("admin", "admin");
doc = database.load(rid);
doc.setLazyLoad(false);
doc.reload("*:1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.orientechnologies.orient.core.sql.OCommandSQL;
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 java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -73,7 +72,7 @@ public void insertOperator() {
int addressId = database.getMetadata().getSchema().getClass("Address").getDefaultClusterId();

for (int i = 0; i < 30; i++) {
new ODocument("Address").save();
database.save(new ODocument("Address"));
}
List<Long> positions = getValidPositions(addressId);

Expand Down Expand Up @@ -179,7 +178,6 @@ public void insertWithWildcards() {
}

@Test
@SuppressWarnings("unchecked")
public void insertMap() {
OElement doc =
database
Expand Down Expand Up @@ -231,7 +229,6 @@ public void insertMap() {
}

@Test
@SuppressWarnings("unchecked")
public void insertList() {
OElement doc =
database
Expand Down Expand Up @@ -386,12 +383,11 @@ public void insertSelect() {
.count();
Assert.assertEquals(inserted, 2);

List<OIdentifiable> result =
database.query(new OSQLSynchQuery<OIdentifiable>("select from UserCopy"));
List<OResult> result = database.query("select from UserCopy").stream().toList();
Assert.assertEquals(result.size(), 2);
for (OIdentifiable r : result) {
Assert.assertEquals(((ODocument) r.getRecord()).getClassName(), "UserCopy");
Assert.assertNotSame(((ODocument) r.getRecord()).field("name"), "admin");
for (OResult r : result) {
Assert.assertEquals(r.getElement().get().getSchemaType().get().getName(), "UserCopy");
Assert.assertNotSame(r.getProperty("name"), "admin");
}
}

Expand Down
Loading

0 comments on commit f6e79e6

Please sign in to comment.