Package org.structr.web.entity

Examples of org.structr.web.entity.User


      assertEquals(p2, paragraphs.item(1));
      assertEquals(p3, paragraphs.item(2));
      assertEquals(p4, paragraphs.item(3));

      // create users
      final User tester1 = app.create(User.class, new NodeAttribute<>(User.name, "tester1"), new NodeAttribute<>(User.eMail, "tester1@test.com"));
      final User tester2 = app.create(User.class, new NodeAttribute<>(User.name, "tester2"), new NodeAttribute<>(User.eMail, "tester2@test.com"));

      assertNotNull("User tester1 should exist.", tester1);
      assertNotNull("User tester2 should exist.", tester2);

      tx.success();

    } catch (FrameworkException fex) {

      fail("Unexpected exception");
    }

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

      final RenderContext ctx = new RenderContext();
      ctx.setPage(page);

      // test for "empty" return value
      assertEquals("", p1.replaceVariables(securityContext, ctx, "${err}"));
      assertEquals("", p1.replaceVariables(securityContext, ctx, "${this.error}"));
      assertEquals("", p1.replaceVariables(securityContext, ctx, "${this.this.this.error}"));
      assertEquals("", p1.replaceVariables(securityContext, ctx, "${parent.error}"));
      assertEquals("", p1.replaceVariables(securityContext, ctx, "${this.owner}"));
      assertEquals("", p1.replaceVariables(securityContext, ctx, "${parent.owner}"));

      // other functions are tested in the ActionContextTest in structr-core, see there.
      assertEquals("true", p1.replaceVariables(securityContext, ctx, "${true}"));
      assertEquals("false", p1.replaceVariables(securityContext, ctx, "${false}"));
      assertEquals("yes", p1.replaceVariables(securityContext, ctx, "${if(true, \"yes\", \"no\")}"));
      assertEquals("no", p1.replaceVariables(securityContext, ctx, "${if(false, \"yes\", \"no\")}"));
      assertEquals("true", p1.replaceVariables(securityContext, ctx, "${if(true, true, false)}"));
      assertEquals("false", p1.replaceVariables(securityContext, ctx, "${if(false, true, false)}"));

      assertEquals("${element} should evaluate to the current DOM node", p1.toString(), p1.replaceVariables(securityContext, ctx, "${element}"));

      assertNull(p1.replaceVariables(securityContext, ctx, "${if(true, null, \"no\")}"));
      assertNull(p1.replaceVariables(securityContext, ctx, "${null}"));

      assertEquals("Invalid replacement result", "/testpage?" + page.getUuid(), p1.replaceVariables(securityContext, ctx, "/${page.name}?${page.id}"));
      assertEquals("Invalid replacement result", "/testpage?" + page.getUuid(), a.replaceVariables(securityContext, ctx, "/${link.name}?${link.id}"));

      // these tests find single element => success
      assertEquals("Invalid replacement result", page.getUuid(), a.replaceVariables(securityContext, ctx, "${get(find('Page', 'name', 'testpage'), 'id')}"));
      assertEquals("Invalid replacement result", a.getUuid(), a.replaceVariables(securityContext, ctx, "${get(find('A'), 'id')}"));

      // this test finds multiple <p> elements => error
      assertEquals("Invalid replacement result", Functions.ERROR_MESSAGE_GET_ENTITY, a.replaceVariables(securityContext, ctx, "${get(find('P'), 'id')}"));

      // more complex replacement
      //assertEquals("Invalid replacement result", "", a.replaceVariables(securityContext, ctx, "${get(find('P'), 'id')}"));

      // String default value
      assertEquals("bar", p1.replaceVariables(securityContext, ctx, "${request.foo!bar}"));

      // Number default value (will be evaluated to a string)
      assertEquals("1", p1.replaceVariables(securityContext, ctx, "${page.position!1}"));

      // Number default value
      assertEquals("true", p1.replaceVariables(securityContext, ctx, "${equal(42, this.null!42)}"));


      final User tester1 = app.nodeQuery(User.class).andName("tester1").getFirst();
      final User tester2 = app.nodeQuery(User.class).andName("tester2").getFirst();

      assertNotNull("User tester1 should exist.", tester1);
      assertNotNull("User tester2 should exist.", tester2);

      final SecurityContext tester1Context = SecurityContext.getInstance(tester1, AccessMode.Backend);
View Full Code Here


      final List<User> users = createTestNodes(User.class, 3);

      assertEquals(3, users.size());

      User user1 = users.get(0);
      user1.setProperty(AbstractNode.name, "user1");
      User user2 = users.get(1);
      user2.setProperty(AbstractNode.name, "user2");
      User user3 = users.get(2);
      user3.setProperty(AbstractNode.name, "user3");

      final List<File> files = createTestNodes(File.class, 6);

      assertEquals(6, files.size());
View Full Code Here

TOP

Related Classes of org.structr.web.entity.User

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.