Search in sources :

Example 1 with DatabaseReconciliator

use of org.syncany.operations.down.DatabaseReconciliator in project syncany by syncany.

the class DatabaseReconciliatorTest method testFromMachinePerspective.

private void testFromMachinePerspective(String localMachineName, DatabaseVersionHeader currentLocalVersion, DatabaseBranches allBranches, TestResult expectedTestResult) throws Exception {
    // Print them all
    System.out.println("testFromMachinePerspective('" + localMachineName + "') with database version headers:");
    printBranches(allBranches);
    System.out.println("----------");
    DatabaseReconciliator databaseReconciliator = new DatabaseReconciliator();
    TestResult actualTestResult = new TestResult();
    // 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);
    System.out.println("Unstitched Branches (from remote):");
    System.out.println("##################################");
    printBranches(unstitchedRemoteBranches);
    System.out.println();
    System.out.println("Unstitched Local Branch (client '" + localMachineName + "'):");
    System.out.println("##################################");
    printBranch(localBranch);
    System.out.println();
    Entry<String, DatabaseBranch> winnersBranch = databaseReconciliator.findWinnerBranch(allBranches);
    System.out.println("Winners Branch (winner is " + winnersBranch.getKey() + "):");
    System.out.println("##################################");
    printBranch(winnersBranch.getValue());
    System.out.println();
    actualTestResult.winnersLastDatabaseVersionHeader = new AbstractMap.SimpleEntry<String, DatabaseVersionHeader>(winnersBranch.getKey(), winnersBranch.getValue().getLast());
    System.out.println("Actual winnersLastDatabaseVersionHeader = " + actualTestResult.winnersLastDatabaseVersionHeader);
    System.out.println("Expect winnersLastDatabaseVersionHeader = " + expectedTestResult.winnersLastDatabaseVersionHeader);
    assertEquals("Different winners winners last version expected", expectedTestResult.winnersLastDatabaseVersionHeader, actualTestResult.winnersLastDatabaseVersionHeader);
}
Also used : AbstractMap(java.util.AbstractMap) DatabaseReconciliator(org.syncany.operations.down.DatabaseReconciliator) DatabaseBranch(org.syncany.operations.down.DatabaseBranch) DatabaseVersionHeader(org.syncany.database.DatabaseVersionHeader) DatabaseBranches(org.syncany.operations.down.DatabaseBranches)

Aggregations

AbstractMap (java.util.AbstractMap)1 DatabaseVersionHeader (org.syncany.database.DatabaseVersionHeader)1 DatabaseBranch (org.syncany.operations.down.DatabaseBranch)1 DatabaseBranches (org.syncany.operations.down.DatabaseBranches)1 DatabaseReconciliator (org.syncany.operations.down.DatabaseReconciliator)1