use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class DegenerateEntityModelTests method init.
@Before
public void init() throws IOException {
session = sessionFactory.openSession();
session.purgeDatabase();
Iterable<Map<String, Object>> executionResult = session.query("CREATE (f:Folder { name: 'f' } )" + "CREATE (a:Document { name: 'a' } ) " + "CREATE (b:Document { name: 'b' } ) " + "CREATE (f)-[:CONTAINS]->(a) " + "CREATE (f)-[:CONTAINS]->(b) " + "RETURN id(f) AS fid, id(a) AS aid, id(b) AS bid", emptyMap()).queryResults();
Map<String, Object> resultSet = executionResult.iterator().next();
session.clear();
a = session.load(Document.class, (Long) resultSet.get("aid"));
Document b = session.load(Document.class, (Long) resultSet.get("bid"));
f = session.load(Folder.class, (Long) resultSet.get("fid"));
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class DegenerateEntityModelTests method testSaveDegenerateDocumentClone.
@Test
public void testSaveDegenerateDocumentClone() {
Document clone = new Document();
clone.setId(a.getId());
clone.setName(a.getName());
clone.setFolder(null);
session.save(clone);
session.clear();
assertThat(session.query("MATCH (f:Folder { name: 'f' } ), " + "(a:Document { name: 'a'} ), " + "(b:Document { name: 'b'} ) " + "WHERE (f)-[:CONTAINS]->(b) return f, a, b", emptyMap()).queryResults()).hasSize(1);
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class DirtyObjectsTest method modifiedLoadedObjectShouldBeDirty.
@Test
public void modifiedLoadedObjectShouldBeDirty() {
Document d = new Document();
session.save(d);
d.setName("Document");
assertThat(session.context().isDirty(d)).isTrue();
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class DirtyObjectsTest method reloadingAnObjectReturnsTheCachedInstance.
@Test
public void reloadingAnObjectReturnsTheCachedInstance() {
Document d = new Document();
session.save(d);
assertThat(session.load(Document.class, d.getId())).isSameAs(d);
}
use of org.neo4j.ogm.domain.filesystem.Document in project neo4j-ogm by neo4j.
the class DirtyObjectsTest method savedObjectShouldNotBeDirty.
@Test
public void savedObjectShouldNotBeDirty() {
Document d = new Document();
session.save(d);
assertThat(session.context().isDirty(d)).isFalse();
}
Aggregations