@Override
 protected void setUp() throws Exception {
   super.setUp();
   db = BeerBuddyDbHelper.getInstance(getActivity());
   spotDAOLocal = new DrinkingSpotDAOLocal(getActivity());
   personDAOLocal = new PersonDAOLocal(getActivity());
 }
  public void testInsert() throws DataAccessException {
    Person p = insertPerson();
    DrinkingSpot ds = new DrinkingSpot();
    ds.setCreator(p);
    ds.setStartTime(new Date());
    ds.setGps("asd");
    ds = spotDAOLocal.insert(ds);
    Assert.assertTrue(ds.getId() != -1);
    Assert.assertTrue(ds.getId() != 0);
    Log.i("BeerBuddy", ds.toString());
    // select it
    SQLiteDatabase writableDatabase = db.getWritableDatabase();

    Cursor dbCursor = writableDatabase.rawQuery("Select * from person", null);
    while (dbCursor.moveToNext()) {
      for (String colname : dbCursor.getColumnNames()) {
        Log.i("BeerBuddy", colname + ": " + dbCursor.getString(dbCursor.getColumnIndex(colname)));
        ;
      }
    }
    dbCursor.close();
    assertTrue(dbCursor.getCount() > 0);

    dbCursor =
        writableDatabase.rawQuery(
            "Select * from drinkingspot where id = ?", new String[] {ds.getId() + ""});
    while (dbCursor.moveToNext()) {
      for (String colname : dbCursor.getColumnNames()) {
        Log.i("BeerBuddy", colname + ": " + dbCursor.getString(dbCursor.getColumnIndex(colname)));
        ;
      }

      assertEquals(ds.getId(), dbCursor.getLong(dbCursor.getColumnIndex("id")));
    }
    assertTrue(dbCursor.getCount() > 0);
    dbCursor.close();

    DrinkingSpot byId = spotDAOLocal.getById(ds.getId());
    assertNotNull(byId);

    byId = spotDAOLocal.getActiveByPersonId(p.getId());
    assertNotNull(byId);
  }