Search in sources :

Example 1 with OneFourOneToOne

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

the class PropertyTest method testSimpleBooleanPropertySearchOnRelationship.

@Test
public void testSimpleBooleanPropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<Boolean> key = OneFourOneToOne.booleanProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, true);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals((Boolean) true, (Boolean) testEntity.getProperty(key));
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, true).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) TestOne(org.structr.core.entity.TestOne) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 2 with OneFourOneToOne

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

the class PropertyTest method testSimpleDoublePropertySearchOnRelationship.

@Test
public void testSimpleDoublePropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<Double> key = OneFourOneToOne.doubleProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, 3.141592653589793238);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(3.141592653589793238, testEntity.getProperty(key), 0.0);
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, 3.141592653589793238).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) TestOne(org.structr.core.entity.TestOne) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 3 with OneFourOneToOne

use of org.structr.core.entity.OneFourOneToOne 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)

Example 4 with OneFourOneToOne

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

the class PropertyTest method testSimpleLongPropertySearchOnRelationship.

@Test
public void testSimpleLongPropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<Long> key = OneFourOneToOne.longProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, 2857312362L);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals((Long) 2857312362L, (Long) testEntity.getProperty(key));
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, 2857312362L).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) TestOne(org.structr.core.entity.TestOne) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 5 with OneFourOneToOne

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

the class PropertyTest method testSimpleIntPropertySearchOnRelationship.

@Test
public void testSimpleIntPropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<Integer> key = OneFourOneToOne.integerProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, 2345);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals((Integer) 2345, (Integer) testEntity.getProperty(key));
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, 2345).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) 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