From a5bb68b6a631373693d3c02b5c1d095101a11a91 Mon Sep 17 00:00:00 2001 From: Sijie Date: Sat, 13 Jan 2024 14:09:58 -0500 Subject: [PATCH] update updateInt2Long logic --- .../mongo/MongoStorageStartUpTest.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java b/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java index 958e8e7d..b4b13355 100644 --- a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java +++ b/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java @@ -6,10 +6,7 @@ import static us.kbase.test.auth2.TestCommon.set; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -160,20 +157,16 @@ public void indexesConfig() { indexes.forEach(doc -> doc.remove("ns")); indexes.forEach(this::updateInt2Long); assertThat("incorrect indexes", indexes, is(set( -// new Document("v", (long) indexVer) -// .append("unique", true) -// .append("key", new Document("schema", 1L)) -// .append("name", "schema_1"), - new Document("v", (long) indexVer) - .append("key", new Document("_id", 1L)) - .append("name", "_id_"), new Document("v", (long) indexVer) .append("unique", true) .append("key", new Document("schema", 1L)) - .append("name", "schema_1") + .append("name", "schema_1"), + new Document("v", (long) indexVer) + .append("key", new Document("_id", 1L)) + .append("name", "_id_") ))); } - + @Test public void indexesConfigApp() { final Set indexes = new HashSet<>(); @@ -424,8 +417,9 @@ public void updateInt2Long(final Document doc) { if (key.equals("key")) { Document valDoc = (Document) val; for (String dkey: valDoc.keySet()) { - if (valDoc.get(dkey) instanceof Number) { - valDoc.put(dkey, ((Number) valDoc.get(dkey)).longValue()); + Object dval = valDoc.get(dkey); + if (dval instanceof Number) { + valDoc.put(dkey, ((Number) dval).longValue()); } } } else {