use of org.syncany.database.VectorClock in project syncany by syncany.
the class VectorClockTest method testCompareSmallerClocksWithDifferentUnitCount.
@Test
public void testCompareSmallerClocksWithDifferentUnitCount() {
VectorClock vc1 = new VectorClock();
vc1.setClock("UnitA", 4L);
vc1.setClock("UnitB", 5L);
VectorClock vc2 = new VectorClock();
// same
vc2.setClock("UnitA", 4L);
// same
vc2.setClock("UnitB", 5L);
// not in vc1
vc2.setClock("UnitC", 100000L);
assertEquals("Expected clock 1 to be smaller than clock 2.", VectorClockComparison.SMALLER, VectorClock.compare(vc1, vc2));
assertEquals("Expected clock 2 to be greater than clock 1.", VectorClockComparison.GREATER, VectorClock.compare(vc2, vc1));
}
use of org.syncany.database.VectorClock in project syncany by syncany.
the class VectorClockTest method testNormalVectorClockUsage.
@Test
public void testNormalVectorClockUsage() {
VectorClock vc = new VectorClock();
vc.setClock("UnitA", 1);
vc.setClock("UnitB", 2);
vc.setClock("UnitC", 3);
assertEquals("Expected clock value to be different.", 1L, (long) vc.getClock("UnitA"));
assertEquals("Expected clock value to be different.", 2L, (long) vc.getClock("UnitB"));
assertEquals("Expected clock value to be different.", 3L, (long) vc.getClock("UnitC"));
}
use of org.syncany.database.VectorClock in project syncany by syncany.
the class VectorClockTest method testParseClock.
@Test
public void testParseClock() {
VectorClock vc1 = VectorClock.parseVectorClock("(UnitBBB5,UnitAAA4)");
assertEquals(4L, (long) vc1.get("UnitAAA"));
assertEquals(5L, (long) vc1.get("UnitBBB"));
}
use of org.syncany.database.VectorClock in project syncany by syncany.
the class VectorClockTest method testCompareGreaterClocksWithSameUnitCount.
@Test
public void testCompareGreaterClocksWithSameUnitCount() {
VectorClock vc1 = new VectorClock();
vc1.setClock("UnitA", 4L);
vc1.setClock("UnitB", 5L);
VectorClock vc2 = new VectorClock();
vc2.setClock("UnitA", 4L);
// greater!
vc2.setClock("UnitB", 100000L);
assertEquals("Expected clock 2 to be greater than clock 1.", VectorClockComparison.GREATER, VectorClock.compare(vc2, vc1));
assertEquals("Expected clock 1 to be smaller than clock 2.", VectorClockComparison.SMALLER, VectorClock.compare(vc1, vc2));
}
use of org.syncany.database.VectorClock in project syncany by syncany.
the class VectorClockTest method testIncrementNonExistingUnit.
@Test
public void testIncrementNonExistingUnit() {
VectorClock vc = new VectorClock();
vc.incrementClock("NonExistingUnit");
assertEquals("Expected clock value to be different.", 1L, (long) vc.getClock("NonExistingUnit"));
}
Aggregations