Search in sources :

Example 6 with OneFourOneToOne

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

the class PropertyTest method testSimpleStringPropertySearchOnRelationship.

@Test
public void testSimpleStringPropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<String> key = OneFourOneToOne.stringProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, "test");
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals("test", testEntity.getProperty(key));
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, "test").getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
        }
    } catch (FrameworkException fex) {
        fail("Error in test");
    }
}
Also used : OneFourOneToOne(org.structr.core.entity.OneFourOneToOne) TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) TestOne(org.structr.core.entity.TestOne) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 StructrTest (org.structr.common.StructrTest)6 FrameworkException (org.structr.common.error.FrameworkException)6 OneFourOneToOne (org.structr.core.entity.OneFourOneToOne)6 TestFour (org.structr.core.entity.TestFour)6 TestOne (org.structr.core.entity.TestOne)6 Tx (org.structr.core.graph.Tx)6 TestEnum (org.structr.core.entity.TestEnum)1