use of com.android.example.devsummit.archdemo.vo.Post in project dev-summit-architecture-demo by yigit.
the class TestUtil method createDummyPost.
public static Post createDummyPost(Long userId) {
Post post = new Post();
post.setId(sPostIdCounter++);
post.setText(UUID.randomUUID().toString());
post.setClientId(UUID.randomUUID().toString());
if (userId == null) {
post.setUserId(1);
} else {
post.setUserId(userId);
}
post.setCreated(System.currentTimeMillis());
return post;
}
use of com.android.example.devsummit.archdemo.vo.Post in project dev-summit-architecture-demo by yigit.
the class TestUtil method createDummyFeedItem.
public static FeedItem createDummyFeedItem() {
User user = createDummyUser();
Post post = createDummyPost(user.getId());
return new FeedItem(post, user);
}
use of com.android.example.devsummit.archdemo.vo.Post in project dev-summit-architecture-demo by yigit.
the class FeedActivityTest method refreshFeedWithOlderItems.
@Test
public void refreshFeedWithOlderItems() throws Throwable {
FeedModel mockFeedModel = mock(FeedModel.class);
when(mComponent.feedModel()).thenReturn(mockFeedModel);
FeedItem feedItem1 = TestUtil.createDummyFeedItem();
FeedItem feedItem2 = TestUtil.createDummyFeedItem();
List<FeedItem> items = Collections.singletonList(feedItem1);
List<FeedItem> items2 = Arrays.asList(feedItem1, feedItem2);
Post post1 = feedItem1.getPost();
final Post post2 = feedItem2.getPost();
post1.setCreated(10L);
post2.setCreated(2L);
//noinspection unchecked
when(mockFeedModel.loadFeed(0L, null)).thenReturn(items);
when(mockFeedModel.loadFeed(1L, null)).thenReturn(items2);
getActivity();
onView(atAdapterPosition(getActivity().mBinding.list, 0)).check(matches(withChild(withText(post1.getText())))).check(matches(withChild(withText(feedItem1.getUser().getName()))));
runTestOnUiThread(new Runnable() {
@Override
public void run() {
getActivity().onEventMainThread(new FetchedFeedEvent(true, null, post2));
}
});
onItemAt(0).check(matches(withChild(withText(post1.getText())))).check(matches(withChild(withText(feedItem1.getUser().getName()))));
onItemAt(1).check(matches(withChild(withText(post2.getText())))).check(matches(withChild(withText(feedItem2.getUser().getName()))));
}
use of com.android.example.devsummit.archdemo.vo.Post in project dev-summit-architecture-demo by yigit.
the class PostModelTest method insertInvalidPost.
@Test(expected = ValidationFailedException.class)
public void insertInvalidPost() {
Post p = new Post();
p.setUserId(-1);
mPostModel.save(p);
}
use of com.android.example.devsummit.archdemo.vo.Post in project dev-summit-architecture-demo by yigit.
the class PostModelTest method loadByClientIds.
@Test
public void loadByClientIds() {
Post post = TestUtil.createDummyPost();
String clientId = post.getClientId();
long userId = post.getUserId();
mPostModel.save(post);
Post loaded = mPostModel.loadByClientIdAndUserId(clientId, userId);
assertThat(loaded, notNullValue());
assertThat(loaded.getUserId(), is(userId));
assertThat(loaded.getClientId(), is(clientId));
}
Aggregations