@Test
 public void testMissingResult() {
   Club gremio = TestFixtures.GREMIO;
   Club internacional = TestFixtures.INTERNACIONAL;
   Match match = Match.create(gremio, internacional);
   service.create(Arrays.asList(gremio, internacional));
   service.create(match);
   assertThat(service.query(AutoValueClasses.MATCH)).isEqualTo(Collections.singletonList(match));
 }
Exemple #2
0
 @Override
 public Match fromCursor(SimpleCursor cursor, ElifutDataStore service) {
   Club home = checkNotNull(service.queryOne(AutoValueClasses.CLUB, cursor.getInt("home_id")));
   Club away = checkNotNull(service.queryOne(AutoValueClasses.CLUB, cursor.getInt("away_id")));
   Persistable.Converter<MatchResult> converter =
       service.converterForType(AutoValueClasses.MATCH_RESULT);
   MatchResult matchResult = converter.fromCursor(cursor, service);
   return Match.create(cursor.getInt("id"), home, away, matchResult);
 }
 @Test
 public void testMatches() {
   Goal goal = newGoal(1, TestFixtures.GREMIO);
   MatchResult matchResult =
       MatchResult.builder()
           .homeGoals(Collections.singletonList(goal))
           .awayGoals(Collections.emptyList())
           .build(TestFixtures.GREMIO, TestFixtures.INTERNACIONAL);
   Match match = Match.create(TestFixtures.GREMIO, TestFixtures.INTERNACIONAL, matchResult);
   service.create(Arrays.asList(TestFixtures.GREMIO, TestFixtures.INTERNACIONAL));
   service.create(match);
   assertThat(service.query(AutoValueClasses.MATCH)).isEqualTo(Collections.singletonList(match));
 }
Exemple #4
0
  /** This assumes that the clubs participating in this match have been previously created. */
  @Override
  public ContentValues toContentValues(Match match, ElifutDataStore service) {
    Persistable.Converter<MatchResult> converter =
        service.converterForType(AutoValueClasses.MATCH_RESULT);
    ContentValuesBuilder contentValuesBuilder =
        ContentValuesBuilder.create()
            .put("home_id", match.home().id())
            .put("away_id", match.away().id());

    if (match.result() != null) {
      contentValuesBuilder.put(converter.toContentValues(match.result(), service));
    }

    return contentValuesBuilder.build();
  }