Permalink
Please sign in to comment.
Browse files
Fix Relations in sample app (JOIN column names collision)
- Loading branch information...
Showing
with
156 additions
and 16 deletions.
- +4 −1 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/AppComponent.java
- +2 −2 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/DbModule.java
- +26 −0 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/entities/TweetWithUser.java
- +26 −0 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/entities/User.java
- +6 −7 ...mple-app/src/main/java/com/pushtorefresh/storio/sample/db/resolvers/TweetWithUserGetResolver.java
- +4 −2 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/tables/TweetsTable.java
- +6 −0 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/tables/UsersTable.java
- +31 −4 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/sample_code/Relations.java
- +2 −0 storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/ui/fragment/TweetsFragment.java
- +49 −0 storio-sample-app/src/test/java/com/pushtorefresh/storio/sample/sample_code/RelationsTest.java
5
storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/AppComponent.java
4
storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/DbModule.java
26
...o-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/entities/TweetWithUser.java
26
storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/entities/User.java
13
.../src/main/java/com/pushtorefresh/storio/sample/db/resolvers/TweetWithUserGetResolver.java
6
storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/tables/TweetsTable.java
6
storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/db/tables/UsersTable.java
35
storio-sample-app/src/main/java/com/pushtorefresh/storio/sample/sample_code/Relations.java
2
...-sample-app/src/main/java/com/pushtorefresh/storio/sample/ui/fragment/TweetsFragment.java
49
...o-sample-app/src/test/java/com/pushtorefresh/storio/sample/sample_code/RelationsTest.java
@@ -0,0 +1,49 @@ | ||
+package com.pushtorefresh.storio.sample.sample_code; | ||
+ | ||
+import com.pushtorefresh.storio.contentresolver.BuildConfig; | ||
+import com.pushtorefresh.storio.sample.SampleApp; | ||
+import com.pushtorefresh.storio.sample.db.entities.Tweet; | ||
+import com.pushtorefresh.storio.sample.db.entities.TweetWithUser; | ||
+import com.pushtorefresh.storio.sample.db.entities.User; | ||
+ | ||
+import org.junit.Test; | ||
+import org.junit.runner.RunWith; | ||
+import org.robolectric.RobolectricGradleTestRunner; | ||
+import org.robolectric.RuntimeEnvironment; | ||
+import org.robolectric.annotation.Config; | ||
+ | ||
+import java.util.List; | ||
+ | ||
+import static java.util.Arrays.asList; | ||
+import static org.assertj.core.api.Assertions.assertThat; | ||
+ | ||
+@RunWith(RobolectricGradleTestRunner.class) | ||
+@Config(constants = BuildConfig.class, sdk = 21) | ||
+public class RelationsTest { | ||
+ | ||
+ @Test | ||
+ public void name() { | ||
+ SampleApp sampleApp = (SampleApp) RuntimeEnvironment.application; | ||
+ | ||
+ sampleApp.appComponent().storIOSQLite() | ||
+ .put() | ||
+ .objects(asList( | ||
+ Tweet.newTweet(1L, "artem_zin", "test tweet 1"), | ||
+ Tweet.newTweet(2L, "artem_zin", "test tweet 2"), | ||
+ Tweet.newTweet(3L, "nikitin-da", "test tweet 3"), | ||
+ User.newUser(1L, "artem_zin"), | ||
+ User.newUser(2L, "nikitin-da")) | ||
+ ) | ||
+ .prepare() | ||
+ .executeAsBlocking(); | ||
+ | ||
+ Relations relations = new Relations(sampleApp.appComponent().storIOSQLite()); | ||
+ List<TweetWithUser> tweetsWithUsers = relations.getTweetWithUser(); | ||
+ | ||
+ assertThat(tweetsWithUsers).hasSize(3); // Same as count of tweets, not users. | ||
+ | ||
+ assertThat(tweetsWithUsers.get(0)).isEqualTo(new TweetWithUser(Tweet.newTweet(1L, "artem_zin", "test tweet 1"), User.newUser(1L, "artem_zin"))); | ||
+ assertThat(tweetsWithUsers.get(1)).isEqualTo(new TweetWithUser(Tweet.newTweet(2L, "artem_zin", "test tweet 2"), User.newUser(1L, "artem_zin"))); | ||
+ assertThat(tweetsWithUsers.get(2)).isEqualTo(new TweetWithUser(Tweet.newTweet(3L, "nikitin-da", "test tweet 3"), User.newUser(2L, "nikitin-da"))); | ||
+ } | ||
+} |
0 comments on commit
468ff87