@Test
  public void testDefaultCascadePersist() {
    Default defaults = new Default();
    defaults.setCascadePersist(true);
    Index index = getIndex();
    Map<DotName, List<AnnotationInstance>> annotations =
        new HashMap<DotName, List<AnnotationInstance>>();
    annotations.putAll(
        index.getClassByName(DotName.createSimple(Parent.class.getName())).annotations());
    assertEquals(4, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.ENTITY).size());
    assertEquals(1, annotations.get(JPADotNames.ID).size());
    assertEquals(1, annotations.get(JPADotNames.ONE_TO_MANY).size());
    assertEquals(1, annotations.get(JPADotNames.MANY_TO_ONE).size());

    DefaultConfigurationHelper.INSTANCE.applyDefaults(annotations, defaults);

    assertEquals(4, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.ENTITY).size());
    assertEquals(1, annotations.get(JPADotNames.ID).size());
    assertEquals(1, annotations.get(JPADotNames.ONE_TO_MANY).size());
    assertEquals(1, annotations.get(JPADotNames.MANY_TO_ONE).size());
    AnnotationInstance oneToMany = annotations.get(JPADotNames.ONE_TO_MANY).get(0);
    String[] cascadeTypes = oneToMany.value("cascade").asEnumArray();
    assertArrayEquals(new String[] {"ALL", "DETACH", "PERSIST"}, cascadeTypes);
    AnnotationInstance manyToOne = annotations.get(JPADotNames.MANY_TO_ONE).get(0);
    cascadeTypes = manyToOne.value("cascade").asEnumArray();
    assertArrayEquals(new String[] {"PERSIST"}, cascadeTypes);

    annotations.clear();
    annotations.putAll(
        index.getClassByName(DotName.createSimple(Child.class.getName())).annotations());
    assertEquals(3, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.ENTITY).size());
    assertEquals(1, annotations.get(JPADotNames.ID).size());
    assertEquals(1, annotations.get(JPADotNames.MANY_TO_ONE).size());

    DefaultConfigurationHelper.INSTANCE.applyDefaults(annotations, defaults);

    assertEquals(3, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.ENTITY).size());
    assertEquals(1, annotations.get(JPADotNames.ID).size());
    assertEquals(1, annotations.get(JPADotNames.MANY_TO_ONE).size());

    manyToOne = annotations.get(JPADotNames.MANY_TO_ONE).get(0);
    cascadeTypes = manyToOne.value("cascade").asEnumArray();
    assertArrayEquals(new String[] {"PERSIST", "ALL", "DETACH"}, cascadeTypes);
  }
 @Test
 public void applyNullDefaultToEntity() {
   JaxbEntity entity = new JaxbEntity();
   entity.setClazz("Entity");
   DefaultConfigurationHelper.INSTANCE.applyDefaults(entity, null);
   assertNull(entity.getTable());
   assertEquals("Entity", entity.getClazz());
 }
  @Test
  public void testDefaultSchemaToAnnotationInstance() {
    Default defaults = new Default();
    defaults.setSchema("hib_schema");
    defaults.setCatalog("hib_catalog");
    Index index = getIndex();
    Map<DotName, List<AnnotationInstance>> annotations =
        new HashMap<DotName, List<AnnotationInstance>>();
    annotations.putAll(
        index.getClassByName(DotName.createSimple(Parent.class.getName())).annotations());
    assertEquals(4, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.ENTITY).size());
    assertEquals(1, annotations.get(JPADotNames.ID).size());
    assertEquals(1, annotations.get(JPADotNames.ONE_TO_MANY).size());
    assertEquals(1, annotations.get(JPADotNames.MANY_TO_ONE).size());
    DefaultConfigurationHelper.INSTANCE.applyDefaults(annotations, defaults);
    assertEquals(5, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.ENTITY).size());
    assertEquals(1, annotations.get(JPADotNames.ID).size());
    assertEquals(1, annotations.get(JPADotNames.ONE_TO_MANY).size());
    assertEquals(1, annotations.get(JPADotNames.MANY_TO_ONE).size());
    assertEquals(1, annotations.get(JPADotNames.TABLE).size());
    AnnotationInstance table = annotations.get(JPADotNames.TABLE).get(0);
    assertEquals("hib_schema", table.value("schema").asString());
    assertEquals("hib_catalog", table.value("catalog").asString());

    annotations.clear();
    annotations.putAll(
        index.getClassByName(DotName.createSimple(Name.class.getName())).annotations());
    DefaultConfigurationHelper.INSTANCE.applyDefaults(annotations, defaults);
    assertEquals(1, annotations.size());
    assertEquals(1, annotations.get(JPADotNames.SECONDARY_TABLES).size());
    AnnotationInstance[] secondaryTables =
        annotations.get(JPADotNames.SECONDARY_TABLES).get(0).value().asNestedArray();
    assertEquals(2, secondaryTables.length);
    AnnotationInstance secondaryTable = secondaryTables[0];
    String name = secondaryTable.value("name").asString();
    if (name.equals("sec1")) {
      assertSt1(secondaryTable);
      assertSt2(secondaryTables[1]);
    } else {
      assertSt1(secondaryTables[1]);
      assertSt2(secondaryTable);
    }
  }
 @Test
 public void applyDefaultToEntity() {
   Default defaults = new Default();
   defaults.setPackageName("org.test");
   defaults.setSchema("schema");
   defaults.setMetadataComplete(true);
   JaxbEntity entity = new JaxbEntity();
   entity.setClazz("Entity");
   DefaultConfigurationHelper.INSTANCE.applyDefaults(entity, defaults);
   assertNotNull(entity.getTable());
   assertNull(entity.getTable().getSchema());
   assertNull(entity.getTable().getCatalog());
   assertTrue(entity.isMetadataComplete());
   assertEquals("org.test.Entity", entity.getClazz());
   DefaultConfigurationHelper.INSTANCE.applyDefaults(entity.getTable(), defaults);
   assertEquals("schema", entity.getTable().getSchema());
   assertNull(entity.getTable().getCatalog());
 }