OperationService { @Transactional public void delete(Long apiId, Long resourceId, Long operationId) { Operation operation = operationRepository.findByResourceApiIdAndResourceIdAndId(apiId, resourceId, operationId); HeimdallException.checkThrow(operation == null, GLOBAL_RESOURCE_NOT_FOUND); interceptorService.deleteAllfromOperation(operationId); operationRepository.delete(operation.getId()); amqpCacheService.dispatchClean(ConstantsCache.OPERATION_ACTIVE_FROM_ENDPOINT, operation.getResource().getApi().getBasePath() + operation.getPath()); amqpRoute.dispatchRoutes(); }  @Transactional(readOnly = true) Operation find(Long apiId, Long resourceId, Long operationId); @Transactional(readOnly = true) OperationPage list(Long apiId, Long resourceId, OperationDTO operationDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Operation> list(Long apiId, Long resourceId, OperationDTO operationDTO); @Transactional(readOnly = true) List<Operation> list(final Long apiId); @Transactional Operation save(Long apiId, Long resourceId, Operation operation); @Transactional Operation update(Long apiId, Long resourceId, Long operationId, OperationDTO operationDTO); @Transactional void delete(Long apiId, Long resourceId, Long operationId); @Transactional void deleteAllfromResource(Long apiId, Long resourceId);  }
@Test public void deleteOperation() { Mockito.when(operationRepository .findByResourceApiIdAndResourceIdAndId(Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong() )).thenReturn(operation); Mockito.when(operationRepository.findOne(Mockito.anyLong())).thenReturn(operation); List<Interceptor> interceptors = new ArrayList<>(); Mockito.when(interceptorRepository.findByOperationId(Mockito.anyLong())).thenReturn(interceptors); this.operationService.delete(1L, 1L, 1L); Mockito.verify(this.operationRepository, Mockito.times(1)).delete(operation.getId()); }