use of org.structr.core.entity.OneTwoOneToOne in project structr by structr.
the class BasicTest method testNodeCacheInvalidationInRelationshipWrapper.
@Test
public void testNodeCacheInvalidationInRelationshipWrapper() {
try (final Tx tx = app.tx()) {
final TestOne testOne = createTestNode(TestOne.class);
final TestTwo testTwo1 = createTestNode(TestTwo.class, new NodeAttribute<>(TestTwo.testOne, testOne));
final OneTwoOneToOne rel = testOne.getOutgoingRelationship(OneTwoOneToOne.class);
final TestTwo testTwo2 = rel.getTargetNode();
testTwo1.setProperty(AbstractNode.name, "test");
assertEquals("Cache invalidation failure!", "test", testTwo2.getProperty(AbstractNode.name));
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
// fill cache with other nodes
try {
createTestNodes(TestSix.class, 1000);
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
try (final Tx tx = app.tx()) {
final TestOne testOne = app.nodeQuery(TestOne.class).getFirst();
final TestTwo testTwo1 = app.nodeQuery(TestTwo.class).getFirst();
final OneTwoOneToOne rel = testOne.getOutgoingRelationship(OneTwoOneToOne.class);
final TestTwo testTwo2 = rel.getTargetNode();
testTwo1.setProperty(AbstractNode.name, "test2");
assertEquals("Cache invalidation failure!", "test2", testTwo2.getProperty(AbstractNode.name));
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
Aggregations