Package org.structr.core.entity

Examples of org.structr.core.entity.TestThree


    try {

      final TestSix a   = createTestNode(TestSix.class);
      final TestSix c   = createTestNode(TestSix.class);
      final TestThree b = createTestNode(TestThree.class);
      final TestThree d = createTestNode(TestThree.class);

      try (final Tx tx = app.tx()) {

        a.setProperty(AbstractNode.name, "a");
        c.setProperty(AbstractNode.name, "c");
        b.setProperty(AbstractNode.name, "b");
        d.setProperty(AbstractNode.name, "d");
        tx.success();

      } catch (FrameworkException fex) {

        fex.printStackTrace();

        fail("Unable to create test nodes");
      }

      assertNotNull(a);
      assertNotNull(c);
      assertNotNull(b);
      assertNotNull(d);

      /**
       * We test the following here:
       * A -> B
       * C -> D
       *
       * then connect A -> D, so C and B should not
       * be related any more
       */

      // create two connections
      try (final Tx tx = app.tx()) {

        a.setProperty(TestSix.oneToOneTestThree, b);
        c.setProperty(TestSix.oneToOneTestThree, d);
        tx.success();

      } catch (FrameworkException fex) {

        fex.printStackTrace();

        fail("Unable to link test nodes");
      }

      try (final Tx tx = app.tx()) {

        // verify connections
        TestThree verifyB = a.getProperty(TestSix.oneToOneTestThree);
        TestThree verifyD = c.getProperty(TestSix.oneToOneTestThree);

        assertTrue(verifyB != null && verifyB.equals(b));
        assertTrue(verifyD != null && verifyD.equals(d));
      }

      try (final Tx tx = app.tx()) {

        a.setProperty(TestSix.oneToOneTestThree, d);
        tx.success();

      } catch (FrameworkException fex) {

        fex.printStackTrace();

        fail("Unable to link test nodes");
      }

      try (final Tx tx = app.tx()) {

        // verify connection
        TestThree verifyD2 = a.getProperty(TestSix.oneToOneTestThree);
        assertTrue(verifyD2 != null && verifyD2.equals(d));

        // testSix2 should not have a testThree associated
        TestThree vrfy4 = c.getProperty(TestSix.oneToOneTestThree);
        assertNull(vrfy4);
      }
     
    } catch (FrameworkException fex) {
     
View Full Code Here


   
    try {

      final TestSix testSix1     = createTestNode(TestSix.class);
      final TestSix testSix2     = createTestNode(TestSix.class);
      final TestThree testThree1 = createTestNode(TestThree.class);
      final TestThree testThree2 = createTestNode(TestThree.class);

      try (final Tx tx = app.tx()) {

        testSix1.setProperty(AbstractNode.name, "a");
        testSix2.setProperty(AbstractNode.name, "c");
        testThree1.setProperty(AbstractNode.name, "b");
        testThree2.setProperty(AbstractNode.name, "d");
        tx.success();

      } catch (FrameworkException fex) {

        fex.printStackTrace();
View Full Code Here

    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 {
View Full Code Here

TOP

Related Classes of org.structr.core.entity.TestThree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.