/** * Given that I have an article in the persistence layer, When I call {@link * ElasticSearchManager#pushArticleById(String} and pass in its id, Then I will retrieve it from * the persistence layer and post it into ElasticSearch */ @Test public void testPushArticleByValidId() { Article article = new Article(); Observable<Article> articleObservable = Observable.just(article); expect(articleManager.getArticleById(TEST_ID)).andReturn(articleObservable); client.postArticle(article); expectLastCall(); replayMocks(); esManager.pushArticleById(TEST_ID); verifyMocks(); }
/** * Given that I have a set of articles in my DB, When I call {@link * ElasticSearchManager#pushAllArticles()}, Then I will retrieve all articles from the persistence * layer and post them into ElasticSearch <br> * TODO: Change the {@link Thread#sleep(long)} for something better like a {@link CountDownLatch}. * <br> * TODO: Investigate if the latter is the reason for the test failing sometimes, or is there * another reason. * * @throws InterruptedException */ @Test public void testPushAllArticles() throws InterruptedException { Article article = new Article(); Observable<Article> articles = Observable.just(article, article); expect(articleManager.getAllArticles()).andReturn(articles); client.postArticle(article); expectLastCall().times(2); replayMocks(); esManager.pushAllArticles(); // Should change this for CountDownLatch or a similar solution, left // like this just for testing Thread.sleep(250); verifyMocks(); }