@Test void linkFolderIsMissing() { PolicyBackedServiceLinker policyBackedServiceLinker = new PolicyBackedServiceLinker(); Map<String, String> operations = new HashMap<>(); operations.put("operation1", "1"); operations.put("operation2", "2"); PolicyBackedService myPolicyBackedService = createPolicyBackedService("myEncass", "1", "PolicyBackedService", operations); Bundle bundle = new Bundle(); bundle.addEntity(myPolicyBackedService); Bundle fullBundle = new Bundle(); fullBundle.addEntity(myPolicyBackedService); fullBundle.addEntity(createPolicy("operation1Policy", "1", "1", "1", null, "")); fullBundle.addEntity(createPolicy("operation2Policy", "2", "2", "1", null, "")); fullBundle.addEntity(createFolder("myFolder", "2", null)); FolderTree folderTree = new FolderTree(fullBundle.getEntities(Folder.class).values()); fullBundle.setFolderTree(folderTree); assertThrows(LinkerException.class, () -> policyBackedServiceLinker.link(bundle, fullBundle)); }
@Override public void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle) { for (PolicyBackedServiceOperation operation : pbs.getOperations()) { String policyId = operation.getPolicy(); Policy policy = bundle.getPolicies().values().stream().filter(p -> policyId.equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Policy Backed Service. Policy ID: " + policyId); } operation.setPolicy(getPolicyPath(policy, bundle, pbs)); } }
PolicyBackedServiceLinker implements EntityLinker<PolicyBackedService> { @Override public void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle) { for (PolicyBackedServiceOperation operation : pbs.getOperations()) { String policyId = operation.getPolicy(); Policy policy = bundle.getPolicies().values().stream().filter(p -> policyId.equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Policy Backed Service. Policy ID: " + policyId); } operation.setPolicy(getPolicyPath(policy, bundle, pbs)); } } }
PolicyBackedServiceLinker implements EntityLinker<PolicyBackedService> { @Override public void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle) { for (PolicyBackedServiceOperation operation : pbs.getOperations()) { String policyId = operation.getPolicy(); Policy policy = bundle.getPolicies().values().stream().filter(p -> policyId.equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Policy Backed Service. Policy ID: " + policyId); } operation.setPolicy(getPolicyPath(policy, bundle, pbs)); } }  }
PolicyBackedServiceLinker implements EntityLinker<PolicyBackedService> { @Override public void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle) { for (PolicyBackedServiceOperation operation : pbs.getOperations()) { String policyId = operation.getPolicy(); Policy policy = bundle.getPolicies().values().stream().filter(p -> policyId.equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Policy Backed Service. Policy ID: " + policyId); } operation.setPolicy(getPolicyPath(policy, bundle, pbs)); } }  @Override Class<PolicyBackedService> getEntityClass(); @Override void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle); }
PolicyBackedServiceLinker implements EntityLinker<PolicyBackedService> { @Override public void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle) { for (PolicyBackedServiceOperation operation : pbs.getOperations()) { String policyId = operation.getPolicy(); Policy policy = bundle.getPolicies().values().stream().filter(p -> policyId.equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Policy Backed Service. Policy ID: " + policyId); } operation.setPolicy(getPolicyPath(policy, bundle, pbs)); } }  @Override Class<PolicyBackedService> getEntityClass(); @Override void link(PolicyBackedService pbs, Bundle bundle, Bundle targetBundle);  }