Examples of MongoMappingContext


Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  @Mock ResourceMappings mappings;

  @Before
  public void setUp() {

    MongoMappingContext context = new MongoMappingContext();
    context.getPersistentEntity(User.class);

    PersistentEntities entities = new PersistentEntities(Arrays.asList(context));

    this.handler = new JsonPatchHandler(new ObjectMapper(), new DomainObjectReader(entities, mappings));
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  @Before
  public void setUp() {

    this.links = new AssociationLinks(mappings);

    this.mappingContext = new MongoMappingContext();
    this.entity = mappingContext.getPersistentEntity(Sample.class);
    this.sampleResourceMetadata = new MappingResourceMetadata(entity);

    when(mappings.getMappingFor(Sample.class)).thenReturn(sampleResourceMetadata);
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  ObjectMapper mapper;

  @Before
  public void setUp() {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.getPersistentEntity(Sample.class);
    mappingContext.getPersistentEntity(SampleWithAdditionalGetters.class);

    PersistentEntities persistentEntities = new PersistentEntities(Arrays.asList(mappingContext));

    SimpleModule module = new SimpleModule();
    module.setSerializerModifier(new PersistentEntityJackson2Module.AssociationOmittingSerializerModifier(
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

        return new DefaultMongoTypeMapper(null);
    }

    @Bean
    public MongoMappingContext mongoMappingContext() {
        return new MongoMappingContext();
    }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

        return new DefaultMongoTypeMapper(null);
    }

    @Bean
    public MongoMappingContext mongoMappingContext() {
        return new MongoMappingContext();
    }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  }

  @Test
  public void buildsIndexDefinitionUsingFieldName() {

    MongoMappingContext mappingContext = prepareMappingContext(Person.class);

    new MongoPersistentEntityIndexCreator(mappingContext, factory);

    assertThat(keysCaptor.getValue(), is(notNullValue()));
    assertThat(keysCaptor.getValue().keySet(), hasItem("fieldname"));
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

  }

  @Test
  public void doesNotCreateIndexForEntityComingFromDifferentMappingContext() {

    MongoMappingContext mappingContext = new MongoMappingContext();
    MongoMappingContext personMappingContext = prepareMappingContext(Person.class);

    MongoPersistentEntityIndexCreator creator = new MongoPersistentEntityIndexCreator(mappingContext, factory);

    MongoPersistentEntity<?> entity = personMappingContext.getPersistentEntity(Person.class);
    MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty> event = new MappingContextEvent<MongoPersistentEntity<?>, MongoPersistentProperty>(
        personMappingContext, entity);

    creator.onApplicationEvent(event);
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

   * @see DATAMONGO-530
   */
  @Test
  public void isIndexCreatorForMappingContextHandedIntoConstructor() {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.initialize();

    MongoPersistentEntityIndexCreator creator = new MongoPersistentEntityIndexCreator(mappingContext, factory);
    assertThat(creator.isIndexCreatorFor(mappingContext), is(true));
    assertThat(creator.isIndexCreatorFor(new MongoMappingContext()), is(false));
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

   * @see DATAMONGO-554
   */
  @Test
  public void triggersBackgroundIndexingIfConfigured() {

    MongoMappingContext mappingContext = prepareMappingContext(AnotherPerson.class);
    new MongoPersistentEntityIndexCreator(mappingContext, factory);

    assertThat(keysCaptor.getValue(), is(notNullValue()));
    assertThat(keysCaptor.getValue().keySet(), hasItem("lastname"));
    assertThat(optionsCaptor.getValue().get("name").toString(), is("lastname"));
View Full Code Here

Examples of org.springframework.data.mongodb.core.mapping.MongoMappingContext

   * @see DATAMONGO-544
   */
  @Test
  public void expireAfterSecondsIfConfigured() {

    MongoMappingContext mappingContext = prepareMappingContext(Milk.class);
    new MongoPersistentEntityIndexCreator(mappingContext, factory);

    assertThat(keysCaptor.getValue(), is(notNullValue()));
    assertThat(keysCaptor.getValue().keySet(), hasItem("expiry"));
    assertThat(optionsCaptor.getValue().get("expireAfterSeconds"), IsEqual.<Object> equalTo(60L));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.