@Test
void buildTrustedCertUsingCertData() throws Exception {

    final String EXPECT_ISSUER = "issuer";
    final BigInteger EXPECT_BIG_INT = new BigInteger("1234");
    final String EXPECT_SUB_NAME = "subName";
    final String EXPECT_DATA = "data";
    final TrustedCertEntityBuilder builder = new TrustedCertEntityBuilder(new IdGenerator(), null, certFact);
    final Bundle bundle = new Bundle();
    final CertificateData certData = new CertificateData(EXPECT_ISSUER, EXPECT_BIG_INT, EXPECT_SUB_NAME, EXPECT_DATA);
    final TrustedCert trustedCert = new TrustedCert(ImmutableMap.of(VERIFY_HOSTNAME, true), certData);
    bundle.putAllTrustedCerts(ImmutableMap.of(CERT_NAME, trustedCert));
    final List<Entity> trustedCerts = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument());
    assertEquals(1, trustedCerts.size());
    final Element trustedCertEntityXml = verifyTrustedCertElement(trustedCerts, false);
    verifyProperties(trustedCertEntityXml);
    final Element certDataXml = getSingleElement(trustedCertEntityXml, CERT_DATA);
    assertEquals(EXPECT_ISSUER, getSingleChildElementTextContent(certDataXml, ISSUER_NAME));
    assertEquals(EXPECT_BIG_INT, new BigInteger(getSingleChildElementTextContent(certDataXml, SERIAL_NUMBER)));
    assertEquals(EXPECT_SUB_NAME, getSingleChildElementTextContent(certDataXml, SUBJECT_NAME));
    assertEquals(EXPECT_DATA, getSingleChildElementTextContent(certDataXml, ENCODED));
}