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();
}
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;
}
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);
}
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());
}
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);
}
Aggregations