### Question:
TweeterApplicationRunner implements ApplicationRunner { @Override @Transactional public void run(ApplicationArguments args) throws Exception { this.tweetRepository .save(new Tweet(UUID.randomUUID(), "Demo1", "making", Instant.now())); this.tweetRepository .save(new Tweet(UUID.randomUUID(), "Demo2", "making", Instant.now())); long count = this.tweetRepository.count(); System.out.println("Number of tweets: " + count); Iterable<Tweet> tweets = this.tweetRepository.findAll(); tweets.forEach(tweet -> System.out.println(tweet)); } TweeterApplicationRunner(TweetRepository tweetRepository); @Override @Transactional void run(ApplicationArguments args);  }### Answer:
@Test void contextLoads(CapturedOutput capture) throws Exception { TweetRepository TweetRepository = mock(TweetRepository.class); given(TweetRepository.count()).willReturn(2L); Instant now = Instant.now(); UUID uuid1 = UUID.randomUUID(); UUID uuid2 = UUID.randomUUID(); given(TweetRepository.findAll()) .willReturn(Arrays.asList(new Tweet(uuid1, "test1", "making", now), new Tweet(uuid2, "test2", "making", now))); TweeterApplicationRunner tweeterApplicationRunner = new TweeterApplicationRunner( TweetRepository); tweeterApplicationRunner.run(new DefaultApplicationArguments(new String[] {})); String output = capture.toString(); assertThat(output).contains("Number of tweets: 2"); assertThat(output).contains("Tweet{uuid=" + uuid1 + ", text='test1', username='making', createdAt=" + now + "}"); assertThat(output).contains("Tweet{uuid=" + uuid2 + ", text='test2', username='making', createdAt=" + now + "}"); }