Search in sources :

Example 6 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class AllianceSelectionNotification method parseMessageData.

@Override
public void parseMessageData() throws JsonParseException {
    JsonObject jsonData = JSONHelper.getasJsonObject(messageData);
    if (!jsonData.has("event")) {
        throw new JsonParseException("Notification data does not have an 'event' object");
    }
    event = mGson.fromJson(jsonData.get("event"), Event.class);
    eventKey = event.getKey();
}
Also used : JsonObject(com.google.gson.JsonObject) Event(com.thebluealliance.androidclient.models.Event) JsonParseException(com.google.gson.JsonParseException)

Example 7 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class EventTeamsTable method getEvents.

/**
 * Get a list of {@link Event} models for an EventTeam (teamKey + year)
 */
public List<Event> getEvents(String teamKey, int year) {
    // INNER JOIN EventTeams + Events on KEY, select where teamKey and year = args
    String query = String.format("SELECT %1$s FROM %2$s JOIN %3$s ON %2$s.%4$s = %3$s.%5$s " + "WHERE %2$s.%6$s = ? AND %2$s.%7$s = ?", EventsTable.getAllColumnsForJoin(), Database.TABLE_EVENTTEAMS, Database.TABLE_EVENTS, EVENTKEY, EventsTable.KEY, TEAMKEY, YEAR);
    Cursor cursor = mDb.rawQuery(query, new String[] { teamKey, Integer.toString(year) });
    ArrayList<Event> results = new ArrayList<>();
    if (cursor != null && cursor.moveToFirst()) {
        do {
            results.add(ModelInflater.inflateEvent(cursor));
        } while (cursor.moveToNext());
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) Event(com.thebluealliance.androidclient.models.Event) Cursor(android.database.Cursor)

Example 8 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class MyTbaModelRendererTest method testRenderEventTeam.

@Test
public void testRenderEventTeam() {
    Team team = ModelMaker.getModel(Team.class, TEAM_KEY);
    Event event = ModelMaker.getModel(Event.class, EVENT_KEY);
    when(mDatafeed.fetchTeam(TEAM_KEY)).thenReturn(Observable.just(team));
    when(mDatafeed.fetchEvent(EVENT_KEY)).thenReturn(Observable.just(event));
    ListItem item = mRenderer.renderFromKey(EVENT_TEAM_KEY, ModelType.EVENTTEAM, null);
    assertNotNull(item);
    assertTrue(item instanceof ModelListElement);
    assertEquals(((ModelListElement) item).getText(), "UberBots @ 2015 Hartford");
    assertEquals(((ModelListElement) item).getKey(), EVENT_TEAM_KEY);
    assertEquals(((ModelListElement) item).getType(), ModelType.EVENTTEAM);
}
Also used : Event(com.thebluealliance.androidclient.models.Event) Team(com.thebluealliance.androidclient.models.Team) ModelListElement(com.thebluealliance.androidclient.listitems.ModelListElement) ListItem(com.thebluealliance.androidclient.listitems.ListItem) Test(org.junit.Test)

Example 9 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class AllianceSelectionNotificationTest method testDbWrite.

@Test
public void testDbWrite() {
    mNotification.parseMessageData();
    mNotification.updateDataLocally();
    Event event = mNotification.getEvent();
    verify(mWriter).write(eq(event), anyLong());
}
Also used : Event(com.thebluealliance.androidclient.models.Event) Test(org.junit.Test)

Example 10 with Event

use of com.thebluealliance.androidclient.models.Event in project the-blue-alliance-android by the-blue-alliance.

the class AllianceSelectionNotificationTest method testParseData.

@Test
public void testParseData() {
    mNotification.parseMessageData();
    assertEquals(mNotification.getEventKey(), "2014necmp");
    Event event = mNotification.getEvent();
    assertNotNull(event);
}
Also used : Event(com.thebluealliance.androidclient.models.Event) Test(org.junit.Test)

Aggregations

Event (com.thebluealliance.androidclient.models.Event)35 Test (org.junit.Test)8 Team (com.thebluealliance.androidclient.models.Team)6 ArrayList (java.util.ArrayList)5 District (com.thebluealliance.androidclient.models.District)4 Date (java.util.Date)4 JsonObject (com.google.gson.JsonObject)3 TeamAvatarUpdateEvent (com.thebluealliance.androidclient.eventbus.TeamAvatarUpdateEvent)3 Match (com.thebluealliance.androidclient.models.Match)3 EventRenderer (com.thebluealliance.androidclient.renderers.EventRenderer)3 Before (org.junit.Before)3 Cursor (android.database.Cursor)2 Nullable (androidx.annotation.Nullable)2 WorkerThread (androidx.annotation.WorkerThread)2 JsonElement (com.google.gson.JsonElement)2 MatchSortByPlayOrderComparator (com.thebluealliance.androidclient.comparators.MatchSortByPlayOrderComparator)2 EventMatchesEvent (com.thebluealliance.androidclient.eventbus.EventMatchesEvent)2 LiveEventUpdateEvent (com.thebluealliance.androidclient.eventbus.LiveEventUpdateEvent)2 ListGroup (com.thebluealliance.androidclient.listitems.ListGroup)2 DistrictPointBreakdown (com.thebluealliance.androidclient.models.DistrictPointBreakdown)2