public void testVirtualMappingMetadataCompleteFalse() throws Exception {
    createTestEntityOneToOneMapping();
    createTestTargetEntityAddress();

    OrmPersistentType ormPersistentType =
        getEntityMappings()
            .addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
    getEntityMappings()
        .addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
    assertEquals(3, ormPersistentType.getDefaultAttributesSize());
    OrmPersistentAttribute virtualPersistentAttribute =
        ormPersistentType.getDefaultAttributes().iterator().next();

    OneToOneMapping virtualOneToOneMapping =
        (OneToOneMapping) virtualPersistentAttribute.getMapping();
    assertEquals("address", virtualOneToOneMapping.getName());
    assertEquals(FetchType.LAZY, virtualOneToOneMapping.getSpecifiedFetch());
    assertEquals(Boolean.FALSE, virtualOneToOneMapping.getSpecifiedOptional());
    assertEquals("Address", virtualOneToOneMapping.getSpecifiedTargetEntity());
    assertNull(
        virtualOneToOneMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());

    SpecifiedJoinColumn virtualJoinColumn =
        virtualOneToOneMapping
            .getRelationship()
            .getJoinColumnStrategy()
            .getSpecifiedJoinColumns()
            .iterator()
            .next();
    assertEquals("MY_COLUMN", virtualJoinColumn.getSpecifiedName());
    assertEquals("MY_REFERENCED_COLUMN", virtualJoinColumn.getSpecifiedReferencedColumnName());
    assertEquals(Boolean.TRUE, virtualJoinColumn.getSpecifiedUnique());
    assertEquals(Boolean.FALSE, virtualJoinColumn.getSpecifiedNullable());
    assertEquals(Boolean.FALSE, virtualJoinColumn.getSpecifiedInsertable());
    assertEquals(Boolean.FALSE, virtualJoinColumn.getSpecifiedUpdatable());
    assertEquals("COLUMN_DEFINITION", virtualJoinColumn.getColumnDefinition());
    assertEquals("MY_TABLE", virtualJoinColumn.getSpecifiedTableName());

    Cascade cascade = virtualOneToOneMapping.getCascade();
    assertTrue(cascade.isAll());
    assertTrue(cascade.isMerge());
    assertTrue(cascade.isPersist());
    assertTrue(cascade.isRemove());
    assertTrue(cascade.isRefresh());

    assertEquals(
        EclipseLinkJoinFetchType.INNER,
        ((EclipseLinkJoinFetchMapping) virtualOneToOneMapping).getJoinFetch().getValue());
    assertTrue(
        ((EclipseLinkOneToOneMapping) virtualOneToOneMapping).getPrivateOwned().isPrivateOwned());
  }
  public void testVirtualMappingMetadataCompleteTrue() throws Exception {
    createTestEntityOneToOneMapping();
    createTestTargetEntityAddress();

    OrmPersistentType ormPersistentType =
        getEntityMappings()
            .addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
    getEntityMappings()
        .addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
    ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
    assertEquals(3, ormPersistentType.getDefaultAttributesSize());
    OrmPersistentAttribute virtualPersistentAttribute =
        ormPersistentType.getAttributeNamed("address");

    assertEquals(
        MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
    assertTrue(virtualPersistentAttribute.isVirtual());

    EclipseLinkOneToOneMapping ormOneToOneMapping =
        (EclipseLinkOneToOneMapping) virtualPersistentAttribute.getMapping();
    assertEquals("address", ormOneToOneMapping.getName());
    assertEquals(FetchType.EAGER, ormOneToOneMapping.getFetch());
    assertEquals(true, ormOneToOneMapping.isOptional());
    assertEquals("test.Address", ormOneToOneMapping.getTargetEntity());
    assertNull(ormOneToOneMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());

    // TODO default join columns in xml one-to-one
    //		XmlJoinColumn ormJoinColumn = ormOneToOneMapping.specifiedJoinColumns().next();
    //		//TODO java default columns name in JavaSingleRelationshipMapping.JoinColumnOwner
    //		//assertEquals("address", ormJoinColumn.getSpecifiedName());
    //		//assertEquals("address", ormJoinColumn.getSpecifiedReferencedColumnName());
    //		assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUnique());
    //		assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedNullable());
    //		assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedInsertable());
    //		assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUpdatable());
    //		assertNull(ormJoinColumn.getColumnDefinition());
    //		assertEquals(TYPE_NAME, ormJoinColumn.getSpecifiedTable());

    Cascade cascade = ormOneToOneMapping.getCascade();
    assertFalse(cascade.isAll());
    assertFalse(cascade.isMerge());
    assertFalse(cascade.isPersist());
    assertFalse(cascade.isRemove());
    assertFalse(cascade.isRefresh());

    assertEquals(null, ormOneToOneMapping.getJoinFetch().getValue());
    assertFalse(ormOneToOneMapping.getPrivateOwned().isPrivateOwned());
  }
  public void testSpecifiedMapping() throws Exception {
    createTestEntityOneToOneMapping();
    createTestTargetEntityAddress();

    OrmPersistentType ormPersistentType =
        getEntityMappings()
            .addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
    getEntityMappings()
        .addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");

    ormPersistentType.addAttributeToXml(
        ormPersistentType.getAttributeNamed("address"),
        MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
    assertEquals(2, ormPersistentType.getDefaultAttributesSize());

    OrmSpecifiedPersistentAttribute ormPersistentAttribute =
        ormPersistentType.getSpecifiedAttributes().iterator().next();
    EclipseLinkOrmOneToOneMapping ormOneToOneMapping =
        (EclipseLinkOrmOneToOneMapping) ormPersistentAttribute.getMapping();

    assertEquals("address", ormOneToOneMapping.getName());
    assertNull(ormOneToOneMapping.getSpecifiedFetch());
    assertNull(ormOneToOneMapping.getSpecifiedOptional());
    assertNull(ormOneToOneMapping.getSpecifiedTargetEntity());
    assertNull(ormOneToOneMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
    assertEquals(FetchType.EAGER, ormOneToOneMapping.getFetch());
    assertEquals(true, ormOneToOneMapping.isOptional());
    // TODO default target entity in xml
    // assertEquals("test.Address", ormOneToOneMapping.getDefaultTargetEntity());

    assertTrue(
        ormOneToOneMapping.getRelationship().getJoinColumnStrategy().getJoinColumnsSize() > 0);

    // TODO default join columns for specified xmlOneToOne mapping
    //		XmlJoinColumn ormJoinColumn = ormOneToOneMapping.defaultJoinColumns().next();
    //		assertNull(ormJoinColumn.getSpecifiedName());
    //		assertNull(ormJoinColumn.getSpecifiedReferencedColumnName());
    //		assertNull(ormJoinColumn.getSpecifiedUnique());
    //		assertNull(ormJoinColumn.getSpecifiedNullable());
    //		assertNull(ormJoinColumn.getSpecifiedInsertable());
    //		assertNull(ormJoinColumn.getSpecifiedUpdatable());
    //		assertNull(ormJoinColumn.getColumnDefinition());
    //		assertNull(ormJoinColumn.getSpecifiedTable());
    //
    //		assertEquals("address", ormJoinColumn.getDefaultName());
    //		assertEquals("address", ormJoinColumn.getDefaultReferencedColumnName());
    //		assertEquals(Boolean.FALSE, ormJoinColumn.getDefaultUnique());
    //		assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultNullable());
    //		assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultInsertable());
    //		assertEquals(Boolean.TRUE, ormJoinColumn.getDefaultUpdatable());
    //		assertEquals(null, ormJoinColumn.getColumnDefinition());
    //		assertEquals(TYPE_NAME, ormJoinColumn.getDefaultTable());

    Cascade cascade = ormOneToOneMapping.getCascade();
    assertFalse(cascade.isAll());
    assertFalse(cascade.isMerge());
    assertFalse(cascade.isPersist());
    assertFalse(cascade.isRemove());
    assertFalse(cascade.isRefresh());

    assertEquals(null, ormOneToOneMapping.getJoinFetch().getValue());
    assertFalse(ormOneToOneMapping.getPrivateOwned().isPrivateOwned());
  }