From 603423c71015751d75e1bfc1d47adf46b644cff3 Mon Sep 17 00:00:00 2001 From: Sijie Date: Sat, 13 Jan 2024 16:27:34 -0500 Subject: [PATCH] check document order --- .github/workflows/test.yml | 2 +- .../mongo/MongoStorageStartUpTest.java | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88b36eff..eceabf35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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' 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 a316c7a4..2d34b6ed 100644 --- a/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java +++ b/src/us/kbase/test/auth2/lib/storage/mongo/MongoStorageStartUpTest.java @@ -173,21 +173,8 @@ public void indexesConfigApp() { db.getCollection("config_app").listIndexes().forEach((Consumer) 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 expected = set( // new Document("v", indexVer) // .append("unique", true) // .append("key", new Document("key", 1)) @@ -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 @@ -447,4 +437,21 @@ public void updateInt2Long(final Document doc) { } } } + + public void display(final Set 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()); + } + } + } + } }