@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)); }
@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)); }