Package at.fhj.itm.model

Examples of at.fhj.itm.model.Trip


    String copyright = set.getString("copyright");

    User user = userDao.getByID(userId, connection);
    Waypoint wp = waypointDAO.getByID(waypoint, connection);

    return new Trip(id, user, departureDate, seats, wp, copyright);
  }
View Full Code Here


      stmt.setString(2, town);
      ResultSet set = stmt.executeQuery();
      List<Trip> trips = new ArrayList<Trip>();
      while (set.next()) {
        int id = set.getInt("id");
        Trip t = getByID(id, connection);
        trips.add(t);
      }
      set.close();
      stmt.close();
View Full Code Here

      PreparedStatement stmt = connection
          .prepareStatement(GET_TRIP_BY_ID);
      stmt.setInt(1, id);
      ResultSet set = stmt.executeQuery();
      set.next();
      Trip trip = createTripFromResultSet(set, connection);
      set.close();
      stmt.close();
      return trip;
    } catch (SQLException e) {
View Full Code Here

      stmt.setInt(1, userID);
      ResultSet set = stmt.executeQuery();
      List<Trip> trips = new ArrayList<Trip>();
      while (set.next()) {
        int id = set.getInt("id");
        Trip t = getByID(id, connection);
        trips.add(t);
      }
      set.close();
      stmt.close();
View Full Code Here

      stmt.setInt(2, userID);
      ResultSet set = stmt.executeQuery();
      List<Trip> trips = new ArrayList<Trip>();
      while (set.next()) {
        int id = set.getInt("id");
        Trip t = getByID(id, connection);
        trips.add(t);
      }
      set.close();
      stmt.close();
View Full Code Here

    departure = new Date();
    mockTripCreator = new User("Trip","Creator","","","","",null,null, "");
    fromLocation = new Location(1,1000,"City1");
    toLocation = new Location(2,2000,"City2");
    mockTripWaypoint = new Waypoint(1,fromLocation,toLocation,mockTripCreator,"",true);
    mockTrip4Seats = new Trip(1,mockTripCreator,departure,4,mockTripWaypoint,"");
    mockTripBooker = new User("Trip", "Booker", "", "", "", "", null, null, "");
    mockBookerWaypointInactive = new Waypoint(fromLocation,toLocation,mockTripBooker,"",false);
    mockJsfUtil = EasyMock.createMock(JsfUtil.class);
    mockGoogleUtil = EasyMock.createMock(GoogleUtil.class);
    mockTripDAO = EasyMock.createMock(TripDAO.class);
View Full Code Here

   * @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();
View Full Code Here

   * @throws JSONException
   */
  @Test
  public void testInsertTripException() 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);
   
    // Setup Mocks:
    EasyMock.expect(mockJsfUtil.getLoggedInUser()).andReturn(mockTripCreator);
    mockBegin();
    mockTripDAO.update(newTrip, mockGetConnection());
View Full Code Here

   * @throws IOException
   */
  @Test
  public void testInsertTripNoConnection() 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);
    mockBeginNoConnection();
    replayMocks();
View Full Code Here

   * @throws JSONException
   */
  @Test
  public void testInsertTripCommitFailed() 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);
   
   
    // Setup Mocks:
    EasyMock.expect(mockJsfUtil.getLoggedInUser()).andReturn(mockTripCreator);
    mockBegin();
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.