|
|
|
@ -43,6 +43,7 @@ import com.mongodb.client.model.IndexOptions; |
|
|
|
* Unit tests for {@link DefaultIndexOperations}. |
|
|
|
* Unit tests for {@link DefaultIndexOperations}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Christoph Strobl |
|
|
|
* @author Christoph Strobl |
|
|
|
|
|
|
|
* @author Mark Paluch |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
|
@ExtendWith(MockitoExtension.class) |
|
|
|
public class DefaultIndexOperationsUnitTests { |
|
|
|
public class DefaultIndexOperationsUnitTests { |
|
|
|
@ -121,6 +122,15 @@ public class DefaultIndexOperationsUnitTests { |
|
|
|
verify(collection).createIndex(eq(new Document("firstname", "hashed")), any()); |
|
|
|
verify(collection).createIndex(eq(new Document("firstname", "hashed")), any()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test // GH-4698
|
|
|
|
|
|
|
|
void shouldConsiderGivenCollectionName() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DefaultIndexOperations operations = new DefaultIndexOperations(template, "foo", Jedi.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
operations.ensureIndex(HashedIndex.hashed("name")); |
|
|
|
|
|
|
|
verify(db).getCollection(eq("foo"), any(Class.class)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private DefaultIndexOperations indexOpsFor(Class<?> type) { |
|
|
|
private DefaultIndexOperations indexOpsFor(Class<?> type) { |
|
|
|
return new DefaultIndexOperations(template, template.getCollectionName(type), type); |
|
|
|
return new DefaultIndexOperations(template, template.getCollectionName(type), type); |
|
|
|
} |
|
|
|
} |
|
|
|
|