Search in sources :

Example 1 with TestEnum

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

the class PropertyTest method testSimpleEnumPropertySearchOnNode.

@Test
public void testSimpleEnumPropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<TestEnum> key = TestFour.enumProperty;
        properties.put(key, TestEnum.Status1);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(TestEnum.Status1, testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, TestEnum.Status1).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) TestEnum(org.structr.core.entity.TestEnum) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 2 with TestEnum

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

the class PropertyTest method testSimpleEnumPropertySearchOnRelationship.

@Test
public void testSimpleEnumPropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<TestEnum> key = OneFourOneToOne.enumProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, TestEnum.Status1);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(TestEnum.Status1, testEntity.getProperty(key));
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, TestEnum.Status1).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
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) TestEnum(org.structr.core.entity.TestEnum) TestOne(org.structr.core.entity.TestOne) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Aggregations

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