* @throws JSONException
*/
@Test
public void testInsertTrip() throws SQLException, IOException, JSONException {
Waypoint waypoint = new Waypoint(fromLocation, toLocation, mockTripCreator, null, true);
Trip newTrip = new Trip(mockTripCreator,departure,4,waypoint, "");
Trip tripWithPoint = newTrip;
List<Point> points = new ArrayList<Point>();
points.add(new Point(0, 0.0, 0.0, 0, newTrip.getId()));
tripWithPoint.setPoints(points);
JSONObject jsonObject = null;
// Setup Mocks:
EasyMock.expect(mockJsfUtil.getLoggedInUser()).andReturn(mockTripCreator);
mockBegin();
mockTripDAO.update(tripWithPoint, mockGetConnection());
EasyMock.expectLastCall();
mockCommit();
mockCloseConnection();
mockBegin();
EasyMock.expect(mockWaypointDAO.getWaypointsForTrip(newTrip, mockGetConnection())).andReturn(new ArrayList<Waypoint>());
EasyMock.expect(mockGoogleUtil.getJsonObj(newTrip, new ArrayList<Waypoint>())).andReturn(jsonObject);
EasyMock.expect(mockGoogleUtil.loadGoogleData(newTrip, jsonObject)).andReturn(tripWithPoint);
mockPointDAO.insertPoints(tripWithPoint.getPoints(), mockGetConnection());
EasyMock.expectLastCall();
mockCommit();
mockCloseConnection();
replayMocks();