@Test public void testInitUser() { when(user.findId("me")).thenReturn(Single.just("1")); when(randomText.getText(anyInt())).thenReturn("My random text"); when(user.getUsers()).thenReturn(Observable.from(Arrays.asList(new Resource<>(new User("1", "me", "Me"))))); FeedItemInitializer initializer = new FeedItemInitializer(this.repo, this.user, this.randomText); initializer.minItems = 5; Single<List<FeedItem>> single = initializer.init("me"); assertThat("single was null", single, is(notNullValue())); List<FeedItem> items = single.toBlocking().value(); assertThat("items was null", items, is(notNullValue())); assertThat("items was wrong size", items.size(), is(greaterThanOrEqualTo(5))); }
Observable<UserFeedItem> initUser(String username) { Single<String> userid = userService.findId(username); return initUser(username, userid); }
FeedItemInitializer { Observable<UserFeedItem> initUser(String username) { Single<String> userid = userService.findId(username); return initUser(username, userid); } }
FeedItemInitializer { Observable<UserFeedItem> initUser(String username) { Single<String> userid = userService.findId(username); return initUser(username, userid); } @Autowired  FeedItemInitializer(FeedItemRepository repo, UserService userService, RandomText randomText); }
FeedItemInitializer { Observable<UserFeedItem> initUser(String username) { Single<String> userid = userService.findId(username); return initUser(username, userid); } @Autowired  FeedItemInitializer(FeedItemRepository repo, UserService userService, RandomText randomText); @RequestMapping("/init/all") Single<Map<String, Collection<FeedItem>>> initAll(); @RequestMapping("/init") Single<List<FeedItem>> init(@RequestParam(value = "user") String username); @ServiceActivator(inputChannel = FeedBinder.USER_INITIALIZED) void handleUserInited(User user); }
FeedItemInitializer { Observable<UserFeedItem> initUser(String username) { Single<String> userid = userService.findId(username); return initUser(username, userid); } @Autowired  FeedItemInitializer(FeedItemRepository repo, UserService userService, RandomText randomText); @RequestMapping("/init/all") Single<Map<String, Collection<FeedItem>>> initAll(); @RequestMapping("/init") Single<List<FeedItem>> init(@RequestParam(value = "user") String username); @ServiceActivator(inputChannel = FeedBinder.USER_INITIALIZED) void handleUserInited(User user);  }