use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testSimpleEnumPropertySearchOnRelationship.
@Test
public void testSimpleEnumPropertySearchOnRelationship() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestFour testFour = createTestNode(TestFour.class);
final Property<TestEnum> key = OneFourOneToOne.enumProperty;
assertNotNull(testOne);
assertNotNull(testFour);
final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
testEntity.setProperty(key, TestEnum.Status1);
tx.success();
}
try (final Tx tx = app.tx()) {
// check value from database
assertEquals(TestEnum.Status1, testEntity.getProperty(key));
Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, TestEnum.Status1).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 testNegativeInfinityDoublePropertySearchOnNode.
/* temporarily disabled because Cypher cannot handle NaN yet..
public void testNaNSearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<Double> key = TestFour.doubleProperty;
properties.put(key, Double.NaN);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals(Double.NaN, testEntity.getProperty(key));
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, Double.NaN).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
*/
@Test
public void testNegativeInfinityDoublePropertySearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<Double> key = TestFour.doubleProperty;
properties.put(key, Double.NEGATIVE_INFINITY);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals(Double.NEGATIVE_INFINITY, testEntity.getProperty(key), 0.0);
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, Double.NEGATIVE_INFINITY).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 testIntProperty.
// ----- integer property tests -----
@Test
public void testIntProperty() {
try {
final Property<Integer> instance = TestFour.integerProperty;
final TestFour testEntity = createTestNode(TestFour.class);
assertNotNull(testEntity);
// store integer in the test entitiy
final Integer value = 2345;
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("Unable to store array");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testBooleanProperty.
// ----- boolean property tests -----
@Test
public void testBooleanProperty() {
try {
final Property<Boolean> key = TestFour.booleanProperty;
final TestFour testEntity = createTestNode(TestFour.class);
assertNotNull(testEntity);
// store boolean in the test entitiy
final Boolean value = Boolean.TRUE;
try (final Tx tx = app.tx()) {
testEntity.setProperty(key, value);
tx.success();
}
try (final Tx tx = app.tx()) {
// check value from database
assertEquals(value, testEntity.getProperty(key));
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testSimpleDoublePropertySearchOnNode.
/* temporarily disabled because Cypher cannot handle NaN yet..
public void testNaN() {
try {
final Property<Double> instance = TestFour.doubleProperty;
final TestFour testEntity = createTestNode(TestFour.class);
assertNotNull(testEntity);
// store NaN double in the test entitiy
final Double value = Double.NaN;
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("Unable to store array");
}
}
*/
@Test
public void testSimpleDoublePropertySearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<Double> key = TestFour.doubleProperty;
properties.put(key, 3.141592653589793238);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals(3.141592653589793238, testEntity.getProperty(key), 0.0);
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, 3.141592653589793238).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
Aggregations