Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DATAMONGO-719 - cleanup tests
  • Loading branch information
ngbalk committed May 18, 2019
commit 5d46e3ec01b9532c6bf4183cea0eddabbdb3dcb6
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.mockito.Mockito.*;

import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -249,12 +248,12 @@ public void createIndexShouldCreateIndexesForDifferentPersistentEntitySameCollec

String collection1 = "collection1";
DynamicCollectionRouter.collectionName = collection1;
MongoMappingContext mappingContext = prepareMappingContext(DynamicCollectionDocument.class, OtherDynamicCollectionDocument.class);
MongoMappingContext mappingContext = prepareMappingContext(DynamicCollectionDocument.class, AnotherDynamicCollectionDocument.class);

MongoPersistentEntityIndexCreator indexCreator = new MongoPersistentEntityIndexCreator(mappingContext, mongoTemplate);

MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty> event = new MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty>(mappingContext, mappingContext.getRequiredPersistentEntity(DynamicCollectionDocument.class));
MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty> otherEvent = new MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty>(mappingContext, mappingContext.getRequiredPersistentEntity(OtherDynamicCollectionDocument.class));
MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty> otherEvent = new MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty>(mappingContext, mappingContext.getRequiredPersistentEntity(AnotherDynamicCollectionDocument.class));

String collection2 = "collection2";
DynamicCollectionRouter.collectionName = collection2;
Expand Down Expand Up @@ -340,31 +339,29 @@ class EntityWithGeneratedIndexName {
@Indexed(useGeneratedName = true, name = "ignored") String lastname;
}

public static class DynamicCollectionRouter {
static class DynamicCollectionRouter {
static String collectionName;

public static String determineCollection() {
return collectionName;
}
}

public static final String dynamicCollectionSpel = "#{ T(org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreatorUnitTests.DynamicCollectionRouter).determineCollection()}";
private static final String dynamicCollectionSpel = "#{ T(org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreatorUnitTests.DynamicCollectionRouter).determineCollection()}";

@Document(collection = dynamicCollectionSpel)
static class DynamicCollectionDocument {

@Indexed(name = "indexName") //
@Field("fieldname") //
String field;
@Indexed
String field;

}

@Document(collection = dynamicCollectionSpel)
static class OtherDynamicCollectionDocument {
static class AnotherDynamicCollectionDocument {

@Indexed(name = "otherIndexName") //
@Field("otherFieldName") //
String otherField;
@Indexed
String anotherField;

}

Expand Down