use of org.neo4j.ogm.domain.convertible.enums.Algebra in project neo4j-ogm by neo4j.
the class EnumConversionTest method testSaveFieldWithAnnotatedConverter.
@Test
public void testSaveFieldWithAnnotatedConverter() {
FieldInfo fieldInfo = algebraInfo.propertyField("numberSystem");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
Algebra algebra = new Algebra();
algebra.setNumberSystem(NumberSystem.NATURAL);
assertThat(algebra.getNumberSystem().getDomain()).isEqualTo("N");
String value = (String) fieldInfo.getPropertyConverter().toGraphProperty(algebra.getNumberSystem());
// the converted enum value that will be stored as a neo4j node / rel property
assertThat(value).isEqualTo("NATURAL");
}
use of org.neo4j.ogm.domain.convertible.enums.Algebra in project neo4j-ogm by neo4j.
the class EnumConversionTest method testLoadFieldWithAnnotatedConverter.
@Test
public void testLoadFieldWithAnnotatedConverter() {
FieldInfo fieldInfo = algebraInfo.propertyField("numberSystem");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
// a node / rel property value loaded from neo4j, to be stored in on an enum
String value = "INTEGER";
Algebra algebra = new Algebra();
algebra.setNumberSystem((NumberSystem) fieldInfo.getPropertyConverter().toEntityAttribute(value));
assertThat(algebra.getNumberSystem()).isEqualTo(NumberSystem.INTEGER);
assertThat(algebra.getNumberSystem().getDomain()).isEqualTo("Z");
}