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");
}
}
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);
}
}
Aggregations