@Test void loadNoSerialNumber() throws Exception { TrustedCertLoader loader = new TrustedCertLoader(); Bundle bundle = new Bundle(); assertThrows(BundleLoadException.class, () -> loader.load(bundle, buildTrustedCertElement(DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), null))); }
@Override public void load(Bundle bundle, Element element) { final Element trustedCertElem = getSingleChildElement(getSingleChildElement(element, RESOURCE), TRUSTED_CERT); final String name = getSingleChildElementTextContent(trustedCertElem, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(trustedCertElem, PROPERTIES, true), PROPERTIES); TrustedCert cert = new TrustedCert(properties, getCertData(trustedCertElem)); cert.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); cert.setName(getSingleChildElementTextContent(trustedCertElem, NAME)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cert.setAnnotations(annotations); bundle.getTrustedCerts().put(name, cert); }
TrustedCertLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element trustedCertElem = getSingleChildElement(getSingleChildElement(element, RESOURCE), TRUSTED_CERT); final String name = getSingleChildElementTextContent(trustedCertElem, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(trustedCertElem, PROPERTIES, true), PROPERTIES); TrustedCert cert = new TrustedCert(properties, getCertData(trustedCertElem)); cert.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); cert.setName(getSingleChildElementTextContent(trustedCertElem, NAME)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cert.setAnnotations(annotations); bundle.getTrustedCerts().put(name, cert); } }
TrustedCertLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element trustedCertElem = getSingleChildElement(getSingleChildElement(element, RESOURCE), TRUSTED_CERT); final String name = getSingleChildElementTextContent(trustedCertElem, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(trustedCertElem, PROPERTIES, true), PROPERTIES); TrustedCert cert = new TrustedCert(properties, getCertData(trustedCertElem)); cert.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); cert.setName(getSingleChildElementTextContent(trustedCertElem, NAME)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cert.setAnnotations(annotations); bundle.getTrustedCerts().put(name, cert); }  }
TrustedCertLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element trustedCertElem = getSingleChildElement(getSingleChildElement(element, RESOURCE), TRUSTED_CERT); final String name = getSingleChildElementTextContent(trustedCertElem, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(trustedCertElem, PROPERTIES, true), PROPERTIES); TrustedCert cert = new TrustedCert(properties, getCertData(trustedCertElem)); cert.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); cert.setName(getSingleChildElementTextContent(trustedCertElem, NAME)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cert.setAnnotations(annotations); bundle.getTrustedCerts().put(name, cert); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType(); }
TrustedCertLoader implements BundleEntityLoader { @Override public void load(Bundle bundle, Element element) { final Element trustedCertElem = getSingleChildElement(getSingleChildElement(element, RESOURCE), TRUSTED_CERT); final String name = getSingleChildElementTextContent(trustedCertElem, NAME); final Map<String, Object> properties = mapPropertiesElements(getSingleChildElement(trustedCertElem, PROPERTIES, true), PROPERTIES); TrustedCert cert = new TrustedCert(properties, getCertData(trustedCertElem)); cert.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); cert.setName(getSingleChildElementTextContent(trustedCertElem, NAME)); Set<Annotation> annotations = new HashSet<>(); Annotation bundleEntity = new Annotation(AnnotationType.BUNDLE_HINTS); bundleEntity.setId(trustedCertElem.getAttribute(ATTRIBUTE_ID)); annotations.add(bundleEntity); cert.setAnnotations(annotations); bundle.getTrustedCerts().put(name, cert); }  @Override void load(Bundle bundle, Element element); @Override String getEntityType();  }