Package org.springframework.data.mongodb.core.mapping

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


  SpringDataMongodbSerializer serializer;

  @Before
  public void setUp() {

    MongoMappingContext context = new MongoMappingContext();

    this.converter = new MappingMongoConverter(dbFactory, context);
    this.serializer = new SpringDataMongodbSerializer(converter);
  }
View Full Code Here


  @Rule public ExpectedException expection = ExpectedException.none();

  @Before
  public void setUp() throws SecurityException, NoSuchMethodException {

    context = new MongoMappingContext();

    doAnswer(new Answer<Object>() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        return invocation.getArguments()[0];
      }
View Full Code Here

    PartTree tree = new PartTree("findByLocationNearAndFirstname",
        org.springframework.data.mongodb.repository.Person.class);
    Method method = PersonRepository.class.getMethod("findByLocationNearAndFirstname", Point.class, Distance.class,
        String.class);
    MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(PersonRepository.class),
        new MongoMappingContext());
    MongoParameterAccessor accessor = new MongoParametersParameterAccessor(queryMethod, new Object[] { point, distance,
        "Dave" });

    Query query = new MongoQueryCreator(tree, new ConvertingParameterAccessor(converter, accessor), context)
        .createQuery();
View Full Code Here

  AuditingEventListener listener;

  @Before
  public void setUp() {

    MongoMappingContext mappingContext = new MongoMappingContext();

    handler = spy(new IsNewAwareAuditingHandler(mappingContext));
    doNothing().when(handler).markCreated(Mockito.any(Object.class));
    doNothing().when(handler).markModified(Mockito.any(Object.class));
View Full Code Here

  }

  private static List<IndexDefinitionHolder> prepareMappingContextAndResolveIndexForType(Class<?> type) {

    MongoMappingContext mappingContext = prepareMappingContext(type);
    MongoPersistentEntityIndexResolver resolver = new MongoPersistentEntityIndexResolver(mappingContext);
    return resolver.resolveIndexForEntity(mappingContext.getPersistentEntity(type));
  }
View Full Code Here

    return resolver.resolveIndexForEntity(mappingContext.getPersistentEntity(type));
  }

  private static MongoMappingContext prepareMappingContext(Class<?> type) {

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(Collections.singleton(type));
    mappingContext.initialize();

    return mappingContext;
  }
View Full Code Here

  @Mock DbRefResolver dbRefResolver;

  @Before
  public void setUp() {

    this.context = new MongoMappingContext();
    this.converter = new MappingMongoConverter(dbRefResolver, context);
    this.mapper = new QueryMapper(converter);
  }
View Full Code Here

  }

  @Test
  public void shouldConvertCompoundExpressionToPropertyPath() {

    MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, new MongoMappingContext());
    TypeBasedAggregationOperationContext ctxt = new TypeBasedAggregationOperationContext(Data.class,
        new MongoMappingContext(), new QueryMapper(converter));
    assertThat(transformer.transform("item.primitiveIntValue", ctxt, new Object[0]).toString(),
        is("$item.primitiveIntValue"));
  }
View Full Code Here

  public void shouldThrowExceptionIfNestedPropertyCannotBeFound() {

    exception.expect(MappingException.class);
    exception.expectMessage("value2");

    MappingMongoConverter converter = new MappingMongoConverter(dbRefResolver, new MongoMappingContext());
    TypeBasedAggregationOperationContext ctxt = new TypeBasedAggregationOperationContext(Data.class,
        new MongoMappingContext(), new QueryMapper(converter));
    assertThat(transformer.transform("item.value2", ctxt, new Object[0]).toString(), is("$item.value2"));
  }
View Full Code Here

  @Test
  public void returnsUninitializedMappingContext() throws Exception {

    SampleMongoConfiguration configuration = new SampleMongoConfiguration();
    MongoMappingContext context = configuration.mongoMappingContext();

    assertThat(context.getPersistentEntities(), is(emptyIterable()));
    context.initialize();
    assertThat(context.getPersistentEntities(), is(not(emptyIterable())));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.mapping.MongoMappingContext

Copyright © 2018 www.massapicom. 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.