@Test public void testGetAllPolicyMetadata_Throws_PolicyNotFoundException() throws UnsupportedEncodingException { thrown.expect(PolicyNotFoundException.class); final List<Policy> policyList = new ArrayList<Policy>(); when(policyRepository.findAll()).thenReturn(policyList); sut.getAllPolicyMetadata(); }
@Override @Transactional(readOnly = true) public PolicyMetadataContainerDto getAllPolicyMetadata() { final List<Policy> allPolicies = policyRepository.findAll(); if (allPolicies == null || allPolicies.size() == 0) { throw new PolicyNotFoundException( "There are no policies in this policy repository."); } final List<PolicyMetadataDto> policyMetadataDtos = allPolicies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); return new PolicyMetadataContainerDto(policyMetadataDtos); }
PolicyServiceImpl implements PolicyService { @Override @Transactional(readOnly = true) public PolicyMetadataContainerDto getAllPolicyMetadata() { final List<Policy> allPolicies = policyRepository.findAll(); if (allPolicies == null || allPolicies.size() == 0) { throw new PolicyNotFoundException( "There are no policies in this policy repository."); } final List<PolicyMetadataDto> policyMetadataDtos = allPolicies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); return new PolicyMetadataContainerDto(policyMetadataDtos); } }
PolicyServiceImpl implements PolicyService { @Override @Transactional(readOnly = true) public PolicyMetadataContainerDto getAllPolicyMetadata() { final List<Policy> allPolicies = policyRepository.findAll(); if (allPolicies == null || allPolicies.size() == 0) { throw new PolicyNotFoundException( "There are no policies in this policy repository."); } final List<PolicyMetadataDto> policyMetadataDtos = allPolicies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); return new PolicyMetadataContainerDto(policyMetadataDtos); }  }
PolicyServiceImpl implements PolicyService { @Override @Transactional(readOnly = true) public PolicyMetadataContainerDto getAllPolicyMetadata() { final List<Policy> allPolicies = policyRepository.findAll(); if (allPolicies == null || allPolicies.size() == 0) { throw new PolicyNotFoundException( "There are no policies in this policy repository."); } final List<PolicyMetadataDto> policyMetadataDtos = allPolicies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); return new PolicyMetadataContainerDto(policyMetadataDtos); }  @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(readOnly = true) public PolicyMetadataContainerDto getAllPolicyMetadata() { final List<Policy> allPolicies = policyRepository.findAll(); if (allPolicies == null || allPolicies.size() == 0) { throw new PolicyNotFoundException( "There are no policies in this policy repository."); } final List<PolicyMetadataDto> policyMetadataDtos = allPolicies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); return new PolicyMetadataContainerDto(policyMetadataDtos); }  @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);  }