@Test public void testAddPolicies_Throws_ConflictingRequestException() throws UnsupportedEncodingException { thrown.expect(ConflictingRequestException.class); final PolicyContentDto addPolicyRequestDto = new PolicyContentDto(); addPolicyRequestDto.setPolicy(POLICY_STRING1.getBytes("UTF-8")); final PolicyContentContainerDto addPolicyRequestContainerDto = new PolicyContentContainerDto( addPolicyRequestDto, addPolicyRequestDto); sut.addPolicies(addPolicyRequestContainerDto, false); }
@Override @Transactional public PolicyMetadataContainerDto addPolicies( PolicyContentContainerDto policyContentContainerDto, boolean force) { final List<PolicyDto> requestPolicyDtos = policyContentContainerDto .getPolicies().stream().map(MappingUtils::toPolicyDto) .collect(toList()); assertUniqueIds(requestPolicyDtos); if (force == false) { assertNotExistsInPolicyRepository(requestPolicyDtos, policyRepository::findOne); } final List<Policy> policies = requestPolicyDtos.stream() .map(PolicyValidationUtils::validateAndReturn) .map(policyDto -> modelMapper.map(policyDto, Policy.class)) .collect(toList()); final List<PolicyMetadataDto> responsePolicyDtos = policies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); policyRepository.save(policies); return new PolicyMetadataContainerDto(responsePolicyDtos); }
PolicyServiceImpl implements PolicyService { @Override @Transactional public PolicyMetadataContainerDto addPolicies( PolicyContentContainerDto policyContentContainerDto, boolean force) { final List<PolicyDto> requestPolicyDtos = policyContentContainerDto .getPolicies().stream().map(MappingUtils::toPolicyDto) .collect(toList()); assertUniqueIds(requestPolicyDtos); if (force == false) { assertNotExistsInPolicyRepository(requestPolicyDtos, policyRepository::findOne); } final List<Policy> policies = requestPolicyDtos.stream() .map(PolicyValidationUtils::validateAndReturn) .map(policyDto -> modelMapper.map(policyDto, Policy.class)) .collect(toList()); final List<PolicyMetadataDto> responsePolicyDtos = policies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); policyRepository.save(policies); return new PolicyMetadataContainerDto(responsePolicyDtos); } }
PolicyServiceImpl implements PolicyService { @Override @Transactional public PolicyMetadataContainerDto addPolicies( PolicyContentContainerDto policyContentContainerDto, boolean force) { final List<PolicyDto> requestPolicyDtos = policyContentContainerDto .getPolicies().stream().map(MappingUtils::toPolicyDto) .collect(toList()); assertUniqueIds(requestPolicyDtos); if (force == false) { assertNotExistsInPolicyRepository(requestPolicyDtos, policyRepository::findOne); } final List<Policy> policies = requestPolicyDtos.stream() .map(PolicyValidationUtils::validateAndReturn) .map(policyDto -> modelMapper.map(policyDto, Policy.class)) .collect(toList()); final List<PolicyMetadataDto> responsePolicyDtos = policies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); policyRepository.save(policies); return new PolicyMetadataContainerDto(responsePolicyDtos); }  }
PolicyServiceImpl implements PolicyService { @Override @Transactional public PolicyMetadataContainerDto addPolicies( PolicyContentContainerDto policyContentContainerDto, boolean force) { final List<PolicyDto> requestPolicyDtos = policyContentContainerDto .getPolicies().stream().map(MappingUtils::toPolicyDto) .collect(toList()); assertUniqueIds(requestPolicyDtos); if (force == false) { assertNotExistsInPolicyRepository(requestPolicyDtos, policyRepository::findOne); } final List<Policy> policies = requestPolicyDtos.stream() .map(PolicyValidationUtils::validateAndReturn) .map(policyDto -> modelMapper.map(policyDto, Policy.class)) .collect(toList()); final List<PolicyMetadataDto> responsePolicyDtos = policies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); policyRepository.save(policies); return new PolicyMetadataContainerDto(responsePolicyDtos); }  @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 PolicyMetadataContainerDto addPolicies( PolicyContentContainerDto policyContentContainerDto, boolean force) { final List<PolicyDto> requestPolicyDtos = policyContentContainerDto .getPolicies().stream().map(MappingUtils::toPolicyDto) .collect(toList()); assertUniqueIds(requestPolicyDtos); if (force == false) { assertNotExistsInPolicyRepository(requestPolicyDtos, policyRepository::findOne); } final List<Policy> policies = requestPolicyDtos.stream() .map(PolicyValidationUtils::validateAndReturn) .map(policyDto -> modelMapper.map(policyDto, Policy.class)) .collect(toList()); final List<PolicyMetadataDto> responsePolicyDtos = policies .stream() .map(policy -> modelMapper.map(policy, PolicyMetadataDto.class)) .collect(toList()); policyRepository.save(policies); return new PolicyMetadataContainerDto(responsePolicyDtos); }  @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);  }