Search in sources :

Example 1 with OneThreeOneToOne

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.");
    }
}
Also used : OneThreeOneToOne(org.structr.core.entity.OneThreeOneToOne) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) TestThree(org.structr.core.entity.TestThree) TestOne(org.structr.core.entity.TestOne) Principal(org.structr.core.entity.Principal) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FrameworkException (org.structr.common.error.FrameworkException)1 OneThreeOneToOne (org.structr.core.entity.OneThreeOneToOne)1 Principal (org.structr.core.entity.Principal)1 TestOne (org.structr.core.entity.TestOne)1 TestThree (org.structr.core.entity.TestThree)1 Tx (org.structr.core.graph.Tx)1