Search in sources :

Example 16 with TestFour

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

the class PropertyTest method testCaseInsensitiveMultilineWithLinefeedStringPropertyInexactSubstringSearchOnNode.

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

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

the class PropertyTest method testMultilineWithLinefeedStringPropertyInexactSubstringSearchOnNode.

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

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

the class PropertyTest method testModifyType.

// ----- type property tests -----
@Test
public void testModifyType() {
    final DatabaseService db = StructrApp.getInstance().getDatabaseService();
    final Set<Label> labelsBefore = new LinkedHashSet<>();
    final Set<Label> labelsAfter = new LinkedHashSet<>();
    String id = null;
    labelsBefore.add(db.forName(Label.class, AccessControllable.class.getSimpleName()));
    labelsBefore.add(db.forName(Label.class, TestFour.class.getSimpleName()));
    labelsAfter.add(db.forName(Label.class, AccessControllable.class.getSimpleName()));
    labelsAfter.add(db.forName(Label.class, TestFive.class.getSimpleName()));
    try (final Tx tx = app.tx()) {
        // create entity of type TestFour
        final TestFour testEntity = createTestNode(TestFour.class);
        // check if node exists
        assertNotNull(testEntity);
        // check labels before type change
        assertTrue(Iterables.toSet(testEntity.getNode().getLabels()).containsAll(labelsBefore));
        // save ID for later use
        id = testEntity.getUuid();
        // change type to TestFive
        // system properties have to be unlocked now, admin rights are not enough anymore
        testEntity.unlockSystemPropertiesOnce();
        testEntity.setProperty(GraphObject.type, TestFive.class.getSimpleName());
        // commit transaction
        tx.success();
    } catch (FrameworkException fex) {
        logger.warn("", fex);
        fail("Unexpected exception");
    }
    try (final Tx tx = app.tx()) {
        final TestFive testEntity = app.get(TestFive.class, id);
        assertNotNull(testEntity);
        // check labels after type change
        assertTrue(Iterables.toSet(testEntity.getNode().getLabels()).containsAll(labelsAfter));
    } catch (FrameworkException fex) {
        logger.warn("", fex);
        fail("Unexpected exception");
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Label(org.structr.api.graph.Label) DatabaseService(org.structr.api.DatabaseService) TestFive(org.structr.core.entity.TestFive) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 19 with TestFour

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

the class PropertyTest method testMultilineStringPropertyInexactSubstringSearchOnNode.

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

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

the class PropertyTest method testSimpleBooleanPropertySearchOnNode.

@Test
public void testSimpleBooleanPropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<Boolean> key = TestFour.booleanProperty;
        properties.put(key, true);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals((Boolean) true, (Boolean) testEntity.getProperty(key));
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, true).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)

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