PolicyBackedServiceLoader implements BundleEntityLoader { @Override public void load(final Bundle bundle, Element element) { final Element policyBackedService = getSingleChildElement(getSingleChildElement(element, RESOURCE), POLICY_BACKED_SERVICE); Element nameElement = getSingleChildElement(policyBackedService, NAME); final String name = nameElement.getTextContent(); Element interfaceNameElement = getSingleChildElement(policyBackedService, INTERFACE_NAME); final String interfaceName = interfaceNameElement.getTextContent(); PolicyBackedService pbs = new PolicyBackedService(); pbs.setId(policyBackedService.getAttribute(ATTRIBUTE_ID)); pbs.setName(name); pbs.setInterfaceName(interfaceName); pbs.setOperations(buildOperations(policyBackedService)); bundle.getPolicyBackedServices().put(name, pbs); }  @Override void load(final Bundle bundle, Element element); @Override String getEntityType();  }
@Test void load() { PolicyBackedServiceLoader loader = new PolicyBackedServiceLoader(); Bundle bundle = new Bundle(); loader.load(bundle, createXml( DocumentTools.INSTANCE.getDocumentBuilder().newDocument() )); assertFalse(bundle.getPolicyBackedServices().isEmpty()); assertEquals(1, bundle.getPolicyBackedServices().size()); PolicyBackedService policyBackedService = bundle.getPolicyBackedServices().get("service"); assertNotNull(policyBackedService); assertEquals("service", policyBackedService.getName()); assertEquals("interface", policyBackedService.getInterfaceName()); assertEquals("id", policyBackedService.getId()); assertFalse(policyBackedService.getOperations().isEmpty()); assertEquals(1, policyBackedService.getOperations().size()); PolicyBackedServiceOperation operation = policyBackedService.getOperations().iterator().next(); assertEquals("operation", operation.getOperationName()); assertEquals("policy", operation.getPolicy()); }