Skip to content

Commit

Permalink
update updateInt2Long logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangs18 committed Jan 13, 2024
1 parent ac2aedc commit a5bb68b
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Document> indexes = new HashSet<>();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a5bb68b

Please sign in to comment.