final String numberString3 = numberFormat3.format(2.234);
MailTemplate template = null;
MailTemplate template2 = null;
TestOne testOne = null;
TestTwo testTwo = null;
TestThree testThree = null;
TestFour testFour = null;
List<TestSix> testSixs = null;
int index = 0;
try (final Tx tx = app.tx()) {
testOne = createTestNode(TestOne.class);
testTwo = createTestNode(TestTwo.class);
testThree = createTestNode(TestThree.class);
testFour = createTestNode(TestFour.class);
testSixs = createTestNodes(TestSix.class, 20);
for (final TestSix testSix : testSixs) {
testSix.setProperty(TestSix.index, index++);
}
// create mail template
template = createTestNode(MailTemplate.class);
template.setProperty(MailTemplate.name, "TEST");
template.setProperty(MailTemplate.locale, "en_EN");
template.setProperty(MailTemplate.text, "This is a template for ${this.name}");
// create mail template
template2 = createTestNode(MailTemplate.class);
template2.setProperty(MailTemplate.name, "TEST2");
template2.setProperty(MailTemplate.locale, "en_EN");
template2.setProperty(MailTemplate.text, "${this.aDouble}");
// check existance
assertNotNull(testOne);
testOne.setProperty(TestOne.name, "A-nice-little-name-for-my-test-object");
testOne.setProperty(TestOne.anInt, 1);
testOne.setProperty(TestOne.aString, "String");
testOne.setProperty(TestOne.anotherString, "{\n\ttest: test,\n\tnum: 3\n}");
testOne.setProperty(TestOne.replaceString, "${this.name}");
testOne.setProperty(TestOne.aLong, 235242522552L);
testOne.setProperty(TestOne.aDouble, 2.234);
testOne.setProperty(TestOne.aDate, now);
testOne.setProperty(TestOne.anEnum, TestOne.Status.One);
testOne.setProperty(TestOne.aBoolean, true);
testOne.setProperty(TestOne.testTwo, testTwo);
testOne.setProperty(TestOne.testThree, testThree);
testOne.setProperty(TestOne.testFour, testFour);
testOne.setProperty(TestOne.manyToManyTestSixs, testSixs);
testOne.setProperty(TestOne.cleanTestString, "a<b>c.d'e?f(g)h{i}j[k]l+m/n–o\\p\\q|r's!t,u-v_w`x-y-zöäüßABCDEFGH");
testOne.setProperty(TestOne.stringWithQuotes, "A'B\"C");
tx.success();
} catch (FrameworkException fex) {
fex.printStackTrace();
fail("Unexpected exception");
}
try (final Tx tx = app.tx()) {
final ActionContext ctx = new ActionContext(testOne, null);
// test for "empty" return value
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${err}"));
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${this.error}"));
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${this.this.this.error}"));
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${parent.error}"));
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${this.owner}"));
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${this.alwaysNull}"));
assertEquals("Invalid expressions should yield an empty result", "", testOne.replaceVariables(securityContext, ctx, "${parent.owner}"));
assertEquals("${this} should evaluate to the current node", testOne.toString(), testOne.replaceVariables(securityContext, ctx, "${this}"));
assertEquals("${parent} should evaluate to the context parent node", testOne.toString(), testOne.replaceVariables(securityContext, ctx, "${parent}"));
assertEquals("${this} should evaluate to the current node", testTwo.toString(), testTwo.replaceVariables(securityContext, ctx, "${this}"));
assertEquals("${parent} should evaluate to the context parent node", testOne.toString(), testTwo.replaceVariables(securityContext, ctx, "${parent}"));
assertEquals("Invalid variable reference", testTwo.toString(), testOne.replaceVariables(securityContext, ctx, "${this.testTwo}"));
assertEquals("Invalid variable reference", testThree.toString(), testOne.replaceVariables(securityContext, ctx, "${this.testThree}"));
assertEquals("Invalid variable reference", testFour.toString(), testOne.replaceVariables(securityContext, ctx, "${this.testFour}"));
assertEquals("Invalid variable reference", testTwo.getUuid(), testOne.replaceVariables(securityContext, ctx, "${this.testTwo.id}"));
assertEquals("Invalid variable reference", testThree.getUuid(), testOne.replaceVariables(securityContext, ctx, "${this.testThree.id}"));
assertEquals("Invalid variable reference", testFour.getUuid(), testOne.replaceVariables(securityContext, ctx, "${this.testFour.id}"));
assertEquals("Invalid size result", "20", testOne.replaceVariables(securityContext, ctx, "${this.manyToManyTestSixs.size}"));
try {