@Test public void testGetPolicies() throws Exception { PdpPolicyRepository policyRepository = mock(PdpPolicyRepository.class); PdpPolicyViolationRepository policyViolationRepository = mock(PdpPolicyViolationRepository.class); PerformancePrePolicyLoader subject = new PerformancePrePolicyLoader(0, new ClassPathResourceManage(), policyRepository, policyViolationRepository); List<PdpPolicy> policies = subject.getPolicies(); assertEquals(51, policies.size()); subject.loadPolicies(); verify(policyRepository, times(51)).save(any(PdpPolicy.class)); }
@Override public List<PdpPolicy> getPolicies() { List<EntityMetaData> sps = manage.serviceProviders(); List<EntityMetaData> idps = manage.identityProviders(); EntityMetaData idp = idps.get(idps.size() - 1); int nbr = (this.count == 0 ? sps.size() : this.count); return sps.subList(0, nbr).stream().map(sp -> pdpPolicyDefinition(sp, idp, UUID.randomUUID().toString())) .map(def -> new PdpPolicy(templateEngine.createPolicyXml(def), def.getName(), true, userIdentifier, authenticatingAuthority, userDisplayName, true, "reg")) .collect(toList()); }
PerformancePrePolicyLoader extends DevelopmentPrePolicyLoader { @Override public List<PdpPolicy> getPolicies() { List<EntityMetaData> sps = manage.serviceProviders(); List<EntityMetaData> idps = manage.identityProviders(); EntityMetaData idp = idps.get(idps.size() - 1); int nbr = (this.count == 0 ? sps.size() : this.count); return sps.subList(0, nbr).stream().map(sp -> pdpPolicyDefinition(sp, idp, UUID.randomUUID().toString())) .map(def -> new PdpPolicy(templateEngine.createPolicyXml(def), def.getName(), true, userIdentifier, authenticatingAuthority, userDisplayName, true, "reg")) .collect(toList()); } }
PerformancePrePolicyLoader extends DevelopmentPrePolicyLoader { @Override public List<PdpPolicy> getPolicies() { List<EntityMetaData> sps = manage.serviceProviders(); List<EntityMetaData> idps = manage.identityProviders(); EntityMetaData idp = idps.get(idps.size() - 1); int nbr = (this.count == 0 ? sps.size() : this.count); return sps.subList(0, nbr).stream().map(sp -> pdpPolicyDefinition(sp, idp, UUID.randomUUID().toString())) .map(def -> new PdpPolicy(templateEngine.createPolicyXml(def), def.getName(), true, userIdentifier, authenticatingAuthority, userDisplayName, true, "reg")) .collect(toList()); } PerformancePrePolicyLoader(int count, Manage manage, PdpPolicyRepository pdpPolicyRepository, PdpPolicyViolationRepository pdpPolicyViolationRepository); }
PerformancePrePolicyLoader extends DevelopmentPrePolicyLoader { @Override public List<PdpPolicy> getPolicies() { List<EntityMetaData> sps = manage.serviceProviders(); List<EntityMetaData> idps = manage.identityProviders(); EntityMetaData idp = idps.get(idps.size() - 1); int nbr = (this.count == 0 ? sps.size() : this.count); return sps.subList(0, nbr).stream().map(sp -> pdpPolicyDefinition(sp, idp, UUID.randomUUID().toString())) .map(def -> new PdpPolicy(templateEngine.createPolicyXml(def), def.getName(), true, userIdentifier, authenticatingAuthority, userDisplayName, true, "reg")) .collect(toList()); } PerformancePrePolicyLoader(int count, Manage manage, PdpPolicyRepository pdpPolicyRepository, PdpPolicyViolationRepository pdpPolicyViolationRepository); @Override List<PdpPolicy> getPolicies(); }
PerformancePrePolicyLoader extends DevelopmentPrePolicyLoader { @Override public List<PdpPolicy> getPolicies() { List<EntityMetaData> sps = manage.serviceProviders(); List<EntityMetaData> idps = manage.identityProviders(); EntityMetaData idp = idps.get(idps.size() - 1); int nbr = (this.count == 0 ? sps.size() : this.count); return sps.subList(0, nbr).stream().map(sp -> pdpPolicyDefinition(sp, idp, UUID.randomUUID().toString())) .map(def -> new PdpPolicy(templateEngine.createPolicyXml(def), def.getName(), true, userIdentifier, authenticatingAuthority, userDisplayName, true, "reg")) .collect(toList()); } PerformancePrePolicyLoader(int count, Manage manage, PdpPolicyRepository pdpPolicyRepository, PdpPolicyViolationRepository pdpPolicyViolationRepository); @Override List<PdpPolicy> getPolicies();  }