Search in sources :

Example 1 with TestFour

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

the class PropertyTest method testCaseInsensitiveMultilineStringPropertyInexactSubstringSearchOnNode.

@Test
public void testCaseInsensitiveMultilineStringPropertyInexactSubstringSearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<String> key = TestFour.stringProperty;
        properties.put(key, "{\n return fooBar;\n}");
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals("{\n return fooBar;\n}", testEntity.getProperty(key));
            // inexact search
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "foo", false).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
        }
    } catch (FrameworkException fex) {
        fail("Error in test");
    }
}
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 2 with TestFour

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

the class PropertyTest method testSimpleDatePropertySearchOnNode.

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

Example 3 with TestFour

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

the class PropertyTest method testDatePropertyRangeSearchOnNode.

@Test
public void testDatePropertyRangeSearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<Date> key = TestFour.dateProperty;
        final Date minValue = new Date(1234567880L);
        final Date value = new Date(1234567890L);
        final Date maxValue = new Date(1234567900L);
        final Date maxMaxValue = new Date(1234567910L);
        properties.put(key, value);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(value, testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).andRange(key, minValue, maxValue).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            Result<TestFour> result = app.nodeQuery(TestFour.class).andRange(key, maxValue, maxMaxValue).getResult();
            assertEquals(0, result.size());
            tx.success();
        }
    } 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) Date(java.util.Date) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 4 with TestFour

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

the class PropertyTest method testSimpleStringPropertySearchOnNode.

@Test
public void testSimpleStringPropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<String> key = TestFour.stringProperty;
        properties.put(key, "test");
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals("test", testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test").getResult();
            assertEquals(result.size(), 1);
            assertEquals(result.get(0), testEntity);
        }
    } catch (FrameworkException fex) {
        fail("Error in test");
    }
}
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 5 with TestFour

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

the class PropertyTest method testIntPropertyRangeSearchOnNode.

@Test
public void testIntPropertyRangeSearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final Property<Integer> key = OneFourOneToOne.integerProperty;
        properties.put(key, 123456);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals((Integer) 123456, testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).andRange(key, 123455, 123457).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            Result<TestFour> result = app.nodeQuery(TestFour.class).andRange(key, 123457, 123458).getResult();
            assertEquals(0, result.size());
            tx.success();
        }
    } 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)

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