use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testSimpleStringPropertySearchOnRelationship.
@Test
public void testSimpleStringPropertySearchOnRelationship() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestFour testFour = createTestNode(TestFour.class);
final Property<String> key = OneFourOneToOne.stringProperty;
assertNotNull(testOne);
assertNotNull(testFour);
final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
testEntity.setProperty(key, "test");
tx.success();
}
try (final Tx tx = app.tx()) {
// check value from database
assertEquals("test", testEntity.getProperty(key));
Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, "test").getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Error in test");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testSimpleLongPropertySearchOnNode.
@Test
public void testSimpleLongPropertySearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<Long> key = TestFour.longProperty;
properties.put(key, 2857312362L);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals((Long) 2857312362L, (Long) testEntity.getProperty(key));
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, 2857312362L).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testSimpleStringArraySearchOnNode.
@Test
public void testSimpleStringArraySearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<String[]> key = TestFour.stringArrayProperty;
// store a string array in the test entitiy
final String[] arr1 = new String[] { "one" };
final String[] arr5 = new String[] { "one", "two", "three", "four", "five" };
properties.put(key, arr1);
TestFour testEntity = null;
try (final Tx tx = app.tx()) {
testEntity = createTestNode(TestFour.class, properties);
tx.success();
}
assertNotNull(testEntity);
Result<TestFour> result = null;
try (final Tx tx = app.tx()) {
result = app.nodeQuery(TestFour.class).and(key, new String[] { "one" }).getResult();
assertEquals(1, result.size());
assertEquals(result.get(0), testEntity);
}
try (final Tx tx = app.tx()) {
testEntity.setProperty(key, arr5);
tx.success();
}
try (final Tx tx = app.tx()) {
result = app.nodeQuery(TestFour.class).and(key, new String[] { "one" }).getResult();
assertEquals(1, result.size());
assertEquals(result.get(0), testEntity);
}
try (final Tx tx = app.tx()) {
result = app.nodeQuery(TestFour.class).and(key, new String[] { "one", "two" }).getResult();
assertEquals(1, result.size());
assertEquals(result.get(0), testEntity);
}
try (final Tx tx = app.tx()) {
result = app.nodeQuery(TestFour.class).and(key, new String[] { "one", "foo" }).getResult();
assertEquals(0, result.size());
}
try (final Tx tx = app.tx()) {
result = app.nodeQuery(TestFour.class).and(key, new String[] { "one", "foo" }, false).getResult();
assertEquals(1, result.size());
assertEquals(result.get(0), testEntity);
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testDoublePropertyRangeSearchOnNode.
@Test
public void testDoublePropertyRangeSearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final Property<Double> key = OneFourOneToOne.doubleProperty;
properties.put(key, 123456.2);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals((Double) 123456.2, testEntity.getProperty(key));
Result<TestFour> result = app.nodeQuery(TestFour.class).andRange(key, 123455.1, 123457.6).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, 123456.3, 123456.7).getResult();
assertEquals(0, result.size());
tx.success();
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testLongPropertyRangeSearchOnNode.
@Test
public void testLongPropertyRangeSearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<Long> key = TestFour.longProperty;
properties.put(key, 123456L);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals((Long) 123456L, testEntity.getProperty(key));
Result<TestFour> result = app.nodeQuery(TestFour.class).andRange(key, 123455L, 123457L).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, 123457L, 123458L).getResult();
assertEquals(0, result.size());
tx.success();
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
Aggregations