Package org.syncany.operations.down

Examples of org.syncany.operations.down.DatabaseBranches


     */
   
    /// Input data ///
    String localMachineName = "C";
    DatabaseVersionHeader currentLocalVersion = TestDatabaseUtil.createFromString("A/(A2)/T=1376074225230");
    DatabaseBranches allBranches = new DatabaseBranches();

    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1376074225169",
      "A/(A2)/T=1376074225230",
      "A/(A3)/T=1376074225256",

      // Conflicts with A -> A3,B1; also: SAME timestamp!
      "A/(A4)/T=9999999999999",
    }));
   
    allBranches.put("B", TestDatabaseUtil.createBranch(new String[] {
      // Conflicts with B -> A4; also: SAME timestamp!
      "B/(A3,B1)/T=9999999999999"
    }));
   
    allBranches.put("C", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1376074225169",
      "A/(A2)/T=1376074225230",
    }));
       
    /// Expected results ///
View Full Code Here


    testFromMachinePerspective(localMachineName, currentLocalVersion, allBranches, expectedTestResult);
  }     

  @Test
  public void testStitchBranches() throws Exception {
    DatabaseBranches allBranches = new DatabaseBranches();
   
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1376074225169",
      "A/(A2)/T=1376074225230",
      "A/(A3)/T=1376074225256",
    }));
   
    allBranches.put("B", TestDatabaseUtil.createBranch(new String[] {
      "B/(A3,B1)/T=1376074225356"
    }));
   
    allBranches.put("C", TestDatabaseUtil.createBranch(new String[] {
      "C/(C1)/T=1376074225383",
      "C/(C2)/T=1376074225399",
      "C/(C3)/T=1376074225416",
    }));   
   
    DatabaseReconciliator databaseVersionUpdateDetector = new DatabaseReconciliator();
    DatabaseBranches actualStitchedRemoteBranches = databaseVersionUpdateDetector.stitchBranches(allBranches, "D", new DatabaseBranch());
   
    DatabaseBranches expectedStitchedBranches = new DatabaseBranches();
   
    expectedStitchedBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1376074225169",
      "A/(A2)/T=1376074225230",
      "A/(A3)/T=1376074225256",
    }));
   
    expectedStitchedBranches.put("B", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1376074225169",
      "A/(A2)/T=1376074225230",
      "A/(A3)/T=1376074225256",
      "B/(A3,B1)/T=1376074225356"
    }));
   
    expectedStitchedBranches.put("C", TestDatabaseUtil.createBranch(new String[] {
      "C/(C1)/T=1376074225383",
      "C/(C2)/T=1376074225399",
      "C/(C3)/T=1376074225416",
    }));
   
    assertEquals("Stitched branches not equal.", expectedStitchedBranches.toString(), actualStitchedRemoteBranches.toString());
  }
View Full Code Here

    assertEquals("Stitched branches not equal.", expectedStitchedBranches.toString(), actualStitchedRemoteBranches.toString());
  }
 
  @Test
  public void testStitchBranches2() throws Exception {   
    DatabaseBranches allBranches = new DatabaseBranches();
   
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1",
      "A/(A2)/T=2",
      // --> B
      "A/(A3,B1)/T=4",
      "A/(A4,B1)/T=5",
      "A/(A5,B1)/T=6",
      // --> C
     
    }));
   
    allBranches.put("B", TestDatabaseUtil.createBranch(new String[] {
      "B/(A2,B1)/T=3",
      // --> A
      "B/(A5,B2,C2)/T=9",
      // --> C
    }));
   
    allBranches.put("C", TestDatabaseUtil.createBranch(new String[] {
      "C/(A5,B1,C1)/T=7",
      "C/(A5,B1,C2)/T=8",
      // --> B
      "C/(A5,B2,C3)/T=10",
    }));   
   
    DatabaseReconciliator databaseVersionUpdateDetector = new DatabaseReconciliator();
    DatabaseBranches actualStitchedRemoteBranches = databaseVersionUpdateDetector.stitchBranches(allBranches, "D", new DatabaseBranch());
   
    DatabaseBranches expectedStitchedBranches = new DatabaseBranches();
   
    expectedStitchedBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
        "A/(A1)/T=1",
        "A/(A2)/T=2",
        "B/(A2,B1)/T=3",
        "A/(A3,B1)/T=4",
        "A/(A4,B1)/T=5",
        "A/(A5,B1)/T=6",
    }));
   
    expectedStitchedBranches.put("B", TestDatabaseUtil.createBranch(new String[] {
        "A/(A1)/T=1",
        "A/(A2)/T=2",
        "B/(A2,B1)/T=3",
        "A/(A3,B1)/T=4",
        "A/(A4,B1)/T=5",
        "A/(A5,B1)/T=6",
        "C/(A5,B1,C1)/T=7",
        "C/(A5,B1,C2)/T=8",
        "B/(A5,B2,C2)/T=9",
    }));
   
    expectedStitchedBranches.put("C", TestDatabaseUtil.createBranch(new String[] {
        "A/(A1)/T=1",
        "A/(A2)/T=2",
        "B/(A2,B1)/T=3",
        "A/(A3,B1)/T=4",
        "A/(A4,B1)/T=5",
        "A/(A5,B1)/T=6",
        "C/(A5,B1,C1)/T=7",
        "C/(A5,B1,C2)/T=8",
        "B/(A5,B2,C2)/T=9",
        "C/(A5,B2,C3)/T=10",
    }));
   
    assertEquals("Stitched branches not equal.", expectedStitchedBranches.toString(), actualStitchedRemoteBranches.toString());
  }   
View Full Code Here

   
    // Get 'local' branch
    DatabaseBranch localBranch = allBranches.getBranch(localMachineName);
   
    // Get all the other ones (clone 'all', and remove local)
    DatabaseBranches unstitchedRemoteBranches = allBranches.clone();
    unstitchedRemoteBranches.remove(localMachineName);

    DatabaseBranches stitchedRemoteBranches = databaseReconciliator.stitchBranches(unstitchedRemoteBranches, localMachineName, localBranch);
   
    System.out.println("Before Orchestration : Remote");
    printBranches(unstitchedRemoteBranches);
    System.out.println("Before Orchestration : Local");
    printBranch(localBranch);
View Full Code Here

TOP

Related Classes of org.syncany.operations.down.DatabaseBranches

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.