@Test(expected = RuntimeException.class) public void pathDoesNotExists() throws Exception { subject = new PolicyProvisioner("does-not-exists", pdpPolicyRepository); subject.onApplicationEvent(null); }
@Override public void onApplicationEvent(ContextStartedEvent contextStartedEvent) { policyDefinitions() .filter(definition -> !pdpPolicyRepository.findByNameAndLatestRevision(definition.getName(), true).isPresent()) .forEach(definition -> { String policyXml = policyTemplateEngine.createPolicyXml(definition); PdpPolicy pdpPolicy = new PdpPolicy(policyXml, definition.getName(), true, "provisioned", "surfnet", "system", true, definition.getType()); pdpPolicyRepository.save(pdpPolicy); }); }
PolicyProvisioner implements ApplicationListener<ContextStartedEvent>, JsonMapper { @Override public void onApplicationEvent(ContextStartedEvent contextStartedEvent) { policyDefinitions() .filter(definition -> !pdpPolicyRepository.findByNameAndLatestRevision(definition.getName(), true).isPresent()) .forEach(definition -> { String policyXml = policyTemplateEngine.createPolicyXml(definition); PdpPolicy pdpPolicy = new PdpPolicy(policyXml, definition.getName(), true, "provisioned", "surfnet", "system", true, definition.getType()); pdpPolicyRepository.save(pdpPolicy); }); } }
PolicyProvisioner implements ApplicationListener<ContextStartedEvent>, JsonMapper { @Override public void onApplicationEvent(ContextStartedEvent contextStartedEvent) { policyDefinitions() .filter(definition -> !pdpPolicyRepository.findByNameAndLatestRevision(definition.getName(), true).isPresent()) .forEach(definition -> { String policyXml = policyTemplateEngine.createPolicyXml(definition); PdpPolicy pdpPolicy = new PdpPolicy(policyXml, definition.getName(), true, "provisioned", "surfnet", "system", true, definition.getType()); pdpPolicyRepository.save(pdpPolicy); }); } @Autowired  PolicyProvisioner(@Value("${provision.policies.directory}") String path, PdpPolicyRepository pdpPolicyRepository); }
PolicyProvisioner implements ApplicationListener<ContextStartedEvent>, JsonMapper { @Override public void onApplicationEvent(ContextStartedEvent contextStartedEvent) { policyDefinitions() .filter(definition -> !pdpPolicyRepository.findByNameAndLatestRevision(definition.getName(), true).isPresent()) .forEach(definition -> { String policyXml = policyTemplateEngine.createPolicyXml(definition); PdpPolicy pdpPolicy = new PdpPolicy(policyXml, definition.getName(), true, "provisioned", "surfnet", "system", true, definition.getType()); pdpPolicyRepository.save(pdpPolicy); }); } @Autowired  PolicyProvisioner(@Value("${provision.policies.directory}") String path, PdpPolicyRepository pdpPolicyRepository); @Override void onApplicationEvent(ContextStartedEvent contextStartedEvent); }
PolicyProvisioner implements ApplicationListener<ContextStartedEvent>, JsonMapper { @Override public void onApplicationEvent(ContextStartedEvent contextStartedEvent) { policyDefinitions() .filter(definition -> !pdpPolicyRepository.findByNameAndLatestRevision(definition.getName(), true).isPresent()) .forEach(definition -> { String policyXml = policyTemplateEngine.createPolicyXml(definition); PdpPolicy pdpPolicy = new PdpPolicy(policyXml, definition.getName(), true, "provisioned", "surfnet", "system", true, definition.getType()); pdpPolicyRepository.save(pdpPolicy); }); } @Autowired  PolicyProvisioner(@Value("${provision.policies.directory}") String path, PdpPolicyRepository pdpPolicyRepository); @Override void onApplicationEvent(ContextStartedEvent contextStartedEvent);  }