Examples of CustomConversions


Examples of org.springframework.data.mongodb.core.convert.CustomConversions

   *
   * @return must not be {@literal null}.
   */
  @Bean
  public CustomConversions customConversions() {
    return new CustomConversions(Collections.emptyList());
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.convert.CustomConversions

  @Autowired
  @SuppressWarnings("unchecked")
  public void setMongo(Mongo mongo) throws Exception {

    CustomConversions conversions = new CustomConversions(Arrays.asList(DateToDateTimeConverter.INSTANCE,
        DateTimeToDateConverter.INSTANCE));

    MongoMappingContext mappingContext = new MongoMappingContext();
    mappingContext.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(PersonWith_idPropertyOfTypeObjectId.class,
        PersonWith_idPropertyOfTypeString.class, PersonWithIdPropertyOfTypeObjectId.class,
        PersonWithIdPropertyOfTypeString.class, PersonWithIdPropertyOfTypeInteger.class,
        PersonWithIdPropertyOfTypeBigInteger.class, PersonWithIdPropertyOfPrimitiveInt.class,
        PersonWithIdPropertyOfTypeLong.class, PersonWithIdPropertyOfPrimitiveLong.class)));
    mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    mappingContext.initialize();

    DbRefResolver dbRefResolver = new DefaultDbRefResolver(factory);
    MappingMongoConverter mappingConverter = new MappingMongoConverter(dbRefResolver, mappingContext);
    mappingConverter.setCustomConversions(conversions);
View Full Code Here

Examples of org.springframework.data.mongodb.core.convert.CustomConversions

   */
  @Test
  public void scansForConverterAndSetsUpCustomConversionsAccordingly() {

    loadValidConfiguration();
    CustomConversions conversions = factory.getBean(CustomConversions.class);
    assertThat(conversions.hasCustomWriteTarget(Person.class), is(true));
    assertThat(conversions.hasCustomWriteTarget(Account.class), is(true));
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.convert.CustomConversions

   * @see DATAMONGO-912
   */
  @Test
  public void shouldUseCustomConversionIfPresentAndConversionIsRequiredInFirstStage() {

    CustomConversions customConversions = customAgeConversions();
    converter.setCustomConversions(customConversions);
    customConversions.registerConvertersIn((GenericConversionService) converter.getConversionService());

    AggregationOperationContext context = getContext(FooPerson.class);

    MatchOperation matchStage = match(Criteria.where("age").is(new Age(10)));
    ProjectionOperation projectStage = project("age", "name");
View Full Code Here

Examples of org.springframework.data.mongodb.core.convert.CustomConversions

   * @see DATAMONGO-912
   */
  @Test
  public void shouldUseCustomConversionIfPresentAndConversionIsRequiredInLaterStage() {

    CustomConversions customConversions = customAgeConversions();
    converter.setCustomConversions(customConversions);
    customConversions.registerConvertersIn((GenericConversionService) converter.getConversionService());

    AggregationOperationContext context = getContext(FooPerson.class);

    MatchOperation matchStage = match(Criteria.where("age").is(new Age(10)));
    ProjectionOperation projectStage = project("age", "name");
View Full Code Here

Examples of org.springframework.data.mongodb.core.convert.CustomConversions

      this.value = value;
    }
  }

  public CustomConversions customAgeConversions() {
    return new CustomConversions(Arrays.<Converter<?, ?>> asList(ageWriteConverter(), ageReadConverter()));
  }
View Full Code Here

Examples of org.springframework.data.mongodb.core.convert.CustomConversions

   * @see DATAMONGO-374
   */
  @Test
  public void convertsUpdateConstraintsUsingConverters() {

    CustomConversions conversions = new CustomConversions(Collections.singletonList(MyConverter.INSTANCE));
    this.converter.setCustomConversions(conversions);
    this.converter.afterPropertiesSet();

    Query query = new Query();
    Update update = new Update().set("foo", new AutogenerateableId());
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.