AccessTokenService { @Transactional(readOnly = true) public AccessToken find(Long id) { AccessToken accessToken = accessTokenRepository.findOne(id); HeimdallException.checkThrow(accessToken == null, GLOBAL_RESOURCE_NOT_FOUND); return accessToken; }  @Transactional(readOnly = true) AccessToken find(Long id); @Transactional(readOnly = true) AccessTokenPage list(AccessTokenRequest accessTokenRequest, PageableDTO pageableDTO); @Transactional(readOnly = true) List<AccessToken> list(AccessTokenRequest accessTokenRequest); @Transactional AccessToken save(AccessTokenPersist accessTokenPersist); @Transactional AccessToken update(Long id, AccessTokenPersist accessTokenPersist); @Transactional void delete(Long id); @Transactional AccessToken save(AccessTokenDTO reqBody);  }
@Test public void findAccessTokenTest() { AccessToken recoverAt = new AccessToken(); recoverAt.setCode("123456"); Mockito.when(this.accessTokenRepository.findOne(Mockito.any(Long.class))).thenReturn(recoverAt); AccessToken accessTokenResp = service.find(1L); assertEquals(accessTokenResp.getId(), recoverAt.getId()); Mockito.verify(this.accessTokenRepository, Mockito.times(1)).findOne(Mockito.any(Long.class)); }