Search in sources :

Example 1 with TestSeven

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

the class SearchAndSortingTest method test04SearchByLocation.

@Test
public void test04SearchByLocation() {
    try {
        final PropertyMap props = new PropertyMap();
        final PropertyKey lat = TestSeven.latitude;
        final PropertyKey lon = TestSeven.longitude;
        final Class type = TestSeven.class;
        props.put(lat, 50.12284d);
        props.put(lon, 8.73923d);
        props.put(AbstractNode.name, "TestSeven-0");
        NodeInterface node = createTestNode(type, props);
        try (final Tx tx = app.tx()) {
            Result result = app.nodeQuery(type).location("Hanauer Landstraße", "200", "60314", "Frankfurt", "Germany", 10.0).includeDeletedAndHidden().getResult();
            assertEquals(1, result.size());
            assertTrue(result.get(0).equals(node));
        }
    } catch (FrameworkException ex) {
        logger.warn("", ex);
        logger.error(ex.toString());
        fail("Unexpected exception");
    }
}
Also used : TestSeven(org.structr.core.entity.TestSeven) PropertyMap(org.structr.core.property.PropertyMap) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) PropertyKey(org.structr.core.property.PropertyKey) NodeInterface(org.structr.core.graph.NodeInterface) Result(org.structr.core.Result) Test(org.junit.Test)

Example 2 with TestSeven

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

the class SearchAndSortingTest method test05SpatialRollback.

@Test
public void test05SpatialRollback() {
    try {
        final Class type = TestSeven.class;
        final PropertyMap props = new PropertyMap();
        final PropertyKey lat = TestSeven.latitude;
        final PropertyKey lon = TestSeven.longitude;
        props.put(AbstractNode.type, type.getSimpleName());
        props.put(lat, 50.12284d);
        props.put(lon, 8.73923d);
        props.put(AbstractNode.name, "TestSeven-0");
        try (final Tx tx = app.tx()) {
            // this will work
            TestSeven node = app.create(TestSeven.class, props);
            props.remove(AbstractNode.name);
            props.put(lat, 50.12285d);
            props.put(lon, 8.73924d);
            // this will fail
            TestSeven node2 = app.create(TestSeven.class, props);
            // adding another
            TestSeven node3 = app.create(TestSeven.class, props);
            tx.success();
        }
        fail("Expected a FrameworkException (name must_not_be_empty)");
    } catch (FrameworkException nfe) {
        logger.warn("", nfe);
    }
}
Also used : TestSeven(org.structr.core.entity.TestSeven) PropertyMap(org.structr.core.property.PropertyMap) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) PropertyKey(org.structr.core.property.PropertyKey) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FrameworkException (org.structr.common.error.FrameworkException)2 TestSeven (org.structr.core.entity.TestSeven)2 Tx (org.structr.core.graph.Tx)2 PropertyKey (org.structr.core.property.PropertyKey)2 PropertyMap (org.structr.core.property.PropertyMap)2 Result (org.structr.core.Result)1 NodeInterface (org.structr.core.graph.NodeInterface)1