use of org.neo4j.ogm.domain.satellites.Satellite in project neo4j-ogm by neo4j.
the class SatelliteIntegrationTest method shouldReturnSatellitesSortedByRefAsc.
@Test
public void shouldReturnSatellitesSortedByRefAsc() {
Collection<Satellite> satellites = session.loadAll(Satellite.class, new SortOrder().add("ref"));
Iterator<Satellite> iter = satellites.iterator();
Satellite first = iter.next();
while (iter.hasNext()) {
Satellite next = iter.next();
assertThat(first.getRef().compareTo(next.getRef()) < 0).isTrue();
first = next;
}
}
use of org.neo4j.ogm.domain.satellites.Satellite in project neo4j-ogm by neo4j.
the class SatelliteIntegrationTest method shouldRollbackLongTransaction.
@Test
public void shouldRollbackLongTransaction() {
Long id;
String name;
try (Transaction tx = session.beginTransaction()) {
// load all
Collection<Satellite> satellites = session.loadAll(Satellite.class);
assertThat(satellites).hasSize(11);
Satellite satellite = satellites.iterator().next();
id = satellite.getId();
name = satellite.getName();
satellite.setName("Updated satellite");
// update
session.save(satellite);
session.clear();
// refetch
Satellite updatedSatellite = session.load(Satellite.class, id);
assertThat(updatedSatellite.getName()).isEqualTo("Updated satellite");
tx.rollback();
}
session.clear();
// fetch - after rollback should not be changed
// note, that because we aren't starting a new tx, we will be given an autocommit one.
Satellite reloadedSatellite = session.load(Satellite.class, id);
assertThat(reloadedSatellite.getName()).isEqualTo(name);
}
use of org.neo4j.ogm.domain.satellites.Satellite in project neo4j-ogm by neo4j.
the class EntityAccessManagerTest method shouldPreferAnnotatedFieldWithMatchingRelationshipTypeWhenGettingIterableWriter.
/**
* @see DATAGRAPH-637
*/
@Test
public void shouldPreferAnnotatedFieldWithMatchingRelationshipTypeWhenGettingIterableWriter() {
// 2nd, try to find a field annotated with with relationship type
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());
List<Satellite> natural = new ArrayList<>();
natural.add(new Satellite());
FieldInfo objectAccess = EntityAccessManager.getIterableField(classInfo, Satellite.class, "NATURAL", Relationship.Direction.OUTGOING);
assertThat(objectAccess).as("The resultant object accessor shouldn't be null").isNotNull();
DummyDomainObject domainObject = new DummyDomainObject();
objectAccess.write(domainObject, natural);
assertThat(domainObject.naturalSatellites).isEqualTo(natural);
}
use of org.neo4j.ogm.domain.satellites.Satellite in project neo4j-ogm by neo4j.
the class EntityAccessManagerTest method shouldPreferAnnotatedFieldWithMatchingRelationshipTypeWhenGettingIterableReader.
/**
* @see DATAGRAPH-637
*/
@Test
public void shouldPreferAnnotatedFieldWithMatchingRelationshipTypeWhenGettingIterableReader() {
// 2nd, try to find a field annotated with with relationship type
ClassInfo classInfo = this.domainInfo.getClass(DummyDomainObject.class.getName());
List<Satellite> natural = new ArrayList<>();
natural.add(new Satellite());
FieldInfo relationalReader = EntityAccessManager.getIterableField(classInfo, Satellite.class, "NATURAL", Relationship.Direction.OUTGOING);
assertThat(relationalReader).as("The resultant object accessor shouldn't be null").isNotNull();
DummyDomainObject domainObject = new DummyDomainObject();
domainObject.naturalSatellites = natural;
Object o = relationalReader.read(domainObject);
assertThat(o).isEqualTo(natural);
}
use of org.neo4j.ogm.domain.satellites.Satellite in project neo4j-ogm by neo4j.
the class SatelliteIntegrationTest method shouldCommitLongTransaction.
@Test
public void shouldCommitLongTransaction() {
Long id;
try (Transaction tx = session.beginTransaction()) {
// load all
Collection<Satellite> satellites = session.loadAll(Satellite.class);
assertThat(satellites).hasSize(11);
Satellite satellite = satellites.iterator().next();
id = satellite.getId();
satellite.setName("Updated satellite");
// update
session.save(satellite);
session.clear();
// refetch
Satellite updatedSatellite = session.load(Satellite.class, id);
assertThat(updatedSatellite.getName()).isEqualTo("Updated satellite");
tx.commit();
}
session.clear();
// fetch - after commit should be changed
// note, that because we aren't starting a new tx, we will be given an autocommit one.
Satellite reloadedSatellite = session.load(Satellite.class, id);
assertThat(reloadedSatellite.getName()).isEqualTo("Updated satellite");
}
Aggregations