Search in sources :

Example 6 with Team

use of net.johnpwood.android.standuptimer.model.Team in project standup-timer by jwood.

the class MeetingDAOTest method test_delete_a_single_meeting.

@MediumTest
public void test_delete_a_single_meeting() {
    Meeting meeting = new Meeting(new Team("Test Team"), new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), 5, 240, 300, 30, 120);
    meeting = dao.save(meeting);
    meeting = dao.findById(meeting.getId());
    assertNotNull(meeting.getId());
    dao.delete(meeting);
    meeting = dao.findById(meeting.getId());
    assertNull(meeting);
}
Also used : Meeting(net.johnpwood.android.standuptimer.model.Meeting) GregorianCalendar(java.util.GregorianCalendar) Team(net.johnpwood.android.standuptimer.model.Team) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 7 with Team

use of net.johnpwood.android.standuptimer.model.Team in project standup-timer by jwood.

the class TeamDAO method updateExistingTeam.

private Team updateExistingTeam(SQLiteDatabase db, Team team) {
    Logger.d("Updating team with the name of '" + team.getName() + "'");
    ContentValues values = new ContentValues();
    values.put(TEAMS_NAME, team.getName());
    long id = db.update(TEAMS_TABLE_NAME, values, _ID + " = ?", new String[] { team.getId().toString() });
    return new Team(id, team.getName());
}
Also used : ContentValues(android.content.ContentValues) Team(net.johnpwood.android.standuptimer.model.Team)

Example 8 with Team

use of net.johnpwood.android.standuptimer.model.Team in project standup-timer by jwood.

the class TeamDAO method findByName.

public Team findByName(String name) {
    Cursor cursor = null;
    Team team = null;
    name = name.trim();
    try {
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(TEAMS_TABLE_NAME, TEAMS_ALL_COLUMS, TEAMS_NAME + " = ?", new String[] { name }, null, null, null);
        if (cursor.getCount() == 1) {
            if (cursor.moveToFirst()) {
                long id = cursor.getLong(0);
                name = cursor.getString(1);
                team = new Team(id, name);
            }
        }
    } finally {
        closeCursor(cursor);
    }
    Logger.d((team == null ? "Unsuccessfully" : "Successfully") + " found team with a name of '" + name + "'");
    return team;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Team(net.johnpwood.android.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 9 with Team

use of net.johnpwood.android.standuptimer.model.Team in project standup-timer by jwood.

the class TeamDAO method findById.

public Team findById(Long id) {
    Cursor cursor = null;
    Team team = null;
    try {
        SQLiteDatabase db = getReadableDatabase();
        cursor = db.query(TEAMS_TABLE_NAME, TEAMS_ALL_COLUMS, _ID + " = ?", new String[] { id.toString() }, null, null, null);
        if (cursor.getCount() == 1) {
            if (cursor.moveToFirst()) {
                String name = cursor.getString(1);
                team = new Team(id, name);
            }
        }
    } finally {
        closeCursor(cursor);
    }
    return team;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Team(net.johnpwood.android.standuptimer.model.Team) Cursor(android.database.Cursor)

Example 10 with Team

use of net.johnpwood.android.standuptimer.model.Team in project standup-timer by jwood.

the class MeetingDAOTest method test_cannot_update_a_meeting_that_has_already_been_created.

@MediumTest
public void test_cannot_update_a_meeting_that_has_already_been_created() {
    Meeting meeting = new Meeting(new Team("Test Team"), new GregorianCalendar(2010, 1, 5, 10, 15, 0).getTime(), 5, 240, 300, 30, 120);
    meeting = dao.save(meeting);
    try {
        dao.save(meeting);
        fail("Should have thrown an exception");
    } catch (CannotUpdateMeetingException e) {
        assertTrue(true);
    }
}
Also used : Meeting(net.johnpwood.android.standuptimer.model.Meeting) GregorianCalendar(java.util.GregorianCalendar) Team(net.johnpwood.android.standuptimer.model.Team) CannotUpdateMeetingException(net.johnpwood.android.standuptimer.dao.CannotUpdateMeetingException) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Aggregations

Team (net.johnpwood.android.standuptimer.model.Team)37 MediumTest (android.test.suitebuilder.annotation.MediumTest)28 Meeting (net.johnpwood.android.standuptimer.model.Meeting)17 GregorianCalendar (java.util.GregorianCalendar)16 Date (java.util.Date)3 ContentValues (android.content.ContentValues)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 RenamingDelegatingContext (android.test.RenamingDelegatingContext)2 MeetingDAO (net.johnpwood.android.standuptimer.dao.MeetingDAO)2 TeamDAO (net.johnpwood.android.standuptimer.dao.TeamDAO)2 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 CannotUpdateMeetingException (net.johnpwood.android.standuptimer.dao.CannotUpdateMeetingException)1 DuplicateTeamException (net.johnpwood.android.standuptimer.dao.DuplicateTeamException)1 InvalidTeamNameException (net.johnpwood.android.standuptimer.dao.InvalidTeamNameException)1 MeetingStats (net.johnpwood.android.standuptimer.model.MeetingStats)1