diff options
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java')
-rw-r--r-- | jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java | 884 |
1 files changed, 884 insertions, 0 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java new file mode 100644 index 0000000000..e9eecf4dc0 --- /dev/null +++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0Tests.java @@ -0,0 +1,884 @@ +/******************************************************************************* + * Copyright (c) 2009, 2011 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.java; + +import java.util.Iterator; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter; +import org.eclipse.jpt.common.utility.internal.CollectionTools; +import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; +import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator; +import org.eclipse.jpt.jpa.core.MappingKeys; +import org.eclipse.jpt.jpa.core.context.AttributeMapping; +import org.eclipse.jpt.jpa.core.context.OneToOneMapping; +import org.eclipse.jpt.jpa.core.context.PersistentAttribute; +import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; +import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; +import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; +import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute; +import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneMapping2_0; +import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneRelationship2_0; +import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaDerivedIdentity2_0; +import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneMapping2_0; +import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneMapping2_0; +import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovable2_0; +import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovalHolder2_0; +import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0; +import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation; +import org.eclipse.jpt.jpa.core.jpa2.resource.java.OneToOne2_0Annotation; +import org.eclipse.jpt.jpa.core.resource.java.JPA; +import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation; +import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.Generic2_0ContextModelTestCase; + +@SuppressWarnings("nls") +public class GenericJavaOneToOneMapping2_0Tests + extends Generic2_0ContextModelTestCase +{ + public GenericJavaOneToOneMapping2_0Tests(String name) { + super(name); + } + + + private void createTestEntity() throws Exception { + createTestType(new DefaultAnnotationWriter() { + @Override + public Iterator<String> imports() { + return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE); + } + + @Override + public void appendTypeAnnotationTo(StringBuilder sb) { + sb.append("@Entity"); + sb.append(CR); + } + + @Override + public void appendIdFieldAnnotationTo(StringBuilder sb) { + sb.append(CR); + sb.append(" @OneToOne"); + sb.append(CR); + sb.append(" private Address address;"); + sb.append(CR); + sb.append(CR); + sb.append(" @Id"); + } + }); + } + + private ICompilationUnit createTestEntityWithIdDerivedIdentity() throws Exception { + return this.createTestType(new DefaultAnnotationWriter() { + @Override + public Iterator<String> imports() { + return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.ID); + } + @Override + public void appendTypeAnnotationTo(StringBuilder sb) { + sb.append("@Entity").append(CR); + } + + @Override + public void appendIdFieldAnnotationTo(StringBuilder sb) { + sb.append(CR); + sb.append(" @OneToOne @Id").append(CR); + sb.append(" private " + TYPE_NAME + " oneToOne;").append(CR); + sb.append(CR); + } + }); + } + + private void createTestEntityWithMapsIdDerivedIdentity() throws Exception { + createTestType(new DefaultAnnotationWriter() { + @Override + public Iterator<String> imports() { + return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA2_0.MAPS_ID); + } + @Override + public void appendTypeAnnotationTo(StringBuilder sb) { + sb.append("@Entity").append(CR); + } + + @Override + public void appendIdFieldAnnotationTo(StringBuilder sb) { + sb.append(CR); + sb.append(" @OneToOne @MapsId").append(CR); + sb.append(" private " + TYPE_NAME + " oneToOne;").append(CR); + sb.append(CR); + } + }); + OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME); + for (OrmReadOnlyPersistentAttribute each : CollectionTools.iterable(ormPersistentType.attributes())) { + each.convertToSpecified(); + } + } + + private ICompilationUnit createTestEntityWithValidOneToOneMapping() throws Exception { + return this.createTestType(new DefaultAnnotationWriter() { + @Override + public Iterator<String> imports() { + return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.ID); + } + @Override + public void appendTypeAnnotationTo(StringBuilder sb) { + sb.append("@Entity").append(CR); + } + + @Override + public void appendIdFieldAnnotationTo(StringBuilder sb) { + sb.append(CR); + sb.append(" @OneToOne").append(CR); + sb.append(" private Address address;").append(CR); + sb.append(CR); + sb.append(" @Id").append(CR); + } + }); + } + + private void createTestEntityWithValidOneToOneMappingOrphanRemovalSpecified() throws Exception { + createTestType(new DefaultAnnotationWriter() { + @Override + public Iterator<String> imports() { + return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE); + } + + @Override + public void appendTypeAnnotationTo(StringBuilder sb) { + sb.append("@Entity"); + sb.append(CR); + } + + @Override + public void appendIdFieldAnnotationTo(StringBuilder sb) { + sb.append(CR); + sb.append(" @OneToOne(orphanRemoval=false)"); + sb.append(CR); + sb.append(" private Address address;"); + sb.append(CR); + sb.append(CR); + sb.append(" @Id"); + } + }); + } + + private void createTestTargetEntityAddress() throws Exception { + SourceWriter sourceWriter = new SourceWriter() { + public void appendSourceTo(StringBuilder sb) { + sb.append(CR); + sb.append("import "); + sb.append(JPA.ENTITY); + sb.append(";"); + sb.append(CR); + sb.append("import "); + sb.append(JPA.ID); + sb.append(";"); + sb.append(CR); + sb.append("import "); + sb.append(JPA.EMBEDDED); + sb.append(";"); + sb.append(CR); + sb.append("@Entity"); + sb.append(CR); + sb.append("public class ").append("Address").append(" "); + sb.append("{").append(CR); + sb.append(CR); + sb.append(" @Id").append(CR); + sb.append(" private int id;").append(CR); + sb.append(CR); + sb.append(" private String city;").append(CR); + sb.append(CR); + sb.append(" @Embedded").append(CR); + sb.append(" private State state;").append(CR); + sb.append(CR); + sb.append(" private int zip;").append(CR); + sb.append(CR); + sb.append("}").append(CR); + } + }; + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); + } + + private void createTestTargetEntityAddressWithElementCollection() throws Exception { + SourceWriter sourceWriter = new SourceWriter() { + public void appendSourceTo(StringBuilder sb) { + sb.append(CR); + sb.append("import "); + sb.append(JPA.ENTITY); + sb.append(";"); + sb.append(CR); + sb.append("import "); + sb.append(JPA.ID); + sb.append(";"); + sb.append(CR); + sb.append("import "); + sb.append(JPA2_0.ELEMENT_COLLECTION); + sb.append(";"); + sb.append(CR); + sb.append("@Entity"); + sb.append(CR); + sb.append("public class ").append("Address").append(" "); + sb.append("{").append(CR); + sb.append(CR); + sb.append(" @Id").append(CR); + sb.append(" private int id;").append(CR); + sb.append(CR); + sb.append(" private String city;").append(CR); + sb.append(CR); + sb.append(" @ElementCollection").append(CR); + sb.append(" private java.util.Collection<State> state;").append(CR); + sb.append(CR); + sb.append(" private int zip;").append(CR); + sb.append(CR); + sb.append("}").append(CR); + } + }; + this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter); + } + + private void createTestEmbeddableState() throws Exception { + SourceWriter sourceWriter = new SourceWriter() { + public void appendSourceTo(StringBuilder sb) { + sb.append(CR); + sb.append("import "); + sb.append(JPA.EMBEDDABLE); + sb.append(";"); + sb.append(CR); + sb.append("@Embeddable"); + sb.append(CR); + sb.append("public class ").append("State").append(" "); + sb.append("{").append(CR); + sb.append(CR); + sb.append(" private String foo;").append(CR); + sb.append(CR); + sb.append(" private Address address;").append(CR); + sb.append(CR); + sb.append("}").append(CR); + } + }; + this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter); + } + + public void testUpdateId() throws Exception { + createTestEntityWithIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping(); + + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + + resourceAttribute.removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + + resourceAttribute.addAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + } + + public void testSetId() throws Exception { + createTestEntityWithIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping(); + + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + + contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(false); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + + contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(true); + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + } + + public void testUpdateMapsId() throws Exception { + createTestEntityWithMapsIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping(); + + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + MapsId2_0Annotation annotation = + (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID); + annotation.setValue("foo"); + getJpaProject().synchronizeContextModel(); + assertEquals("foo", annotation.getValue()); + assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + annotation.setValue("bar"); + getJpaProject().synchronizeContextModel(); + assertEquals("bar", annotation.getValue()); + assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + } + + public void testSetMapsId() throws Exception { + createTestEntityWithMapsIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping(); + + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue("foo"); + MapsId2_0Annotation annotation = + (MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID); + assertNotNull(annotation); + assertEquals("foo", annotation.getValue()); + assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue("bar"); + assertEquals("bar", annotation.getValue()); + assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue(null); + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + } + + public void testUpdatePredominantDerivedIdentityStrategy() throws Exception { + createTestEntityWithMapsIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping(); + JavaDerivedIdentity2_0 derivedIdentity = contextMapping.getDerivedIdentity(); + + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesNullDerivedIdentityStrategy()); + + resourceAttribute.addAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesNullDerivedIdentityStrategy()); + + resourceAttribute.removeAnnotation(JPA2_0.MAPS_ID); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertTrue(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesNullDerivedIdentityStrategy()); + + resourceAttribute.removeAnnotation(JPA.ID); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertTrue(derivedIdentity.usesNullDerivedIdentityStrategy()); + } + + public void testSetPredominantDerivedIdentityStrategy() throws Exception { + createTestEntityWithMapsIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping(); + JavaDerivedIdentity2_0 derivedIdentity = contextMapping.getDerivedIdentity(); + + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesNullDerivedIdentityStrategy()); + + derivedIdentity.setIdDerivedIdentityStrategy(); + assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNotNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertTrue(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesNullDerivedIdentityStrategy()); + + derivedIdentity.setNullDerivedIdentityStrategy(); + assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertTrue(derivedIdentity.usesNullDerivedIdentityStrategy()); + + derivedIdentity.setMapsIdDerivedIdentityStrategy(); + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertTrue(derivedIdentity.usesMapsIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesIdDerivedIdentityStrategy()); + assertFalse(derivedIdentity.usesNullDerivedIdentityStrategy()); + } + + public void testMorphMapping() throws Exception { + createTestEntityWithMapsIdDerivedIdentity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentType resourceType = + getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute resourceAttribute = resourceType.persistableAttributes().next(); + JavaPersistentType contextType = getJavaPersistentType(); + JavaPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne"); + + ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).setValue("foo"); + getJpaProject().synchronizeContextModel(); + + assertNull(resourceAttribute.getAnnotation(JPA.ID)); + assertFalse(((JavaOneToOneMapping2_0) contextAttribute.getMapping()). + getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertEquals("foo", ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).getValue()); + assertEquals("foo", ((JavaOneToOneMapping2_0) contextAttribute.getMapping()). + getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); + assertFalse(((JavaManyToOneMapping2_0) contextAttribute.getMapping()). + getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertEquals("foo", ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).getValue()); + assertEquals("foo", ((JavaManyToOneMapping2_0) contextAttribute.getMapping()). + getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + + contextAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY); + assertFalse(((JavaOneToOneMapping2_0) contextAttribute.getMapping()). + getDerivedIdentity().getIdDerivedIdentityStrategy().getValue()); + assertNotNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)); + assertEquals("foo", ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).getValue()); + assertEquals("foo", ((JavaOneToOneMapping2_0) contextAttribute.getMapping()). + getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue()); + } + + public void testCandidateMappedByAttributeNames() throws Exception { + createTestEntityWithValidOneToOneMapping(); + createTestTargetEntityAddress(); + createTestEmbeddableState(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + addXmlClassRef(PACKAGE_NAME + ".Address"); + addXmlClassRef(PACKAGE_NAME + ".State"); + + PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next(); + OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping(); + + Iterator<String> attributeNames = + oneToOneMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames(); + assertEquals("id", attributeNames.next()); + assertEquals("city", attributeNames.next()); + assertEquals("state", attributeNames.next()); + assertEquals("state.foo", attributeNames.next()); + assertEquals("state.address", attributeNames.next()); + assertEquals("zip", attributeNames.next()); + assertFalse(attributeNames.hasNext()); + + oneToOneMapping.setSpecifiedTargetEntity("foo"); + attributeNames = + oneToOneMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames(); + assertFalse(attributeNames.hasNext()); + + oneToOneMapping.setSpecifiedTargetEntity(null); + attributeNames = + oneToOneMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames(); + assertEquals("id", attributeNames.next()); + assertEquals("city", attributeNames.next()); + assertEquals("state", attributeNames.next()); + assertEquals("state.foo", attributeNames.next()); + assertEquals("state.address", attributeNames.next()); + assertEquals("zip", attributeNames.next()); + assertFalse(attributeNames.hasNext()); + + AttributeMapping stateFooMapping = oneToOneMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo"); + assertEquals("foo", stateFooMapping.getName()); + } + + public void testCandidateMappedByAttributeNamesElementCollection() throws Exception { + createTestEntityWithValidOneToOneMapping(); + createTestTargetEntityAddressWithElementCollection(); + createTestEmbeddableState(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + addXmlClassRef(PACKAGE_NAME + ".Address"); + addXmlClassRef(PACKAGE_NAME + ".State"); + + PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next(); + OneToOneMapping oneToOneMapping = (OneToOneMapping) persistentAttribute.getMapping(); + + Iterator<String> attributeNames = + oneToOneMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames(); + assertEquals("id", attributeNames.next()); + assertEquals("city", attributeNames.next()); + assertEquals("state", attributeNames.next()); + assertEquals("state.foo", attributeNames.next()); + assertEquals("state.address", attributeNames.next()); + assertEquals("zip", attributeNames.next()); + assertFalse(attributeNames.hasNext()); + + oneToOneMapping.setSpecifiedTargetEntity("foo"); + attributeNames = + oneToOneMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames(); + assertFalse(attributeNames.hasNext()); + + oneToOneMapping.setSpecifiedTargetEntity(null); + attributeNames = + oneToOneMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames(); + assertEquals("id", attributeNames.next()); + assertEquals("city", attributeNames.next()); + assertEquals("state", attributeNames.next()); + assertEquals("state.foo", attributeNames.next()); + assertEquals("state.address", attributeNames.next()); + assertEquals("zip", attributeNames.next()); + assertFalse(attributeNames.hasNext()); + + AttributeMapping stateFooMapping = oneToOneMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo"); + assertEquals("foo", stateFooMapping.getName()); + } + + private JavaOrphanRemovable2_0 getOrphanRemovalOf(OneToOneMapping2_0 oneToOneMapping) { + return ((JavaOrphanRemovalHolder2_0) oneToOneMapping).getOrphanRemoval(); + } + + public void testDefaultOneToOneGetDefaultOrphanRemoval() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + assertEquals(false, this.getOrphanRemovalOf(oneToOneMapping).isDefaultOrphanRemoval()); + } + + public void testSpecifiedOneToOneGetDefaultOrphanRemoval() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + assertEquals(false, this.getOrphanRemovalOf(oneToOneMapping).isDefaultOrphanRemoval()); + } + + public void testGetOrphanRemoval() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping); + + assertEquals(false, mappingsOrphanRemoval.isOrphanRemoval()); + + mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE); + assertEquals(true, mappingsOrphanRemoval.isOrphanRemoval()); + } + + public void testGetSpecifiedOrphanRemoval() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping); + + assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + + JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); + OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); + oneToOne.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); + + assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + } + + public void testGetSpecifiedOrphanRemoval2() throws Exception { + this.createTestEntityWithValidOneToOneMappingOrphanRemovalSpecified(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + + assertEquals(Boolean.FALSE, this.getOrphanRemovalOf(oneToOneMapping).getSpecifiedOrphanRemoval()); + } + + public void testSetSpecifiedOrphanRemoval() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping); + + assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + + mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE); + + JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); + OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); + + assertEquals(Boolean.TRUE, oneToOne.getOrphanRemoval()); + + mappingsOrphanRemoval.setSpecifiedOrphanRemoval(null); + assertNotNull(attributeResource.getAnnotation(JPA.ONE_TO_ONE)); // .getElement); + } + + public void testSetSpecifiedOrphanRemoval2() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping); + + assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + + mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE); + + JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); + OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); + + assertEquals(Boolean.TRUE, oneToOne.getOrphanRemoval()); + + oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping); + assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + + mappingsOrphanRemoval.setSpecifiedOrphanRemoval(null); + assertNotNull(attributeResource.getAnnotation(JPA.ONE_TO_ONE)); + } + + public void testGetSpecifiedOrphanRemovalUpdatesFromResourceModelChange() throws Exception { + this.createTestEntity(); + this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 oneToOneMapping = (OneToOneMapping2_0) persistentAttribute.getMapping(); + JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToOneMapping); + + assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + + JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next(); + OneToOne2_0Annotation oneToOne = (OneToOne2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_ONE); + oneToOne.setOrphanRemoval(Boolean.FALSE); + getJpaProject().synchronizeContextModel(); + + assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + + oneToOne.setOrphanRemoval(null); + getJpaProject().synchronizeContextModel(); + assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval()); + assertSame(oneToOneMapping, persistentAttribute.getMapping()); + + oneToOne.setOrphanRemoval(Boolean.FALSE); + attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance()); + getJpaProject().synchronizeContextModel(); + + assertTrue(persistentAttribute.getMapping().isDefault()); + } + + public void testModifyPredominantJoiningStrategy() throws Exception { + createTestEntityWithValidOneToOneMapping(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next(); + OneToOneAnnotation annotation = (OneToOneAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_ONE); + PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 mapping = (OneToOneMapping2_0) contextAttribute.getMapping(); + OneToOneRelationship2_0 rel = (OneToOneRelationship2_0) mapping.getRelationship(); + + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertTrue(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + rel.setStrategyToPrimaryKeyJoinColumn(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertTrue(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + rel.setStrategyToMappedBy(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNotNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertTrue(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + rel.setStrategyToJoinTable(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertTrue(rel.strategyIsJoinTable()); + + rel.setStrategyToJoinColumn(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertTrue(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + } + + public void testUpdatePredominantJoiningStrategy() throws Exception { + createTestEntityWithValidOneToOneMapping(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next(); + OneToOneAnnotation annotation = (OneToOneAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_ONE); + PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next(); + OneToOneMapping2_0 mapping = (OneToOneMapping2_0) contextAttribute.getMapping(); + OneToOneRelationship2_0 rel = (OneToOneRelationship2_0) mapping.getRelationship(); + + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertTrue(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + resourceAttribute.addAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertTrue(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + annotation.setMappedBy("foo"); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNotNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertTrue(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + resourceAttribute.addAnnotation(JPA.JOIN_COLUMN); + getJpaProject().synchronizeContextModel(); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNotNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertTrue(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + resourceAttribute.addAnnotation(JPA.JOIN_TABLE); + getJpaProject().synchronizeContextModel(); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNotNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNotNull(annotation.getMappedBy()); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertTrue(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + resourceAttribute.removeAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN); + getJpaProject().synchronizeContextModel(); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNotNull(annotation.getMappedBy()); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertTrue(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + + annotation.setMappedBy(null); + getJpaProject().synchronizeContextModel(); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertTrue(rel.strategyIsJoinTable()); + + resourceAttribute.removeAnnotation(JPA.JOIN_COLUMN); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertFalse(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertTrue(rel.strategyIsJoinTable()); + + resourceAttribute.removeAnnotation(JPA.JOIN_TABLE); + getJpaProject().synchronizeContextModel(); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN)); + assertNull(resourceAttribute.getAnnotation(JPA.PRIMARY_KEY_JOIN_COLUMN)); + assertNull(annotation.getMappedBy()); + assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE)); + assertTrue(rel.strategyIsJoinColumn()); + assertFalse(rel.strategyIsPrimaryKeyJoinColumn()); + assertFalse(rel.strategyIsMappedBy()); + assertFalse(rel.strategyIsJoinTable()); + } +} |