Package org.structr.core.entity

Examples of org.structr.core.entity.TestFour


      final PropertyMap properties  = new PropertyMap();
      final PropertyKey<String> key = TestFour.stringProperty;
     
      properties.put(key, "test");
     
      final TestFour testEntity     = createTestNode(TestFour.class, properties);
     
      assertNotNull(testEntity);
     
      try (final Tx tx = app.tx()) {

        // check value from database
        assertEquals("test", testEntity.getProperty(key));
       
        Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test").getResult();

        assertEquals(result.size(), 1);
        assertEquals(result.get(0), testEntity);
View Full Code Here


  public void testSimpleSearchOnRelationship() {
   
    try {

      final TestOne testOne        = createTestNode(TestOne.class);
      final TestFour testFour      = createTestNode(TestFour.class);
      final Property<String> key   = OneFourOneToOne.stringProperty;
     
      assertNotNull(testOne);
      assertNotNull(testFour);
     
View Full Code Here

   
    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");
View Full Code Here

      final PropertyMap properties  = new PropertyMap();
      final PropertyKey<Boolean> key = TestFour.booleanProperty;
     
      properties.put(key, true);
     
      final TestFour testEntity     = createTestNode(TestFour.class, properties);
     
      assertNotNull(testEntity);

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

        // check value from database
        assertEquals((Boolean)true, (Boolean)testEntity.getProperty(key));

        Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, true).getResult();

        assertEquals(1, result.size());
        assertEquals(testEntity, result.get(0));
View Full Code Here

  public void testSimpleSearchOnRelationship() {
   
    try {

      final TestOne testOne        = createTestNode(TestOne.class);
      final TestFour testFour      = createTestNode(TestFour.class);
      final Property<Boolean> key = OneFourOneToOne.booleanProperty;
     
      assertNotNull(testOne);
      assertNotNull(testFour);
     
View Full Code Here

    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.TestFour

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.