use of org.structr.core.entity.OneThreeOneToOne in project structr by structr.
the class BasicTest method testRelationshipEndNodeTypeRestriction.
@Test
public void testRelationshipEndNodeTypeRestriction() {
// types are filtered according to the types of their end nodes
try (final Tx tx = app.tx()) {
// create two OWNS relationships with different end node types
final TestOne testOne = app.create(TestOne.class, "testone");
final TestThree testThree = app.create(TestThree.class, "testthree");
final Principal testUser = app.create(Principal.class, "testuser");
testOne.setProperty(TestOne.testThree, testThree);
testThree.setProperty(TestThree.owner, testUser);
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
try (final Tx tx = app.tx()) {
final List<OneThreeOneToOne> rels = app.relationshipQuery(OneThreeOneToOne.class).getAsList();
assertEquals("Relationship query returns wrong number of results", 1, rels.size());
for (final OneThreeOneToOne rel : rels) {
assertEquals("Relationship query returns wrong type", OneThreeOneToOne.class, rel.getClass());
}
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
Aggregations