@Test public void deleteDefaultPlan() { Mockito.when(planRepository.findOne(Mockito.anyLong())).thenReturn(plan); this.planService.delete(1L); Mockito.verify(this.planRepository, Mockito.times(1)).delete(plan); }
public void delete(Long id) { Plan plan = planRepository.findOne(id); HeimdallException.checkThrow(plan == null, GLOBAL_RESOURCE_NOT_FOUND); Integer totalAppsAttached = planRepository.findAppsWithPlan(id); HeimdallException.checkThrow(totalAppsAttached > 0, PLAN_ATTACHED_TO_APPS); planRepository.delete(plan); amqpCacheService.dispatchClean(); }
PlanService { public void delete(Long id) { Plan plan = planRepository.findOne(id); HeimdallException.checkThrow(plan == null, GLOBAL_RESOURCE_NOT_FOUND); Integer totalAppsAttached = planRepository.findAppsWithPlan(id); HeimdallException.checkThrow(totalAppsAttached > 0, PLAN_ATTACHED_TO_APPS); planRepository.delete(plan); amqpCacheService.dispatchClean(); } }
PlanService { public void delete(Long id) { Plan plan = planRepository.findOne(id); HeimdallException.checkThrow(plan == null, GLOBAL_RESOURCE_NOT_FOUND); Integer totalAppsAttached = planRepository.findAppsWithPlan(id); HeimdallException.checkThrow(totalAppsAttached > 0, PLAN_ATTACHED_TO_APPS); planRepository.delete(plan); amqpCacheService.dispatchClean(); }  }
PlanService { public void delete(Long id) { Plan plan = planRepository.findOne(id); HeimdallException.checkThrow(plan == null, GLOBAL_RESOURCE_NOT_FOUND); Integer totalAppsAttached = planRepository.findAppsWithPlan(id); HeimdallException.checkThrow(totalAppsAttached > 0, PLAN_ATTACHED_TO_APPS); planRepository.delete(plan); amqpCacheService.dispatchClean(); }  @Transactional(readOnly = true) Plan find(Long id); @Transactional(readOnly = true) PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Plan> list(PlanDTO planDTO); Plan save(PlanDTO planDTO); Plan update(Long id, PlanDTO planDTO); void delete(Long id); }
PlanService { public void delete(Long id) { Plan plan = planRepository.findOne(id); HeimdallException.checkThrow(plan == null, GLOBAL_RESOURCE_NOT_FOUND); Integer totalAppsAttached = planRepository.findAppsWithPlan(id); HeimdallException.checkThrow(totalAppsAttached > 0, PLAN_ATTACHED_TO_APPS); planRepository.delete(plan); amqpCacheService.dispatchClean(); }  @Transactional(readOnly = true) Plan find(Long id); @Transactional(readOnly = true) PlanPage list(PlanDTO planDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Plan> list(PlanDTO planDTO); Plan save(PlanDTO planDTO); Plan update(Long id, PlanDTO planDTO); void delete(Long id);  }