use of org.structr.core.entity.TestOne in project structr by structr.
the class CypherTest method test04DeleteAfterIndexLookup.
@Test
public void test04DeleteAfterIndexLookup() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestSix testSix = createTestNode(TestSix.class);
SixOneOneToOne rel = null;
assertNotNull(testOne);
assertNotNull(testSix);
try (final Tx tx = app.tx()) {
rel = app.create(testSix, testOne, SixOneOneToOne.class);
tx.success();
}
assertNotNull(rel);
try (final Tx tx = app.tx()) {
GraphObject searchRes = app.getNodeById(testSix.getUuid());
assertNotNull(searchRes);
tx.success();
}
try (final Tx tx = app.tx()) {
testSix.getRelationships().iterator().next().getRelationship().delete();
tx.success();
}
try (final Tx tx = app.tx()) {
rel.getUuid();
fail("Accessing a deleted relationship should thow an exception.");
tx.success();
} catch (NotFoundException nfex) {
assertNotNull(nfex.getMessage());
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.entity.TestOne in project structr by structr.
the class PropertyTest method testSimpleLongPropertySearchOnRelationship.
@Test
public void testSimpleLongPropertySearchOnRelationship() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestFour testFour = createTestNode(TestFour.class);
final Property<Long> key = OneFourOneToOne.longProperty;
assertNotNull(testOne);
assertNotNull(testFour);
final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
testEntity.setProperty(key, 2857312362L);
tx.success();
}
try (final Tx tx = app.tx()) {
// check value from database
assertEquals((Long) 2857312362L, (Long) testEntity.getProperty(key));
Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.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.TestOne in project structr by structr.
the class PropertyTest method testSimpleIntPropertySearchOnRelationship.
@Test
public void testSimpleIntPropertySearchOnRelationship() {
try {
final TestOne testOne = createTestNode(TestOne.class);
final TestFour testFour = createTestNode(TestFour.class);
final Property<Integer> key = OneFourOneToOne.integerProperty;
assertNotNull(testOne);
assertNotNull(testFour);
final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
testEntity.setProperty(key, 2345);
tx.success();
}
try (final Tx tx = app.tx()) {
// check value from database
assertEquals((Integer) 2345, (Integer) testEntity.getProperty(key));
Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, 2345).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
use of org.structr.core.entity.TestOne 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.TestOne in project structr by structr.
the class ScriptingTest method testEnumPropertyGet.
@Test
public void testEnumPropertyGet() {
// setup phase
try (final Tx tx = app.tx()) {
final ActionContext actionContext = new ActionContext(securityContext);
final TestOne context = app.create(TestOne.class);
Scripting.evaluate(actionContext, context, "${{ var e = Structr.get('this'); e.anEnum = 'One'; }}", "test");
assertEquals("Invalid enum get result", "One", Scripting.evaluate(actionContext, context, "${{ var e = Structr.get('this'); return e.anEnum; }}", "test"));
assertEquals("Invaliid Javascript enum comparison result", true, Scripting.evaluate(actionContext, context, "${{ var e = Structr.get('this'); return e.anEnum == 'One'; }}", "test"));
tx.success();
} catch (UnlicensedException | FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
Aggregations