IndexFactory { public static Index newInstance(final String name, final List<String> fields, final boolean unique) { final List<IndexKey> keys = createDefaultKeys(requireNonNull(fields)); return newInstanceWithCustomKeys(name, keys, unique); } private  IndexFactory(); static Index newInstance(final String name, final List<String> fields, final boolean unique); static Index newInstanceWithCustomKeys(final String name, final List<IndexKey> keys, final boolean unique); static Index newExpirationIndex(final String name, final String field, final long expireAfterSeconds);  }
@Test public void newInstanceWithDefaultKeys() { final List<String> fields = Arrays.asList(FIELD_1_NAME, FIELD_2_NAME); final Index actual = IndexFactory.newInstance(INDEX_NAME, fields, UNIQUE); final BsonDocument expectedKeys = new BsonDocument(); expectedKeys.put(FIELD_1_NAME, IndexDirection.DEFAULT.getBsonInt()); expectedKeys.put(FIELD_2_NAME, IndexDirection.DEFAULT.getBsonInt()); final Index expected = Index.of(expectedKeys, INDEX_NAME, UNIQUE, UNIQUE, BACKGROUND); assertThat(actual).isEqualTo(expected); }