@Test(expected = HibernateException.class)
 public void testAddingNonExistingPackageName() {
   MetadataSources sources =
       new MetadataSources(new ServiceRegistryBuilder().buildServiceRegistry());
   sources.addPackage("not.a.package");
   sources.buildMetadata();
 }
 @Test(expected = IllegalArgumentException.class)
 public void testAddingNullPackageName() {
   MetadataSources sources =
       new MetadataSources(new ServiceRegistryBuilder().buildServiceRegistry());
   sources.addPackage(null);
   sources.buildMetadata();
 }
  @Test
  public void testAddingPackageNameWithTrailingDot() {
    MetadataSources sources =
        new MetadataSources(new ServiceRegistryBuilder().buildServiceRegistry());
    sources.addPackage("org.hibernate.metamodel.source.internal.");
    MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();

    assertFetchProfile(metadata);
  }