Package org.structr.core.entity

Examples of org.structr.core.entity.TestSix


  public void test01DeleteRelationship() {

    try {

      final TestOne testOne  = createTestNode(TestOne.class);
      final TestSix testSix  = createTestNode(TestSix.class);
      SixOneOneToOne rel     = null;

      assertNotNull(testOne);
      assertNotNull(testSix);
View Full Code Here


  public void testOneToOne() throws Exception {

    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

  public void testOneToMany() throws Exception {
   
    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();

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

      assertNotNull(testSix1);
      assertNotNull(testThree1);
      assertNotNull(testSix2);
      assertNotNull(testThree2);

      /**
       * We test the following here:
       * A -> B
       * C -> D
       *
       * then connect A -> D, so C and B should not
       * be related any more
       */
      try (final Tx tx = app.tx()) {

        testSix1.setProperty(TestSix.oneToManyTestThrees, toList(testThree1));
        testSix2.setProperty(TestSix.oneToManyTestThrees, toList(testThree2));
        tx.success();

      } catch (FrameworkException fex) {

        fex.printStackTrace();

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

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

        // verify connections
        List<TestThree> verifyB = testSix1.getProperty(TestSix.oneToManyTestThrees);
        List<TestThree> verifyD = testSix2.getProperty(TestSix.oneToManyTestThrees);

        assertTrue(verifyB != null && verifyB.get(0).equals(testThree1));
        assertTrue(verifyD != null && verifyD.get(0).equals(testThree2));
      }
     
      try (final Tx tx = app.tx()) {

        testSix1.setProperty(TestSix.oneToManyTestThrees, toList(testThree2));
        tx.success();

      } catch (FrameworkException fex) {

        fex.printStackTrace();

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

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

        // verify connection
        List<TestThree> verifyD2 = testSix1.getProperty(TestSix.oneToManyTestThrees);
        assertEquals(1, verifyD2.size());
        assertEquals(testThree2, verifyD2.get(0));

        // testSix2 should not have a testThree associated
        List<TestThree> vrfy4 = testSix2.getProperty(TestSix.oneToManyTestThrees);
        assertEquals(0, vrfy4.size());
      }
     
    } catch (FrameworkException fex) {
     
View Full Code Here

  public void testManyToMany() throws Exception {

    try {

      Property<List<TestOne>> instance = TestSix.manyToManyTestOnes;
      TestSix testSix1  = null;
      TestSix testSix2  = null;
      TestOne testOne1  = null;
      TestOne testOne2  = null;

      testSix1 = createTestNode(TestSix.class);
      testSix2 = createTestNode(TestSix.class);
View Full Code Here

  public void test01DeleteAfterLookupWithCypherInTransaction() {

    try {

      final TestSix testSix = this.createTestNode(TestSix.class);
      final TestOne testOne = this.createTestNode(TestOne.class);
      SixOneOneToOne rel            = null;

      assertNotNull(testSix);
      assertNotNull(testOne);
View Full Code Here

  public void test03DeleteDirectly() {

    try {

      final TestOne testOne  = createTestNode(TestOne.class);
      final TestSix testSix  = createTestNode(TestSix.class);
      SixOneOneToOne rel     = null;

      assertNotNull(testOne);
      assertNotNull(testSix);
View Full Code Here

  public void test04DeleteAfterIndexLookup() {

    try {

      final TestOne testOne  = createTestNode(TestOne.class);
      final TestSix testSix  = createTestNode(TestSix.class);
      SixOneOneToOne rel     = null;

      assertNotNull(testOne);
      assertNotNull(testSix);

      try (final Tx tx = app.tx()) {
       
        rel = app.create(testSix, testOne, SixOneOneToOne.class);
        tx.success();
      }

      assertNotNull(rel);

      try (final Tx tx = app.tx()) {
       
        GraphObject  searchRes = app.get(testSix.getUuid());
        assertNotNull(searchRes);
      }
     
      try (final Tx tx = app.tx()) {
       
        testSix.getRelationships().iterator().next().getRelationship().delete();

        tx.success();
      }

      try (final Tx tx = app.tx()) {
View Full Code Here

TOP

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

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.