@Test
public final void testCalculateLineBearing() {

    Map<Lines, Line> lines = mockBearingTestLines();
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L1),
            BearingDirection.IN_DIRECTION, BEARING_DISTANCE, 0),
            BEARING_L1_IN_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L2),
            BearingDirection.AGAINST_DIRECTION, BEARING_DISTANCE, Lines.L2.lenght),
            BEARING_L2_AGAINST_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L3),
            BearingDirection.IN_DIRECTION, BEARING_DISTANCE, 0),
            BEARING_L3_IN_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L4),
            BearingDirection.AGAINST_DIRECTION, BEARING_DISTANCE, Lines.L4.lenght),
            BEARING_L4_AGAINST_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(null, null,
            BEARING_DISTANCE, 0), EXPECTED_BEARING_ERROR);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L1),
            BearingDirection.IN_DIRECTION, BEARING_DISTANCE,
            PAL_DISTANCE_LONG), BEARING_L1_PAL_IN_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L2),
            BearingDirection.AGAINST_DIRECTION, BEARING_DISTANCE,
            PAL_DISTANCE_LONG), BEARING_L2_PAL_AGAINST_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L3),
            BearingDirection.IN_DIRECTION, BEARING_DISTANCE,
            PAL_DISTANCE_SHORT), BEARING_L3_PAL_IN_DIRECTION);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.L4),
            BearingDirection.AGAINST_DIRECTION, BEARING_DISTANCE,
            PAL_DISTANCE_SHORT), BEARING_L4_PAL_AGAINST_DIRECTION);
    // test the bearing calculation in the case all points are in the same
    // latitude line.
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.VERTICAL_LINE),
            BearingDirection.IN_DIRECTION, BEARING_DISTANCE, 0),
            BEARING_180);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.VERTICAL_LINE),
            BearingDirection.AGAINST_DIRECTION, BEARING_DISTANCE, 0),
            BEARING_0);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.VERTICAL_LINE),
            BearingDirection.IN_DIRECTION, BEARING_DISTANCE,
            PAL_DISTANCE_SHORT), BEARING_180);
    assertEquals(GeometryUtils.calculateLineBearing(lines.get(Lines.VERTICAL_LINE),
            BearingDirection.AGAINST_DIRECTION, BEARING_DISTANCE,
            PAL_DISTANCE_SHORT), BEARING_0);
}