use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class DateConversionTest method assertCollectionFieldDateConversionToISO8601FormatByDefault.
// DATAGRAPH-550
@Test
public void assertCollectionFieldDateConversionToISO8601FormatByDefault() {
simpleDateISO8601format.setTimeZone(TimeZone.getTimeZone("UTC"));
List<Date> dates = new ArrayList<>();
dates.add(new Date(0));
dates.add(new Date(20000));
FieldInfo fieldInfo = memoInfo.propertyField("implementations");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
AttributeConverter attributeConverter = fieldInfo.getPropertyConverter();
assertThat(attributeConverter.getClass().isAssignableFrom(DateCollectionStringConverter.class)).isTrue();
String[] converted = (String[]) attributeConverter.toGraphProperty(dates);
assertThat(converted[0].equals("1970-01-01T00:00:00.000Z") || converted[1].equals("1970-01-01T00:00:00.000Z")).isTrue();
assertThat(converted[0].equals(simpleDateISO8601format.format(new Date(20000))) || converted[1].equals(simpleDateISO8601format.format(new Date(20000)))).isTrue();
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class DateConversionTest method assertFieldCustomTypeConversion.
@Test
public void assertFieldCustomTypeConversion() {
FieldInfo fieldInfo = memoInfo.propertyField("approved");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
AttributeConverter attributeConverter = fieldInfo.getPropertyConverter();
assertThat(attributeConverter.toGraphProperty(new Date(1234567890123L))).isEqualTo("20090213113130");
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class DateConversionTest method assertFieldDateLongConversion.
@Test
public void assertFieldDateLongConversion() {
FieldInfo fieldInfo = memoInfo.propertyField("closed");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
AttributeConverter attributeConverter = fieldInfo.getPropertyConverter();
assertThat(attributeConverter.getClass().isAssignableFrom(DateLongConverter.class)).isTrue();
Date date = new Date(0);
Long value = (Long) attributeConverter.toGraphProperty(date);
assertThat(value).isEqualTo(new Long(0));
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class DateConversionTest method assertFieldDateConversionWithExplicitAnnotation.
// DATAGRAPH-424
@Test
public void assertFieldDateConversionWithExplicitAnnotation() {
FieldInfo fieldInfo = memoInfo.propertyField("modified");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
AttributeConverter attributeConverter = fieldInfo.getPropertyConverter();
assertThat(attributeConverter.getClass().isAssignableFrom(DateStringConverter.class)).isTrue();
assertThat(attributeConverter.toGraphProperty(new Date(0))).isEqualTo("1970-01-01T00:00:00.000Z");
}
use of org.neo4j.ogm.metadata.FieldInfo in project neo4j-ogm by neo4j.
the class DateConversionTest method assertFieldDateConversionToISO8601FormatByDefault.
@Test
public void assertFieldDateConversionToISO8601FormatByDefault() {
FieldInfo fieldInfo = memoInfo.propertyField("recorded");
assertThat(fieldInfo.hasPropertyConverter()).isTrue();
AttributeConverter attributeConverter = fieldInfo.getPropertyConverter();
assertThat(attributeConverter.getClass().isAssignableFrom(DateStringConverter.class)).isTrue();
assertThat(attributeConverter.toGraphProperty(new Date(0))).isEqualTo("1970-01-01T00:00:00.000Z");
}
Aggregations