use of org.structr.core.entity.SixOneOneToOne in project structr by structr.
the class CypherTest method test03DeleteDirectly.
@Test
public void test03DeleteDirectly() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestSix testSix = createTestNode(TestSix.class);
SixOneOneToOne rel = null;
assertNotNull(testOne);
assertNotNull(testSix);
try (final Tx tx = app.tx()) {
rel = app.create(testSix, testOne, SixOneOneToOne.class);
tx.success();
}
assertNotNull(rel);
try (final Tx tx = app.tx()) {
testOne.getRelationships().iterator().next().getRelationship().delete();
tx.success();
}
try (final Tx tx = app.tx()) {
rel.getUuid();
fail("Accessing a deleted relationship should thow an exception.");
tx.success();
} catch (NotFoundException nfex) {
assertNotNull(nfex.getMessage());
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.entity.SixOneOneToOne in project structr by structr.
the class CypherTest method test01DeleteAfterLookupWithCypherInTransaction.
@Test
public void test01DeleteAfterLookupWithCypherInTransaction() {
try {
final TestSix testSix = this.createTestNode(TestSix.class);
final TestOne testOne = this.createTestNode(TestOne.class);
SixOneOneToOne rel = null;
assertNotNull(testSix);
assertNotNull(testOne);
try (final Tx tx = app.tx()) {
rel = app.create(testSix, testOne, SixOneOneToOne.class);
tx.success();
}
assertNotNull(rel);
DatabaseService graphDb = app.command(GraphDatabaseCommand.class).execute();
try (final Tx tx = app.tx()) {
NativeResult<Relationship> result = graphDb.execute("MATCH (n)<-[r:ONE_TO_ONE]-() RETURN r");
final Iterator<Relationship> rels = result.columnAs("r");
assertTrue(rels.hasNext());
rels.next().delete();
tx.success();
}
try (final Tx tx = app.tx()) {
rel.getUuid();
fail("Accessing a deleted relationship should thow an exception.");
tx.success();
} catch (NotFoundException iex) {
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.entity.SixOneOneToOne in project structr by structr.
the class CypherTest method test05RollbackDelete.
@Test
public void test05RollbackDelete() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestSix testSix = createTestNode(TestSix.class);
String relId = null;
SixOneOneToOne rel = null;
assertNotNull(testOne);
assertNotNull(testSix);
try (final Tx tx = app.tx()) {
rel = app.create(testSix, testOne, SixOneOneToOne.class);
relId = rel.getUuid();
tx.success();
}
assertNotNull(rel);
try (final Tx tx = app.tx()) {
// do not commit transaction
testOne.getRelationships().iterator().next().getRelationship().delete();
}
try (final Tx tx = app.tx()) {
assertEquals("UUID of relationship should be readable after rollback", relId, rel.getUuid());
tx.success();
} catch (NotFoundException iex) {
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.entity.SixOneOneToOne in project structr by structr.
the class BasicTest method test01DeleteRelationship.
@Test
public void test01DeleteRelationship() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestSix testSix = createTestNode(TestSix.class);
SixOneOneToOne rel = null;
assertNotNull(testOne);
assertNotNull(testSix);
try (final Tx tx = app.tx()) {
rel = app.create(testSix, testOne, SixOneOneToOne.class);
tx.success();
}
assertNotNull(rel);
try {
// try to delete relationship
rel.getRelationship().delete();
fail("Should have raised an org.neo4j.graphdb.NotInTransactionException");
} catch (NotInTransactionException e) {
}
// Relationship still there
assertNotNull(rel);
try (final Tx tx = app.tx()) {
app.delete(rel);
tx.success();
}
try (final Tx tx = app.tx()) {
String uuid = rel.getUuid();
fail("Deleted entity should have thrown an exception on access.");
} catch (NotFoundException iex) {
}
} catch (FrameworkException ex) {
logger.warn("", ex);
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.entity.SixOneOneToOne in project structr by structr.
the class CypherTest method test04DeleteAfterIndexLookup.
@Test
public void test04DeleteAfterIndexLookup() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestSix testSix = createTestNode(TestSix.class);
SixOneOneToOne rel = null;
assertNotNull(testOne);
assertNotNull(testSix);
try (final Tx tx = app.tx()) {
rel = app.create(testSix, testOne, SixOneOneToOne.class);
tx.success();
}
assertNotNull(rel);
try (final Tx tx = app.tx()) {
GraphObject searchRes = app.getNodeById(testSix.getUuid());
assertNotNull(searchRes);
tx.success();
}
try (final Tx tx = app.tx()) {
testSix.getRelationships().iterator().next().getRelationship().delete();
tx.success();
}
try (final Tx tx = app.tx()) {
rel.getUuid();
fail("Accessing a deleted relationship should thow an exception.");
tx.success();
} catch (NotFoundException nfex) {
assertNotNull(nfex.getMessage());
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
Aggregations