test_class.declarator: connectionFactory = new MongoConnectionFactory()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public MongoConnectionFactory connectionFactory = new MongoConnectionFactory();
test_class.type: MongoConnectionFactory
test_class.var_name: connectionFactory
test_class.file: oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtilsTest.java
test_class.identifier: MongoUtilsTest
test_case.body: @Test
      public void createIndex() {
          MongoConnection c = connectionFactory.getConnection();
          assertNotNull(c);
          c.getDatabase().drop();
          MongoCollection collection = c.getDatabase().getCollection("test");
          MongoUtils.createIndex(collection, "foo", true, false, true);
          MongoUtils.createIndex(collection, "bar", false, true, false);
          MongoUtils.createIndex(collection, new String[]{"baz", "qux"},
                  new boolean[]{true, false}, false, false);
  
          assertTrue(MongoUtils.hasIndex(collection, "_id"));
          assertTrue(MongoUtils.hasIndex(collection, "foo"));
          assertFalse(MongoUtils.hasIndex(collection, "foo", "bar"));
          assertTrue(MongoUtils.hasIndex(collection, "baz", "qux"));
  
          List<Document> indexes = new ArrayList<>();
          collection.listIndexes().into(indexes);
          assertEquals(4, indexes.size());
          for (Document info : indexes) {
              Document key = (Document) info.get("key");
              if (key.keySet().contains("foo")) {
                  assertEquals(1, key.keySet().size());
                  assertEquals(1, key.get("foo"));
                  assertEquals(Boolean.TRUE, info.get("sparse"));
              } else if (key.keySet().contains("bar")) {
                  assertEquals(1, key.keySet().size());
                  assertEquals(-1, key.get("bar"));
                  assertEquals(Boolean.TRUE, info.get("unique"));
              } else if (key.keySet().contains("baz")) {
                  assertEquals(2, key.keySet().size());
                  assertEquals(1, key.get("baz"));
                  assertEquals(-1, key.get("qux"));
              }
          }
  
          c.getDatabase().drop();
      }
test_case.class_method_signature: MongoUtilsTest.createIndex()
test_case.full_signature: @Test public void createIndex()
test_case.identifier: createIndex
test_case.invocations: getConnection assertNotNull drop getDatabase getCollection getDatabase createIndex createIndex createIndex assertTrue hasIndex assertTrue hasIndex assertFalse hasIndex assertTrue hasIndex into listIndexes assertEquals size get contains keySet assertEquals size keySet assertEquals get assertEquals get contains keySet assertEquals size keySet assertEquals get assertEquals get contains keySet assertEquals size keySet assertEquals get assertEquals get drop getDatabase
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void createIndex()
focal_class.file: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoUtils.java
focal_class.identifier: MongoUtils
focal_class.class_method_signature: MongoUtils.createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_class.full_signature: static void createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_class.identifier: createIndex
focal_class.modifiers: static
focal_class.parameters: (MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_class.return: void
focal_class.signature: void createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_class.class_method_signature: MongoUtils.createIndex(MongoCollection<?> collection,
                              String[] fields,
                              boolean[] ascending,
                              boolean unique,
                              boolean sparse)
focal_class.full_signature: static void createIndex(MongoCollection<?> collection,
                              String[] fields,
                              boolean[] ascending,
                              boolean unique,
                              boolean sparse)
focal_class.identifier: createIndex
focal_class.modifiers: static
focal_class.parameters: (MongoCollection<?> collection,
                              String[] fields,
                              boolean[] ascending,
                              boolean unique,
                              boolean sparse)
focal_class.return: void
focal_class.signature: void createIndex(MongoCollection<?> collection,
                              String[] fields,
                              boolean[] ascending,
                              boolean unique,
                              boolean sparse)
focal_class.class_method_signature: MongoUtils.createPartialIndex(MongoCollection<?> collection,
                                     String[] fields,
                                     boolean[] ascending,
                                     String filter)
focal_class.full_signature: static void createPartialIndex(MongoCollection<?> collection,
                                     String[] fields,
                                     boolean[] ascending,
                                     String filter)
focal_class.identifier: createPartialIndex
focal_class.modifiers: static
focal_class.parameters: (MongoCollection<?> collection,
                                     String[] fields,
                                     boolean[] ascending,
                                     String filter)
focal_class.return: void
focal_class.signature: void createPartialIndex(MongoCollection<?> collection,
                                     String[] fields,
                                     boolean[] ascending,
                                     String filter)
focal_class.class_method_signature: MongoUtils.hasIndex(MongoCollection<?> collection, String... fields)
focal_class.full_signature: static boolean hasIndex(MongoCollection<?> collection, String... fields)
focal_class.identifier: hasIndex
focal_class.modifiers: static
focal_class.parameters: (MongoCollection<?> collection, String... fields)
focal_class.return: boolean
focal_class.signature: boolean hasIndex(MongoCollection<?> collection, String... fields)
focal_class.class_method_signature: MongoUtils.isCollectionEmpty(@NotNull MongoCollection<?> collection,
                                       @Nullable ClientSession session)
focal_class.full_signature: static boolean isCollectionEmpty(@NotNull MongoCollection<?> collection,
                                       @Nullable ClientSession session)
focal_class.identifier: isCollectionEmpty
focal_class.modifiers: static
focal_class.parameters: (@NotNull MongoCollection<?> collection,
                                       @Nullable ClientSession session)
focal_class.return: boolean
focal_class.signature: boolean isCollectionEmpty(@NotNull MongoCollection<?> collection,
                                       @Nullable ClientSession session)
focal_class.class_method_signature: MongoUtils.getDocumentStoreExceptionTypeFor(Throwable t)
focal_class.full_signature: static Type getDocumentStoreExceptionTypeFor(Throwable t)
focal_class.identifier: getDocumentStoreExceptionTypeFor
focal_class.modifiers: static
focal_class.parameters: (Throwable t)
focal_class.return: Type
focal_class.signature: Type getDocumentStoreExceptionTypeFor(Throwable t)
focal_method.body: static void createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
              throws MongoException {
          createIndex(collection, new String[]{field},
                  new boolean[]{ascending}, unique, sparse);
      }
focal_method.class_method_signature: MongoUtils.createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_method.full_signature: static void createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_method.identifier: createIndex
focal_method.invocations: createIndex
focal_method.modifiers: static
focal_method.parameters: (MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)
focal_method.return: void
focal_method.signature: void createIndex(MongoCollection<?> collection,
                              String field,
                              boolean ascending,
                              boolean unique,
                              boolean sparse)