RBACDecorator implements RBACDecoratorMBean { static List<String> iterateDownPids(List<String> segments) { List<String> res = new ArrayList<>(); for (int i = segments.size(); i > 0; i--) { StringBuilder sb = new StringBuilder(); sb.append(JMX_ACL_PID_PREFIX); for (int j = 0; j < i; j++) { sb.append('.'); sb.append(segments.get(j)); } res.add(sb.toString()); } res.add(JMX_ACL_PID_PREFIX); return res; } RBACDecorator(BundleContext bundleContext); @Override @SuppressWarnings("unchecked") void decorate(Map<String, Object> result); @Override boolean getVerify(); @Override void setVerify(boolean verify); static Logger LOG; }
@Test public void iteratingDownPids() { assertThat(RBACDecorator.iterateDownPids(Arrays.asList("a.b", "c", "d")).toArray(new String[4]), equalTo(new String[]{"jmx.acl.a.b.c.d", "jmx.acl.a.b.c", "jmx.acl.a.b", "jmx.acl"})); }