@Test public void testUpdatePolicy_Throws_PolicyIdNotFoundException() throws UnsupportedEncodingException { thrown.expect(PolicyIdNotFoundException.class); final String policyId = ""; final PolicyContentDto updatePolicyRequestDto = mock(PolicyContentDto.class); sut.updatePolicy(updatePolicyRequestDto, policyId); }
@Override @Transactional public PolicyMetadataDto updatePolicy( PolicyContentDto updatePolicyRequestDto, String policyId) { assertPolicyId(policyId); final PolicyDto policyDto = MappingUtils .toPolicyDto(updatePolicyRequestDto.getPolicy()); assertPolicyIdConsistency(policyId, policyDto.getId()); final Policy policy = policyRepository.findOne(policyId); assertPolicyNotNull(policy, policyId); policy.setPolicy(updatePolicyRequestDto.getPolicy()); policy.setValid(PolicyValidationUtils.validate(updatePolicyRequestDto .getPolicy())); policyRepository.save(policy); final PolicyMetadataDto updatePolicyResponseDto = modelMapper.map( policy, PolicyMetadataDto.class); return updatePolicyResponseDto; }
PolicyServiceImpl implements PolicyService { @Override @Transactional public PolicyMetadataDto updatePolicy( PolicyContentDto updatePolicyRequestDto, String policyId) { assertPolicyId(policyId); final PolicyDto policyDto = MappingUtils .toPolicyDto(updatePolicyRequestDto.getPolicy()); assertPolicyIdConsistency(policyId, policyDto.getId()); final Policy policy = policyRepository.findOne(policyId); assertPolicyNotNull(policy, policyId); policy.setPolicy(updatePolicyRequestDto.getPolicy()); policy.setValid(PolicyValidationUtils.validate(updatePolicyRequestDto .getPolicy())); policyRepository.save(policy); final PolicyMetadataDto updatePolicyResponseDto = modelMapper.map( policy, PolicyMetadataDto.class); return updatePolicyResponseDto; } }
PolicyServiceImpl implements PolicyService { @Override @Transactional public PolicyMetadataDto updatePolicy( PolicyContentDto updatePolicyRequestDto, String policyId) { assertPolicyId(policyId); final PolicyDto policyDto = MappingUtils .toPolicyDto(updatePolicyRequestDto.getPolicy()); assertPolicyIdConsistency(policyId, policyDto.getId()); final Policy policy = policyRepository.findOne(policyId); assertPolicyNotNull(policy, policyId); policy.setPolicy(updatePolicyRequestDto.getPolicy()); policy.setValid(PolicyValidationUtils.validate(updatePolicyRequestDto .getPolicy())); policyRepository.save(policy); final PolicyMetadataDto updatePolicyResponseDto = modelMapper.map( policy, PolicyMetadataDto.class); return updatePolicyResponseDto; }  }
PolicyServiceImpl implements PolicyService { @Override @Transactional public PolicyMetadataDto updatePolicy( PolicyContentDto updatePolicyRequestDto, String policyId) { assertPolicyId(policyId); final PolicyDto policyDto = MappingUtils .toPolicyDto(updatePolicyRequestDto.getPolicy()); assertPolicyIdConsistency(policyId, policyDto.getId()); final Policy policy = policyRepository.findOne(policyId); assertPolicyNotNull(policy, policyId); policy.setPolicy(updatePolicyRequestDto.getPolicy()); policy.setValid(PolicyValidationUtils.validate(updatePolicyRequestDto .getPolicy())); policyRepository.save(policy); final PolicyMetadataDto updatePolicyResponseDto = modelMapper.map( policy, PolicyMetadataDto.class); return updatePolicyResponseDto; }  @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 PolicyMetadataDto updatePolicy( PolicyContentDto updatePolicyRequestDto, String policyId) { assertPolicyId(policyId); final PolicyDto policyDto = MappingUtils .toPolicyDto(updatePolicyRequestDto.getPolicy()); assertPolicyIdConsistency(policyId, policyDto.getId()); final Policy policy = policyRepository.findOne(policyId); assertPolicyNotNull(policy, policyId); policy.setPolicy(updatePolicyRequestDto.getPolicy()); policy.setValid(PolicyValidationUtils.validate(updatePolicyRequestDto .getPolicy())); policyRepository.save(policy); final PolicyMetadataDto updatePolicyResponseDto = modelMapper.map( policy, PolicyMetadataDto.class); return updatePolicyResponseDto; }  @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);  }