Package com.betfair.platform.virtualheap.utils

Examples of com.betfair.platform.virtualheap.utils.RandomHeapBuilder


    @Test
    public void shouldGenerateHeapDiff() {

        // Get two identical heaps
        RandomHeapBuilder to = new RandomHeapBuilder(1000);
        RandomHeapBuilder from = new RandomHeapBuilder(to.getAllUpdates());

        // Diverge them
        to.randomUpdate(100);
        from.randomUpdate(100);

        // generate the diff
        UpdateBlock diff = HeapDiff.getHeapDiffFrom(from).to(to);

        // apply the diff
        from.update(diff);

        // test that the diff was accurate
        assertEquals(to, from);

    }
View Full Code Here


    }

    @Test
    public void shouldReturnEmptyUpdateBlockForTwoIdenticalHeaps() {
        // Get two identical heaps
        RandomHeapBuilder to = new RandomHeapBuilder(1000);
        RandomHeapBuilder from = new RandomHeapBuilder(to.getAllUpdates());

        // when
        UpdateBlock block = HeapDiff.getHeapDiffFrom(from).to(to);

        // then
View Full Code Here

    }

    @Test
    public void shouldGenerateHeapDiffWhenFromHeapIsEmpty() {
        // given
        Heap to = new RandomHeapBuilder(1000);
        Heap from = new MutableHeap(null);

        // when
        UpdateBlock block = HeapDiff.getHeapDiffFrom(from).to(to);
        Heap result = new HeapBuilder(block);
View Full Code Here

    @Test(expected = IllegalArgumentException.class)
    public void shouldFailConvertingNonEmptyToEmpty() {
         // given
        Heap to = new MutableHeap(null);
        Heap from = new RandomHeapBuilder(1000);

        // when
        HeapDiff.getHeapDiffFrom(from).to(to);
    }
View Full Code Here

public abstract class ConflaterTest {

    protected abstract Conflater getConflater();

    public void doConflaterTest(List<Update> updates, boolean print)  {
        RandomHeapBuilder randomHeapBuilder = new RandomHeapBuilder();
        randomHeapBuilder.update(updates);
        doConflaterTest(randomHeapBuilder, print);
    }
View Full Code Here

        randomHeapBuilder.update(updates);
        doConflaterTest(randomHeapBuilder, print);
    }

    public void doConflaterTest(int updates, boolean print)  {
        RandomHeapBuilder randomHeapBuilder = new RandomHeapBuilder();
        randomHeapBuilder.randomUpdate(updates);

        doConflaterTest(randomHeapBuilder, print);
    }
View Full Code Here

        doConflaterTest(10000, false);
    }

    @Test
    public void testAcrossTransactionBoundaries()  {
        RandomHeapBuilder randomHeapBuilder = new RandomHeapBuilder();

        randomHeapBuilder.randomUpdate(1000);
        UpdateBlock tx1 = randomHeapBuilder.getLastUpdate();

        randomHeapBuilder.randomUpdate(1000);
        UpdateBlock tx2 = randomHeapBuilder.getLastUpdate();

        doTestAcrossTransactionBoundaries(tx1.list(), tx2.list(), false);
    }
View Full Code Here

TOP

Related Classes of com.betfair.platform.virtualheap.utils.RandomHeapBuilder

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.