use of org.neo4j.ogm.domain.convertible.enums.Person in project neo4j-ogm by neo4j.
the class ConvertibleIntegrationTest method shouldSaveAndRetrieveEnums.
// DATAGRAPH-550
@Test
public void shouldSaveAndRetrieveEnums() {
List<Education> completed = new ArrayList<>();
completed.add(Education.HIGHSCHOOL);
completed.add(Education.BACHELORS);
Person person = new Person();
person.setName("luanne");
person.setInProgressEducation(new Education[] { Education.MASTERS, Education.PHD });
person.setCompletedEducation(completed);
person.setGender(Gender.FEMALE);
session.save(person);
Person luanne = session.loadAll(Person.class, new Filter("name", ComparisonOperator.EQUALS, "luanne")).iterator().next();
assertThat(luanne.getGender()).isEqualTo(Gender.FEMALE);
assertThat(luanne.getCompletedEducation().contains(Education.HIGHSCHOOL)).isTrue();
assertThat(luanne.getCompletedEducation().contains(Education.BACHELORS)).isTrue();
assertThat(luanne.getInProgressEducation().length).isEqualTo(2);
assertThat(luanne.getInProgressEducation()[0].equals(Education.MASTERS) || luanne.getInProgressEducation()[1].equals(Education.MASTERS)).isTrue();
assertThat(luanne.getInProgressEducation()[0].equals(Education.PHD) || luanne.getInProgressEducation()[1].equals(Education.PHD)).isTrue();
}
use of org.neo4j.ogm.domain.convertible.enums.Person in project neo4j-ogm by neo4j.
the class ConvertibleIntegrationTest method shouldSaveAndRetrieveEnumsAsResult.
@Test
public void shouldSaveAndRetrieveEnumsAsResult() {
List<Education> completed = new ArrayList<>();
completed.add(Education.HIGHSCHOOL);
completed.add(Education.BACHELORS);
Person person = new Person();
person.setName("luanne");
person.setInProgressEducation(new Education[] { Education.MASTERS, Education.PHD });
person.setCompletedEducation(completed);
person.setGender(Gender.FEMALE);
session.save(person);
session.clear();
Result res = session.query("MATCH (p:Person{name:'luanne'}) return p", Collections.EMPTY_MAP);
Person luanne = (Person) res.queryResults().iterator().next().get("p");
assertThat(luanne.getGender()).isEqualTo(Gender.FEMALE);
assertThat(luanne.getCompletedEducation().contains(Education.HIGHSCHOOL)).isTrue();
assertThat(luanne.getCompletedEducation().contains(Education.BACHELORS)).isTrue();
assertThat(luanne.getInProgressEducation().length).isEqualTo(2);
assertThat(luanne.getInProgressEducation()[0].equals(Education.MASTERS) || luanne.getInProgressEducation()[1].equals(Education.MASTERS)).isTrue();
assertThat(luanne.getInProgressEducation()[0].equals(Education.PHD) || luanne.getInProgressEducation()[1].equals(Education.PHD)).isTrue();
}
use of org.neo4j.ogm.domain.convertible.enums.Person in project neo4j-ogm by neo4j.
the class EnumConversionTest method testEducationCollectionFieldWithAutoDetectedConverter.
/**
* @see DATAGRAPH-550
*/
@Test
public void testEducationCollectionFieldWithAutoDetectedConverter() {
List<Education> completedEducation = new ArrayList<>();
completedEducation.add(Education.HIGHSCHOOL);
completedEducation.add(Education.BACHELORS);
Person bob = new Person();
bob.setCompletedEducation(completedEducation);
FieldInfo fieldInfo = personInfo.propertyField("completedEducation");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
String[] converted = (String[]) fieldInfo.getPropertyConverter().toGraphProperty(bob.getCompletedEducation());
assertThat("HIGHSCHOOL".equals(converted[0]) || "HIGHSCHOOL".equals(converted[1])).isTrue();
assertThat("BACHELORS".equals(converted[0]) || "BACHELORS".equals(converted[1])).isTrue();
}
use of org.neo4j.ogm.domain.convertible.enums.Person in project neo4j-ogm by neo4j.
the class EnumConversionTest method testEducationArrayFieldWithAutoDetectedConverter.
/**
* @see DATAGRAPH-550
*/
@Test
public void testEducationArrayFieldWithAutoDetectedConverter() {
Person bob = new Person();
bob.setGender(Gender.MALE);
Education[] inProgress = new Education[] { Education.MASTERS, Education.PHD };
bob.setInProgressEducation(inProgress);
FieldInfo fieldInfo = personInfo.propertyField("inProgressEducation");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
String[] converted = (String[]) fieldInfo.getPropertyConverter().toGraphProperty(bob.getInProgressEducation());
assertThat("MASTERS".equals(converted[0]) || "MASTERS".equals(converted[1])).isTrue();
assertThat("PHD".equals(converted[0]) || "PHD".equals(converted[1])).isTrue();
}
use of org.neo4j.ogm.domain.convertible.enums.Person in project neo4j-ogm by neo4j.
the class EnumConversionTest method testGenderFieldWithAutoDetectedConverter.
@Test
public void testGenderFieldWithAutoDetectedConverter() {
Person bob = new Person();
bob.setGender(Gender.MALE);
FieldInfo fieldInfo = personInfo.propertyField("gender");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
assertThat(fieldInfo.getPropertyConverter().toGraphProperty(bob.getGender())).isEqualTo("MALE");
}
Aggregations