@Test public void findNotFoundTest() { thrown.expect(NotFoundException.class); thrown.expectMessage("Resource not found"); Mockito.when(middlewareRepository.findByApiIdAndId(Mockito.anyLong(), Mockito.anyLong())).thenReturn(null); Middleware middleware = service.find(1L, 1L); assertEquals(m1, middleware); }
@Transactional(readOnly = true) public Middleware find(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); return middleware; }
MiddlewareService { @Transactional(readOnly = true) public Middleware find(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); return middleware; } }
MiddlewareService { @Transactional(readOnly = true) public Middleware find(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); return middleware; }  }
MiddlewareService { @Transactional(readOnly = true) public Middleware find(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); return middleware; }  @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(readOnly = true) public Middleware find(Long apiId, Long middlewareId) { Middleware middleware = middlewareRepository.findByApiIdAndId(apiId, middlewareId); HeimdallException.checkThrow(middleware == null, GLOBAL_RESOURCE_NOT_FOUND); return middleware; }  @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);  }