EnvironmentService { @Transactional public void delete(Long id) { Environment environment = environmentRepository.findOne(id); HeimdallException.checkThrow(environment == null, GLOBAL_RESOURCE_NOT_FOUND); Integer totalEnvironmentsAttached = environmentRepository.findApisWithEnvironment(id); HeimdallException.checkThrow(totalEnvironmentsAttached > 0, ENVIRONMENT_ATTACHED_TO_API); environmentRepository.delete(environment); }  Environment find(Long id); EnvironmentPage list(EnvironmentDTO environmentDTO, PageableDTO pageableDTO); List<Environment> list(EnvironmentDTO environmentDTO); @Transactional Environment save(EnvironmentDTO environmentDTO); @Transactional Environment update(Long id, EnvironmentDTO environmentDTO); @Transactional void delete(Long id);  }
@Test public void deleteEnviroment() { Mockito.when(environmentRepository.findOne(Mockito.anyLong())).thenReturn(environment); this.environmentService.delete(1L); Mockito.verify(this.environmentRepository, Mockito.times(1)).delete(environment); }