@Test public void deleteTest() { Mockito.when(middlewareRepository.findByApiIdAndId(Mockito.anyLong(), Mockito.anyLong())).thenReturn(middleware); service.delete(1L, 1L); Mockito.verify(middlewareRepository, Mockito.times(1)).findByApiIdAndId(Mockito.anyLong(), Mockito.anyLong()); }
@Transactional public void delete(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); HeimdallException.checkThrow(middleware.getInterceptors() != null && middleware.getInterceptors().size() > 0, ExceptionMessage.MIDDLEWARE_CONTAINS_INTERCEPTORS); amqpMiddlewareService.dispatchRemoveMiddlewares(middleware.getPath()); middlewareRepository.delete(middleware.getId()); }
MiddlewareService { @Transactional public void delete(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); HeimdallException.checkThrow(middleware.getInterceptors() != null && middleware.getInterceptors().size() > 0, ExceptionMessage.MIDDLEWARE_CONTAINS_INTERCEPTORS); amqpMiddlewareService.dispatchRemoveMiddlewares(middleware.getPath()); middlewareRepository.delete(middleware.getId()); } }
MiddlewareService { @Transactional public void delete(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); HeimdallException.checkThrow(middleware.getInterceptors() != null && middleware.getInterceptors().size() > 0, ExceptionMessage.MIDDLEWARE_CONTAINS_INTERCEPTORS); amqpMiddlewareService.dispatchRemoveMiddlewares(middleware.getPath()); middlewareRepository.delete(middleware.getId()); }  }
MiddlewareService { @Transactional public void delete(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); HeimdallException.checkThrow(middleware.getInterceptors() != null && middleware.getInterceptors().size() > 0, ExceptionMessage.MIDDLEWARE_CONTAINS_INTERCEPTORS); amqpMiddlewareService.dispatchRemoveMiddlewares(middleware.getPath()); middlewareRepository.delete(middleware.getId()); }  @Transactional(readOnly = true) Middleware find(Long apiId, Long middlewareId); @Transactional(readOnly = true) MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Middleware> list(Long apiId, MiddlewareDTO middlewareDTO); @Transactional Middleware save(Long apiId, MiddlewareDTO middlewareDTO, MultipartFile file); @Transactional Middleware update(Long apiId, Long middlewareId, MiddlewareDTO middlewareDTO); @Transactional void delete(Long apiId, Long middlewareId); @Transactional void deleteAll(Long apiId); }
MiddlewareService { @Transactional public void delete(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); HeimdallException.checkThrow(middleware.getInterceptors() != null && middleware.getInterceptors().size() > 0, ExceptionMessage.MIDDLEWARE_CONTAINS_INTERCEPTORS); amqpMiddlewareService.dispatchRemoveMiddlewares(middleware.getPath()); middlewareRepository.delete(middleware.getId()); }  @Transactional(readOnly = true) Middleware find(Long apiId, Long middlewareId); @Transactional(readOnly = true) MiddlewarePage list(Long apiId, MiddlewareDTO middlewareDTO, PageableDTO pageableDTO); @Transactional(readOnly = true) List<Middleware> list(Long apiId, MiddlewareDTO middlewareDTO); @Transactional Middleware save(Long apiId, MiddlewareDTO middlewareDTO, MultipartFile file); @Transactional Middleware update(Long apiId, Long middlewareId, MiddlewareDTO middlewareDTO); @Transactional void delete(Long apiId, Long middlewareId); @Transactional void deleteAll(Long apiId);  }