Search in sources :

Example 26 with TestFour

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

the class PropertyTest method testMultilineStringPropertyExactSubstringSearchOnNode.

@Test
public void testMultilineStringPropertyExactSubstringSearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<String> key = TestFour.stringProperty;
        properties.put(key, "test\nabc");
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals("test\nabc", testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test").getResult();
            assertEquals(0, result.size());
        }
    } 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 27 with TestFour

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

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

the class PropertyTest method testMultilineStringPropertySearchOnNode.

@Test
public void testMultilineStringPropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<String> key = TestFour.stringProperty;
        properties.put(key, "test\nabc");
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals("test\nabc", testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test\nabc").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 29 with TestFour

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

the class PropertyTest method testStringProperty.

// ----- string property tests -----
@Test
public void testStringProperty() {
    try {
        final Property<String> instance = TestFour.stringProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store string in the test entitiy
        final String value = "This is a test!";
        try (final Tx tx = app.tx()) {
            instance.setProperty(securityContext, testEntity, value);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(value, instance.getProperty(securityContext, testEntity, true));
        }
    } 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 30 with TestFour

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