Search in sources :

Example 11 with TestFour

use of org.structr.core.entity.TestFour 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 12 with TestFour

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

the class PropertyTest method testSimpleIntPropertySearchOnNode.

@Test
public void testSimpleIntPropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<Integer> key = TestFour.integerProperty;
        properties.put(key, 2345);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals((Integer) 2345, (Integer) testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, 2345).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) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 13 with TestFour

use of org.structr.core.entity.TestFour 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 14 with TestFour

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

the class PropertyTest method testStringArrayProperty.

@Test
public void testStringArrayProperty() {
    try {
        final Property<String[]> instance = TestFour.stringArrayProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store a string array in the test entitiy
        final String[] arr = new String[] { "one", "two", "three", "four", "five" };
        try (final Tx tx = app.tx()) {
            instance.setProperty(securityContext, testEntity, arr);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            String[] newArr = instance.getProperty(securityContext, testEntity, true);
            assertTrue(Objects.deepEquals(arr, newArr));
        }
    } 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) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 15 with TestFour

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

Aggregations

Test (org.junit.Test)37 StructrTest (org.structr.common.StructrTest)37 FrameworkException (org.structr.common.error.FrameworkException)37 TestFour (org.structr.core.entity.TestFour)37 Tx (org.structr.core.graph.Tx)37 TestOne (org.structr.core.entity.TestOne)8 OneFourOneToOne (org.structr.core.entity.OneFourOneToOne)6 Date (java.util.Date)5 UnlicensedException (org.structr.common.error.UnlicensedException)2 TestEnum (org.structr.core.entity.TestEnum)2 TestSix (org.structr.core.entity.TestSix)2 TestThree (org.structr.core.entity.TestThree)2 TestTwo (org.structr.core.entity.TestTwo)2 ActionContext (org.structr.schema.action.ActionContext)2 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1