@Test void linkMissingPolicy() { Bundle fullBundle = new Bundle(); fullBundle.addEntity(mySTask); fullBundle.addEntity(createFolder("folder", "1", null)); FolderTree folderTree = new FolderTree(fullBundle.getEntities(Folder.class).values()); fullBundle.setFolderTree(folderTree); assertThrows(LinkerException.class, () -> scheduledTaskLinker.link(bundle, fullBundle)); }
@Override public void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle) { Policy policy = bundle.getPolicies().values().stream().filter(p -> scheduledTaskEntity.getPolicy().equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Scheduled Task: " + scheduledTaskEntity.getName() + ". Policy ID: " + scheduledTaskEntity.getPolicy()); } scheduledTaskEntity.setPolicy(getPolicyPath(policy, bundle, scheduledTaskEntity)); }
ScheduledTaskLinker implements EntityLinker<ScheduledTask> { @Override public void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle) { Policy policy = bundle.getPolicies().values().stream().filter(p -> scheduledTaskEntity.getPolicy().equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Scheduled Task: " + scheduledTaskEntity.getName() + ". Policy ID: " + scheduledTaskEntity.getPolicy()); } scheduledTaskEntity.setPolicy(getPolicyPath(policy, bundle, scheduledTaskEntity)); } }
ScheduledTaskLinker implements EntityLinker<ScheduledTask> { @Override public void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle) { Policy policy = bundle.getPolicies().values().stream().filter(p -> scheduledTaskEntity.getPolicy().equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Scheduled Task: " + scheduledTaskEntity.getName() + ". Policy ID: " + scheduledTaskEntity.getPolicy()); } scheduledTaskEntity.setPolicy(getPolicyPath(policy, bundle, scheduledTaskEntity)); }  }
ScheduledTaskLinker implements EntityLinker<ScheduledTask> { @Override public void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle) { Policy policy = bundle.getPolicies().values().stream().filter(p -> scheduledTaskEntity.getPolicy().equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Scheduled Task: " + scheduledTaskEntity.getName() + ". Policy ID: " + scheduledTaskEntity.getPolicy()); } scheduledTaskEntity.setPolicy(getPolicyPath(policy, bundle, scheduledTaskEntity)); }  @Override Class<ScheduledTask> getEntityClass(); @Override void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle); }
ScheduledTaskLinker implements EntityLinker<ScheduledTask> { @Override public void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle) { Policy policy = bundle.getPolicies().values().stream().filter(p -> scheduledTaskEntity.getPolicy().equals(p.getId())).findFirst().orElse(null); if (policy == null) { throw new LinkerException("Could not find policy for Scheduled Task: " + scheduledTaskEntity.getName() + ". Policy ID: " + scheduledTaskEntity.getPolicy()); } scheduledTaskEntity.setPolicy(getPolicyPath(policy, bundle, scheduledTaskEntity)); }  @Override Class<ScheduledTask> getEntityClass(); @Override void link(ScheduledTask scheduledTaskEntity, Bundle bundle, Bundle targetBundle);  }