Search in sources :

Example 1 with SixOneManyToMany

use of org.structr.core.entity.SixOneManyToMany in project structr by structr.

the class SearchAndSortingTest method test09SearchBySourceAndTargetId.

@Test
public void test09SearchBySourceAndTargetId() {
    try {
        final TestOne test1 = createTestNode(TestOne.class);
        final List<TestSix> tests = createTestNodes(TestSix.class, 5);
        try (final Tx tx = app.tx()) {
            test1.setProperty(TestOne.manyToManyTestSixs, tests);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            final List<SixOneManyToMany> result1 = app.relationshipQuery(SixOneManyToMany.class).and(SixOneManyToMany.sourceId, tests.get(0).getUuid()).getAsList();
            assertEquals("Invalid sourceId query result", 1, result1.size());
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            final List<SixOneManyToMany> result1 = app.relationshipQuery(SixOneManyToMany.class).and(SixOneManyToMany.targetId, test1.getUuid()).getAsList();
            assertEquals("Invalid targetId query result", 5, result1.size());
            tx.success();
        }
    } catch (FrameworkException ex) {
        logger.error(ex.toString());
        fail("Unexpected exception");
    }
}
Also used : SixOneManyToMany(org.structr.core.entity.SixOneManyToMany) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) TestOne(org.structr.core.entity.TestOne) TestSix(org.structr.core.entity.TestSix) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FrameworkException (org.structr.common.error.FrameworkException)1 SixOneManyToMany (org.structr.core.entity.SixOneManyToMany)1 TestOne (org.structr.core.entity.TestOne)1 TestSix (org.structr.core.entity.TestSix)1 Tx (org.structr.core.graph.Tx)1