@Test public void testDeletePolicy_Throws_PolicyNotFoundException() { final String policyId = "policyId"; doThrow(EmptyResultDataAccessException.class).when(policyRepository) .delete(policyId); thrown.expect(PolicyNotFoundException.class); sut.deletePolicy(policyId); }
@Override @Transactional public void deletePolicy(String policyId) { assertPolicyId(policyId); try { policyRepository.delete(policyId); } catch (final EmptyResultDataAccessException e) { final StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append( "Policy/PolicySet cannot be found with given ID: ").append( policyId); throw new PolicyNotFoundException(errorBuilder.toString()); } }
PolicyServiceImpl implements PolicyService { @Override @Transactional public void deletePolicy(String policyId) { assertPolicyId(policyId); try { policyRepository.delete(policyId); } catch (final EmptyResultDataAccessException e) { final StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append( "Policy/PolicySet cannot be found with given ID: ").append( policyId); throw new PolicyNotFoundException(errorBuilder.toString()); } } }
PolicyServiceImpl implements PolicyService { @Override @Transactional public void deletePolicy(String policyId) { assertPolicyId(policyId); try { policyRepository.delete(policyId); } catch (final EmptyResultDataAccessException e) { final StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append( "Policy/PolicySet cannot be found with given ID: ").append( policyId); throw new PolicyNotFoundException(errorBuilder.toString()); } }  }
PolicyServiceImpl implements PolicyService { @Override @Transactional public void deletePolicy(String policyId) { assertPolicyId(policyId); try { policyRepository.delete(policyId); } catch (final EmptyResultDataAccessException e) { final StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append( "Policy/PolicySet cannot be found with given ID: ").append( policyId); throw new PolicyNotFoundException(errorBuilder.toString()); } }  @Override @Transactional PolicyMetadataContainerDto addPolicies(
			PolicyContentContainerDto policyContentContainerDto, boolean force); @Override @Transactional void deletePolicy(String policyId); @Override @Transactional(readOnly = true) PolicyMetadataContainerDto getAllPolicyMetadata(); @Override @Transactional(readOnly = true) PolicyContainerDto getPolicies(String policyId, String wildcard); @Override @Transactional(readOnly = true) PolicyDto getPoliciesCombinedAsPolicySet(String policyId,
			String wildcard, String policySetId, String policyCombiningAlgId); @Override Map<String, String> getPolicyCombiningAlgIds(); @Override @Transactional PolicyMetadataDto updatePolicy(
			PolicyContentDto updatePolicyRequestDto, String policyId); }
PolicyServiceImpl implements PolicyService { @Override @Transactional public void deletePolicy(String policyId) { assertPolicyId(policyId); try { policyRepository.delete(policyId); } catch (final EmptyResultDataAccessException e) { final StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append( "Policy/PolicySet cannot be found with given ID: ").append( policyId); throw new PolicyNotFoundException(errorBuilder.toString()); } }  @Override @Transactional PolicyMetadataContainerDto addPolicies(
			PolicyContentContainerDto policyContentContainerDto, boolean force); @Override @Transactional void deletePolicy(String policyId); @Override @Transactional(readOnly = true) PolicyMetadataContainerDto getAllPolicyMetadata(); @Override @Transactional(readOnly = true) PolicyContainerDto getPolicies(String policyId, String wildcard); @Override @Transactional(readOnly = true) PolicyDto getPoliciesCombinedAsPolicySet(String policyId,
			String wildcard, String policySetId, String policyCombiningAlgId); @Override Map<String, String> getPolicyCombiningAlgIds(); @Override @Transactional PolicyMetadataDto updatePolicy(
			PolicyContentDto updatePolicyRequestDto, String policyId);  }