### Question:
CheckUserQuoteScheduler implements Job { @Override public void execute(JobExecutionContext context) { environmentService.getUsers() .stream() .map(UserDTO::getName) .filter(billingDAO::isUserQuoteReached) .peek(u -> log.warn("Stopping {} user env because of reaching user billing quote", u)) .forEach(environmentService::stopEnvironmentWithServiceAccount); }  @Override void execute(JobExecutionContext context);  }### Answer:
@Test public void testWhenUserQuoteReached() { when(billingDAO.isUserQuoteReached(anyString())).thenReturn(true); when(environmentService.getUsers()).thenReturn(Collections.singletonList(new UserDTO(USER, 1, UserDTO.Status.ACTIVE))); checkUserQuoteScheduler.execute(jobExecutionContext); verify(environmentService).getUsers(); verify(billingDAO).isUserQuoteReached(USER); verify(environmentService).stopEnvironmentWithServiceAccount(USER); verifyNoMoreInteractions(environmentService, billingDAO); verifyZeroInteractions(jobExecutionContext); }
@Test public void testWhenUserQuoteNotReached() { when(billingDAO.isUserQuoteReached(anyString())).thenReturn(false); when(environmentService.getUsers()).thenReturn(Collections.singletonList(new UserDTO(USER, 1, UserDTO.Status.ACTIVE))); checkUserQuoteScheduler.execute(jobExecutionContext); verify(environmentService).getUsers(); verify(billingDAO).isUserQuoteReached(USER); verify(environmentService, never()).stopEnvironmentWithServiceAccount(anyString()); verifyNoMoreInteractions(environmentService, billingDAO); verifyZeroInteractions(jobExecutionContext); }