@Test public void mockedWithSpy() { EmailsReader emailsReader = Mockito.mock(EmailsReader.class); LotteryMachine lotteryMachine = new LotteryMachine(5); LotteryMachine spyMachine = Mockito.spy(lotteryMachine); String seedString = "Test"; long longSeed = 1L; when(spyMachine.getSeed()).thenReturn(longSeed); Lottery lottery = new Lottery(emailsReader, spyMachine, seedString); lottery.run(); Assert.assertEquals(LotteryMachine.DEFAULT_SEED, lotteryMachine.getSeed()); Assert.assertEquals(longSeed, spyMachine.getSeed()); }
void run() { List<String> emails = emailsSource.get(); System.out.println("Emails count: " + emails.size()); List<String> winners = machine.setSeed(seedString).draw(emails); System.out.println("Winners:"); winners.forEach(System.out::println); }
Lottery { void run() { List<String> emails = emailsSource.get(); System.out.println("Emails count: " + emails.size()); List<String> winners = machine.setSeed(seedString).draw(emails); System.out.println("Winners:"); winners.forEach(System.out::println); } }
Lottery { void run() { List<String> emails = emailsSource.get(); System.out.println("Emails count: " + emails.size()); List<String> winners = machine.setSeed(seedString).draw(emails); System.out.println("Winners:"); winners.forEach(System.out::println); } Lottery(Supplier<List<String>> emailsSource,
            LotteryMachine machine,
            String seedString); }
Lottery { void run() { List<String> emails = emailsSource.get(); System.out.println("Emails count: " + emails.size()); List<String> winners = machine.setSeed(seedString).draw(emails); System.out.println("Winners:"); winners.forEach(System.out::println); } Lottery(Supplier<List<String>> emailsSource,
            LotteryMachine machine,
            String seedString);  }
Lottery { void run() { List<String> emails = emailsSource.get(); System.out.println("Emails count: " + emails.size()); List<String> winners = machine.setSeed(seedString).draw(emails); System.out.println("Winners:"); winners.forEach(System.out::println); } Lottery(Supplier<List<String>> emailsSource,
            LotteryMachine machine,
            String seedString);   }