Examples of MongoPersistentProperty


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

  }

  private ResourceMapping getPropertyMappingFor(Class<?> entity, String propertyName) {

    MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entity);
    MongoPersistentProperty property = persistentEntity.getPersistentProperty(propertyName);

    CollectionResourceMapping entityResourceMapping = new TypeBasedCollectionResourceMapping(entity);
    ResourceMapping propertyTypeMapping = new TypeBasedCollectionResourceMapping(property.getType());

    return new PersistentPropertyResourceMapping(property, propertyTypeMapping, entityResourceMapping);
  }
View Full Code Here

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

   * @see DATAREST-262
   */
  @Test
  public void considersUnexportedPropertyUnlinkable() {

    MongoPersistentProperty property = entity.getPersistentProperty("unexportedProperty");
    assertThat(links.isLinkableAssociation(property), is(false));
  }
View Full Code Here

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

    assertThat(links.getLinksFor(property.getAssociation(), new Path("/sample")), hasSize(0));
  }

  private PersistentProperty<?> exposeProperty(String name) {

    MongoPersistentProperty property = entity.getPersistentProperty(name);
    ResourceMetadata metadata = new MappingResourceMetadata(mappingContext.getPersistentEntity(property));

    when(mappings.getMappingFor(property.getActualType())).thenReturn(metadata);

    return property;
  }
View Full Code Here

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

   * @see DATAMONGO-962
   */
  @Test
  public void shouldIdentifyCycleForOwnerOfSameTypeAndMatchingPath() {

    MongoPersistentProperty property = createPersistentPropertyMock(entityMock, "foo");
    assertThat(new Path(property, "foo.bar").cycles(property, "foo.bar.bar"), is(true));
  }
View Full Code Here

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

   */
  @Test
  @SuppressWarnings("rawtypes")
  public void shouldAllowMatchingPathForDifferentOwners() {

    MongoPersistentProperty existing = createPersistentPropertyMock(entityMock, "foo");

    MongoPersistentEntity entityOfDifferentType = Mockito.mock(MongoPersistentEntity.class);
    when(entityOfDifferentType.getType()).thenReturn(String.class);
    MongoPersistentProperty toBeVerified = createPersistentPropertyMock(entityOfDifferentType, "foo");

    assertThat(new Path(existing, "foo.bar").cycles(toBeVerified, "foo.bar.bar"), is(false));
  }
View Full Code Here

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

   * @see DATAMONGO-962
   */
  @Test
  public void shouldAllowEqaulPropertiesOnDifferentPaths() {

    MongoPersistentProperty property = createPersistentPropertyMock(entityMock, "foo");
    assertThat(new Path(property, "foo.bar").cycles(property, "foo2.bar.bar"), is(false));
  }
View Full Code Here

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

  }

  @SuppressWarnings({ "rawtypes", "unchecked" })
  private MongoPersistentProperty createPersistentPropertyMock(MongoPersistentEntity owner, String fieldname) {

    MongoPersistentProperty property = Mockito.mock(MongoPersistentProperty.class);
    when(property.getOwner()).thenReturn(owner);
    when(property.getFieldName()).thenReturn(fieldname);
    return property;
  }
View Full Code Here

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

  public void eagerlyReturnsDBRefObjectIfTargetAlreadyIsOne() {

    DB db = mock(DB.class);
    DBRef dbRef = new DBRef(db, "collection", "id");

    MongoPersistentProperty property = mock(MongoPersistentProperty.class);

    assertThat(converter.createDBRef(dbRef, property), is(dbRef));
  }
View Full Code Here

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

   */
  @Test
  public void createsDBRefWithClientSpecCorrectly() {

    PropertyPath path = PropertyPath.from("person", PersonClient.class);
    MongoPersistentProperty property = mappingContext.getPersistentPropertyPath(path).getLeafProperty();

    Person person = new Person();
    person.id = "foo";

    DBRef dbRef = converter.toDBRef(person, property);
View Full Code Here

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

   */
  @Test
  public void shouldEagerlyResolveIdPropertyWithFieldAccess() {

    MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(ClassWithLazyDbRefs.class);
    MongoPersistentProperty property = entity.getPersistentProperty("dbRefToConcreteType");

    String idValue = new ObjectId().toString();
    DBRef dbRef = converter.toDBRef(new LazyDbRefTarget(idValue), property);

    DBObject object = new BasicDBObject("dbRefToConcreteType", dbRef);

    ClassWithLazyDbRefs result = converter.read(ClassWithLazyDbRefs.class, object);

    BeanWrapper<LazyDbRefTarget> wrapper = BeanWrapper.create(result.dbRefToConcreteType, null);
    MongoPersistentProperty idProperty = mappingContext.getPersistentEntity(LazyDbRefTarget.class).getIdProperty();

    assertThat(wrapper.getProperty(idProperty), is(notNullValue()));
    assertProxyIsResolved(result.dbRefToConcreteType, false);
  }
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.