Skip to content

Commit

Permalink
check document order
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiangs18 committed Jan 13, 2024
1 parent 7d90c74 commit 603423c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- java: '8'
mongo: 'mongodb-linux-x86_64-ubuntu2204-7.0.4'
wired_tiger: 'false'
- java: '8'
- java: '11'
mongo: 'mongodb-linux-x86_64-3.6.23'
wired_tiger: 'true'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,8 @@ public void indexesConfigApp() {
db.getCollection("config_app").listIndexes().forEach((Consumer<Document>) indexes::add);
indexes.forEach(doc -> doc.remove("ns"));
// indexes.forEach(this::updateInt2Long);
for (Document doc: indexes) {
for (String key: doc.keySet()) {
if (key.equals("key")) {
Document dVal = (Document) doc.get(key);
for (String dkey: dVal.keySet()) {
Object dval = dVal.get(dkey);
System.out.println("key: " + dkey + " |" + " value: " + dval + " |" + " type: " + dval.getClass().getName());
}
} else {
Object val = doc.get(key);
System.out.println("key: " + key + " |" + " value: " + val + " |" + " type: " + val.getClass().getName());
}
}
}
assertThat("incorrect indexes", indexes, is(set(
display(indexes);
final Set<Document> expected = set(
// new Document("v", indexVer)
// .append("unique", true)
// .append("key", new Document("key", 1))
Expand All @@ -199,7 +186,10 @@ public void indexesConfigApp() {
.append("unique", true)
.append("key", new Document("key", 1))
.append("name", "key_1")
)));
);
System.out.println("-------------------------");
display(expected);
assertThat("incorrect indexes", indexes, is(expected));
}

@Test
Expand Down Expand Up @@ -447,4 +437,21 @@ public void updateInt2Long(final Document doc) {
}
}
}

public void display(final Set<Document> indexes) {
for (Document doc: indexes) {
for (String key: doc.keySet()) {
if (key.equals("key")) {
Document dVal = (Document) doc.get(key);
for (String dkey: dVal.keySet()) {
Object dval = dVal.get(dkey);
System.out.println("key: " + dkey + " |" + " value: " + dval + " |" + " type: " + dval.getClass().getName());
}
} else {
Object val = doc.get(key);
System.out.println("key: " + key + " |" + " value: " + val + " |" + " type: " + val.getClass().getName());
}
}
}
}
}

0 comments on commit 603423c

Please sign in to comment.