Package at.fhj.itm.model

Examples of at.fhj.itm.model.Trip


   * @throws JSONException
   */
  @Test
  public void testInsertTriploadGoogleDataThrowsIOException() 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);
View Full Code Here


   * @throws JSONException
   */
  @Test
  public void testInsertTriploadGoogleDataThrowsJSONException() 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);
View Full Code Here

   * @throws JSONException
   */
  @Test
  public void testInsertTripgetJSONObjectThrowsIOException() throws SQLException, IOException {
    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);
   
   
    // Setup Mocks:
    EasyMock.expect(mockJsfUtil.getLoggedInUser()).andReturn(mockTripCreator);
    mockBegin();
View Full Code Here

   * @throws JSONException
   */
  @Test
  public void testInsertTriploadAndPersistGoogleDataThrowsSQLException() 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();
    EasyMock.expectLastCall().andThrow(new SQLException());
    mockRollback();
    mockCloseConnection();
View Full Code Here

    User user = new User("Unit", "Test", "UnitTest", "1234", "Unit@Test.com", "123456",
        location, new Date(), UUID.randomUUID().toString().replace("-", ""));
    Location from = new Location(8190, "Birkfeld");
    Location to = new Location(8010, "Graz");
    Waypoint wp = new Waypoint(from, to, user, "", true);
    Trip t = new Trip(user, new Date(), 4, wp, "Copyright (C) Google");
   
    return t;
  }
View Full Code Here

   * @throws JSONException
   */
  @Test
  public void testInsertTriploadAndPersistGoogleDataThrowsDAOException() 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().andThrow(new DAOException("getPoints throws DAOException"));
    mockRollback();
    mockCloseConnection();
 
    replayMocks();
View Full Code Here

   * associated
   * @throws SQLException
   */
  @Test
  public void testWaypointForTrip()throws SQLException{
    Trip testTrip = createTestTrip();
    factory.getTripDAO().update(testTrip, connection);
    dao.addWaypointToTrip(testTrip,testTrip.getWaypoint(), connection);
    connection.commit();
    List<Waypoint> waypoints = dao.getWaypointsForTrip(testTrip, connection);
    assertEquals(1, waypoints.size());
    assertEquals(testTrip.getWaypoint(), waypoints.get(0));
  }
View Full Code Here

    User user = new User("Unit", "Test", "UnitTest", "1234", "Unit@Test.com", "123456",
        location, new Date(), UUID.randomUUID().toString().replace("-", ""));
    Location from = new Location(8190, "Birkfeld");
    Location to = new Location(8010, "Graz");
    Waypoint wp = new Waypoint(from, to, user, "", true);
    Trip t = new Trip(user, new Date(), 4, wp, "Copyright (C) Google");
   
    return t;
  }
View Full Code Here

  public void testInsertDeleteTrip()throws SQLException{

 
    int before = dao.selectAll(connection).size();
   
    Trip t = createTestTrip();
   
    dao.update(t, connection);
    connection.commit();
    assertTrue(t.getId() != -1);
    assertTrue(t.getWaypoint().getId() != -1);
    assertTrue(t.getWaypoint().getFromLocation().getId() != -1);
    assertTrue(t.getWaypoint().getToLocation().getId() != -1);
    assertTrue(t.getWaypoint().getUser().getId() != -1);   
    int after = dao.selectAll(connection).size();
    assertTrue(after > before);
    dao.delete(t, connection);
   
    int afterDelete = dao.selectAll(connection).size();
    assertTrue(t.getId() == -1);
    assertTrue(t.getWaypoint().getId() == -1);
    assertTrue(t.getUser().getId() != -1);
    assertEquals(before, afterDelete);
  }
View Full Code Here

   * DAO can perform an update on the already created trip.
   * @throws SQLException
   */
  @Test
  public void testUpdate()throws SQLException{
    Trip t = createTestTrip();
    dao.update(t, connection);
    assertTrue(t.getId() != -1);
    t.setSeats(1);
    dao.update(t, connection);
    connection.commit();
    Trip newTrip = dao.getByID(t.getId(), connection);
    assertEquals(t.getSeats(), newTrip.getSeats());
   
   
   
  }
View Full Code Here

TOP

Related Classes of at.fhj.itm.model.Trip

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.