Package org.structr.core

Examples of org.structr.core.Result


        tx.success();
      }

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

        Result result = app.nodeQuery(NodeInterface.class).uuid(uuid).getResult();

        assertEquals("Node should have been deleted", 0, result.size());

      } catch (FrameworkException fe) {}

    } catch (FrameworkException ex) {
View Full Code Here


      SecurityContext publicContext = SecurityContext.getInstance(null, AccessMode.Frontend);

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

        Result result = StructrApp.getInstance(publicContext).nodeQuery(type).getResult();

        // Node should not be visible in public context (no user logged in)
        assertTrue(result.isEmpty());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

      SecurityContext publicContext = SecurityContext.getInstance(null, AccessMode.Frontend);

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

        Result result = StructrApp.getInstance(publicContext).nodeQuery(type).getResult();

        assertEquals(1, result.size());
        assertEquals(t1.getUuid(), result.get(0).getUuid());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

      TestOne t2 = createTestNode(TestOne.class, props, user);

      SecurityContext publicContext = SecurityContext.getInstance(null, AccessMode.Frontend);

      try (final Tx tx = app.tx()) {
        Result result = StructrApp.getInstance(publicContext).nodeQuery(type).getResult();

        assertEquals(1, result.size());
        assertEquals(t1.getUuid(), result.get(0).getUuid());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

      // Let another user search
      SecurityContext user2Context = SecurityContext.getInstance(user2, AccessMode.Backend);

      try (final Tx tx = app.tx()) {
        Result result = StructrApp.getInstance(user2Context).nodeQuery(type).getResult();

        assertEquals(2, result.size());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

      // Let another user search
      SecurityContext user2Context = SecurityContext.getInstance(user2, AccessMode.Frontend);

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

        Result result = StructrApp.getInstance(user2Context).nodeQuery(type).getResult();

        assertEquals(2, result.size());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

    try {

      List<TestUser> users = createTestNodes(TestUser.class, 2);
      TestUser user1 = (TestUser) users.get(0);
      TestUser user2 = (TestUser) users.get(1);
      Result result = null;

      // Let user 1 create a node
      Class type = TestOne.class;
      final TestOne t1 = createTestNode(TestOne.class, user1);

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

        // Grant read permission to user 2
        user2.grant(Permission.read, t1);
        tx.success();
      }

      // Let user 2 search
      SecurityContext user2Context = SecurityContext.getInstance(user2, AccessMode.Backend);

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

        result = StructrApp.getInstance(user2Context).nodeQuery(type).getResult();

        assertEquals(1, result.size());
        assertEquals(t1.getUuid(), result.get(0).getUuid());
      }

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

        // Revoke permission again
        user2.revoke(Permission.read, t1);
        tx.success();
      }

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

        result = StructrApp.getInstance(user2Context).nodeQuery(type).getResult();
        assertTrue(result.isEmpty());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

      SecurityContext publicContext = SecurityContext.getInstance(null, AccessMode.Frontend);

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

        Result result = StructrApp.getInstance(publicContext).nodeQuery(type).getResult();

        assertEquals(3, result.size());
        assertEquals(3, (int) result.getRawResultCount());

        assertEquals(nodes.get(3).getUuid(), result.get(0).getUuid());
        assertEquals(nodes.get(5).getUuid(), result.get(1).getUuid());
        assertEquals(nodes.get(7).getUuid(), result.get(2).getUuid());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

      int pageSize        = 2;
      int page            = 1;

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

        Result result = StructrApp.getInstance(publicContext).nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

        assertEquals(2, result.size());
        assertEquals(4, (int) result.getRawResultCount());

        assertEquals(nodes.get(3).getUuid(), result.get(0).getUuid());
        assertEquals(nodes.get(5).getUuid(), result.get(1).getUuid());
      }

    } catch (FrameworkException ex) {

      logger.log(Level.SEVERE, ex.toString());
View Full Code Here

        tx.success();
      }

      try (final Tx tx = app.tx()) {
       
        Result result = app.nodeQuery(type).getResult();

        assertEquals(number, result.size());

        PropertyKey sortKey = AbstractNode.name;
        boolean sortDesc    = false;
        int pageSize        = 10;
        int page            = 1;

        result = app.nodeQuery(type).sort(sortKey).order(sortDesc).page(page).pageSize(pageSize).getResult();

        logger.log(Level.INFO, "Raw result size: {0}, expected: {1}", new Object[] { result.getRawResultCount(), number });
        assertEquals(number, (int) result.getRawResultCount());
        logger.log(Level.INFO, "Result size: {0}, expected: {1}", new Object[] { result.size(), Math.min(number, pageSize) });
        assertEquals(Math.min(number, pageSize), result.size());

        for (int j = 0; j < Math.min(result.size(), pageSize); j++) {

          String expectedName = "TestOne-" + (offset + j);
          String gotName     = result.get(j).getProperty(AbstractNode.name);

          System.out.println(expectedName + ", got: " + gotName);
          assertEquals(expectedName, gotName);

        }
View Full Code Here

TOP

Related Classes of org.structr.core.Result

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.