GenericEntityLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element genericEntityEle = getSingleChildElement(getSingleChildElement(element, RESOURCE), GENERIC_ENTITY); final String name = getSingleChildElementTextContent(genericEntityEle, NAME); final String description = getSingleChildElementTextContent(genericEntityEle, DESCRIPTION); final String entityClassName = getSingleChildElementTextContent(genericEntityEle, ENTITY_CLASS_NAME); final String valueXml = getSingleChildElementTextContent(genericEntityEle, VALUE_XML); GenericEntity genericEntity = new GenericEntity(); genericEntity.setId(genericEntityEle.getAttribute(ATTRIBUTE_ID)); genericEntity.setName(name); genericEntity.setDescription(description); genericEntity.setEntityClassName(entityClassName); genericEntity.setValueXml(valueXml); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(genericEntityEle.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); genericEntity.setAnnotations(annotations); bundle.getGenericEntities().put(name, genericEntity); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType();  }
@Test public void testHttp2GenericEntity() throws DocumentParseException { GenericEntityLoader loader = new GenericEntityLoader(); Bundle bundle = new Bundle(); Document document = DocumentTools.INSTANCE.parse(HTTP2_CLIENT_CONFIG); loader.load(bundle, document.getDocumentElement()); GenericEntity genericEntity = bundle.getGenericEntities().get("default"); assertEquals("com.l7tech.external.assertions.http2.routing.model.Http2ClientConfigurationEntity", genericEntity.getEntityClassName()); assertNotNull(genericEntity.getValueXml()); assertThat(genericEntity.getValueXml(), containsString("<void property=\"tlsVersion\">")); assertThat(genericEntity.getValueXml(), containsString("<void property=\"readTimeout\">")); assertTrue(genericEntity.getAnnotations().contains(new Annotation(AnnotationType.BUNDLE_HINTS))); }