### Question:
CycleService { public Collection<Cycle> getAllCycles() { Collection<Cycle> cycles = new ArrayList<>(); for (Cycle cycle : cycleRepository.findAll()) { cycles.add(cycle); } return cycles; } @Autowired  CycleService(
      CyclePreparationCloningService cyclePreparationCloningService,
      CycleRepository cycleRepository,
      CompanyHistoryRepository companyHistoryRepository,
      CompanyService companyService); Collection<Cycle> getAllCycles(); Cycle findById(Long cycleId); @Transactional Cycle updateCycle(Cycle updatedCycle); @Transactional void deleteCycle(Long cycleId, User user); @Transactional Cycle defineCycle(Long oldCycleId, Cycle cycle); @EventListener(ApplicationReadyEvent.class) void applicationStartCycleProcessing(); @Scheduled(cron = threeInTheMorningCronExpr) void dailyCycleProcessing(); @Transactional void processAutomaticCycleSwitch();  }### Answer:
@Test public void getAllCycles_expectedNoCycles() { Collection<Cycle> expectedCycles = new ArrayList<>(); when(cycleRepository.findAll()).thenReturn(new ArrayList<>()); Collection<Cycle> actualCycles = cycleService.getAllCycles(); Assert.assertEquals(expectedCycles, actualCycles); }
@Test public void getAllCycles_expectedOneCycle() { Cycle testCycle1 = new Cycle("TestCycle1"); Collection<Cycle> expectedCycles = new ArrayList<>(); expectedCycles.add(testCycle1); Collection<Cycle> outputCycles = new ArrayList<>(); outputCycles.add(testCycle1); when(cycleRepository.findAll()).thenReturn(outputCycles); Collection<Cycle> actualCycles = cycleService.getAllCycles(); Assert.assertEquals(expectedCycles, actualCycles); }
@Test public void getAllCycles_expectedMultipleCycles() { Cycle testCycle1 = new Cycle("TestCycle1"); Cycle testCycle2 = new Cycle("TestCycle2"); Collection<Cycle> expectedCycles = new ArrayList<>(); expectedCycles.add(testCycle1); expectedCycles.add(testCycle2); Collection<Cycle> outputCycles = new ArrayList<>(); outputCycles.add(testCycle1); outputCycles.add(testCycle2); when(cycleRepository.findAll()).thenReturn(outputCycles); Collection<Cycle> actualCycles = cycleService.getAllCycles(); Assert.assertEquals(expectedCycles, actualCycles); }