@Test
    public void insertTest2() {
        int i, j, heapDimension, min = 201, x;
        HeapNode hNode = null, minHNode = null;
        Random randomGenerator = new Random();
        heapDimension = 100 + randomGenerator.nextInt(200); //[100, 200)
        MinHeap heap = new MinHeap(heapDimension);
        for (i = 0; i < heapDimension; i++) {
            x = 1 + randomGenerator.nextInt(200);
            hNode = new HeapNode(i, 0, x);
            if (x < min) {
                min = x;
                minHNode = hNode;
            }
            try {
                heap.insert(hNode);
            } catch (Exception ex) {
                fail("Exception was not expected to be thrown.");
            }
            assertEquals(heap.lastFreePos, i + 1);
            assertEquals(heap.heapNodes[0], minHNode);
            assertFalse(heap.positions[hNode.vertex] == -1);
            for (j = 0; j < heap.lastFreePos; j++) {
                assertEquals(j, heap.positions[heap.heapNodes[j].vertex]);

                if ((j + 1) * 2 - 1 < heap.lastFreePos) {
                    assertTrue(heap.heapNodes[j].compareTo(heap.heapNodes[(j + 1) * 2 - 1]) <= 0);
                } else {
                    continue;
                }
                if ((j + 1) * 2 < heap.lastFreePos) {
                    assertTrue(heap.heapNodes[j].compareTo(heap.heapNodes[(j + 1) * 2]) <= 0);
                }
            }
        }

        try {
            heap.insert(new HeapNode(1, 2, 3));
            fail("Heap should be full.");
        } catch (Exception ex) {
            assertEquals(ex.getMessage(), "Heap overflow");
        }
    }