use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class AnnotatedFieldWithNoSetterAndNonSetterTest method shouldPreferAnnotatedFieldOverNonSetterInAbsenceOfSetterForRelationshipEntity.
@Test
public void shouldPreferAnnotatedFieldOverNonSetterInAbsenceOfSetterForRelationshipEntity() {
ClassInfo classInfo = this.domainInfo.getClass(End.class.getName());
RelEntity relEntity = new RelEntity();
Set<RelEntity> parameter = new HashSet();
parameter.addAll(Arrays.asList(relEntity));
FieldInfo objectAccess = EntityAccessManager.getRelationalWriter(classInfo, "REL_ENTITY_TYPE", Relationship.Direction.INCOMING, relEntity);
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess instanceof FieldInfo).as("The access mechanism should be via the field").isTrue();
End end = new End();
objectAccess.write(end, parameter);
assertThat(parameter).isEqualTo(end.getRelEntities());
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class EntityAccessManagerTest method shouldPreferAnnotatedFieldToMethodNotAnnotatedWithPropertyWhenFindingPropertyToSet.
/**
* @see DATAGRAPH-674
*/
@Test
public void shouldPreferAnnotatedFieldToMethodNotAnnotatedWithPropertyWhenFindingPropertyToSet() {
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());
DummyDomainObject domainObject = new DummyDomainObject();
FieldInfo objectAccess = classInfo.getFieldInfo("testIgnored");
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess instanceof FieldInfo).isTrue();
assertThat(objectAccess.type()).isEqualTo(String.class);
objectAccess.write(domainObject, "TEST");
assertThat(domainObject.propertyMethodsIgnored).isEqualTo("TEST");
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class EntityAccessManagerTest method shouldPreferAnnotatedFieldToGetterWhenReadingFromAnObject.
@Test
public void shouldPreferAnnotatedFieldToGetterWhenReadingFromAnObject() {
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());
DummyDomainObject domainObject = new DummyDomainObject();
domainObject.propertyWithDifferentAnnotatedGetter = "more arbitrary text";
Collection<FieldInfo> readers = classInfo.propertyFields();
FieldInfo objectAccess = classInfo.getFieldInfo("differentAnnotationOnGetter");
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess.readProperty(domainObject)).isEqualTo(domainObject.propertyWithDifferentAnnotatedGetter);
for (FieldInfo reader : readers) {
if (reader.propertyName().equals("differentAnnotationOnGetter")) {
assertThat(reader instanceof FieldInfo).isTrue();
}
}
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class EntityAccessManagerTest method shouldUseFieldAccessUnconditionallyForReadingIdentityProperty.
@Test
public void shouldUseFieldAccessUnconditionallyForReadingIdentityProperty() {
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());
final long id = 593L;
DummyDomainObject domainObject = new DummyDomainObject();
domainObject.setId(id);
FieldInfo idReader = classInfo.identityField();
assertThat(idReader).as("The resultant ID reader shouldn't be null").isNotNull();
assertThat(idReader.readProperty(domainObject)).isEqualTo(id);
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class EntityAccessManagerTest method shouldPreferAnnotatedFieldToPlainGetterWhenReadingFromAnObject.
@Test
public void shouldPreferAnnotatedFieldToPlainGetterWhenReadingFromAnObject() {
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());
DummyDomainObject domainObject = new DummyDomainObject();
domainObject.annotatedTestProperty = "more arbitrary text";
FieldInfo objectAccess = classInfo.getFieldInfo("testProp");
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
assertThat(objectAccess.readProperty(domainObject)).isEqualTo(domainObject.annotatedTestProperty);
}
Aggregations