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);
}
Aggregations