### Question:
X509Bundle implements BundleSource<X509Bundle> { @Override public X509Bundle getBundleForTrustDomain(@NonNull final TrustDomain trustDomain) throws BundleNotFoundException { if (this.trustDomain.equals(trustDomain)) { return this; } throw new BundleNotFoundException(String.format("No X.509 bundle found for trust domain %s", trustDomain)); } X509Bundle(@NonNull final TrustDomain trustDomain);  X509Bundle(@NonNull final TrustDomain trustDomain, @NonNull final Set<X509Certificate> x509Authorities); static X509Bundle load(@NonNull final TrustDomain trustDomain, @NonNull final Path bundlePath); static X509Bundle parse(@NonNull final TrustDomain trustDomain, @NonNull final byte[] bundleBytes); @Override X509Bundle getBundleForTrustDomain(@NonNull final TrustDomain trustDomain); Set<X509Certificate> getX509Authorities(); boolean hasX509Authority(@NonNull final X509Certificate x509Authority); void addX509Authority(@NonNull final X509Certificate x509Authority); void removeX509Authority(@NonNull final X509Certificate x509Authority);  }### Answer:
@Test void testGetBundleForTrustDomain() throws BundleNotFoundException { X509Bundle x509Bundle = new X509Bundle(TrustDomain.of("example.org")); assertEquals(x509Bundle, x509Bundle.getBundleForTrustDomain(TrustDomain.of("example.org"))); }
@Test void testGetBundleForTrustDomain_notBundleFound_throwsBundleNotFoundException() { X509Bundle x509Bundle = new X509Bundle(TrustDomain.of("example.org")); try { x509Bundle.getBundleForTrustDomain(TrustDomain.of("other.org")); } catch (BundleNotFoundException e) { assertEquals("No X.509 bundle found for trust domain other.org", e.getMessage()); } }
@Test void testGetBundleForTrustDomain_nullArgument_throwsNullPointerException() { X509Bundle x509Bundle = new X509Bundle(TrustDomain.of("example.org")); try { x509Bundle.getBundleForTrustDomain(null); fail(); } catch (BundleNotFoundException e) { fail(); } catch (NullPointerException e) { assertEquals("trustDomain is marked non-null but is null", e.getMessage()); } }