Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests')
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.classpath14
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.cvsignore1
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.project28
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/META-INF/MANIFEST.MF46
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/about.html34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/build.properties18
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/plugin.properties23
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/JptJpaEclipseLinkCoreTests.java93
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java49
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkJpaProjectTests.java149
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptEclipseLink1_0CoreContextModelTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptJpaEclipseLinkCoreContextModelTests.java45
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java322
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java646
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java224
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java222
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java253
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java387
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java323
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java149
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java148
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java348
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java644
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java579
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java448
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java221
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java313
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java322
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java43
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkEntityMappingsTests.java675
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmBasicMappingTests.java389
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmContextModelTestCase.java84
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmConverterTests.java194
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEmbeddableTests.java1035
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEntityTests.java2394
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmIdMappingTests.java389
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToManyMappingTests.java383
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToOneMappingTests.java321
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmMappedSuperclassTests.java2147
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmObjectTypeConverterTests.java569
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java747
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToOneMappingTests.java455
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmPersistentAttributeTests.java313
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmStructConverterTests.java199
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTransientMappingTests.java62
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTypeConverterTests.java266
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmVersionMappingTests.java387
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitDefaultsTests.java369
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitMetadataTests.java105
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/JptEclipseLinkCoreOrmContextModelTests.java47
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java53
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTests.java178
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/JptEclipseLinkCorePersistenceContextModelTests.java43
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java449
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java444
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/JptEclipseLinkPersistenceCachingTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/EclipseLinkConnectionTests.java542
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/JptEclipseLinkPersistenceConnectionTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java205
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/EclipseLinkCustomizationTests.java761
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/JptEclipseLinkPersistenceCustomizationTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesAdapterTests.java105
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesValueModelTests.java162
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/JptEclipseLinkPersistenceGeneralTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/JptEclipseLinkPersistenceLoggingTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java340
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingValueModelTests.java162
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/JptEclipseLinkPersistenceOptionsTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java380
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsValueModelTests.java161
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/JptEclipseLinkPersistenceSchemaGenerationTests.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationAdapterTests.java254
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationBasicAdapterTests.java154
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationValueModelTests.java232
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/JptJpaEclipselinkCoreResourceModelTests.java41
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CacheTests.java448
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ChangeTrackingTests.java88
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConversionValueAnnotationTests.java131
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConvertAnnotationTests.java105
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConverterAnnotationTests.java155
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CustomizerAnnotationTests.java99
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkJavaResourceModelTestCase.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkPrimaryKeyAnnotationTests.java53
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ExistenceCheckingTests.java88
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JoinFetchTests.java92
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JptEclipseLinkCoreJavaResourceModelTests.java47
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/MutableAnnotationTests.java111
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ObjectTypeConverterAnnotationTests.java426
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/PrivateOwnedTests.java49
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadOnlyTests.java47
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadTransformerAnnotationTests.java155
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/StructConverterAnnotationTests.java155
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java220
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TransformationAnnotationTests.java158
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TypeConverterAnnotationTests.java214
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/WriteTransformerAnnotationTests.java219
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1ContextModelTestCase.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1JpaProjectTests.java173
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/JptEclipseLink1_1CoreContextModelTests.java31
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmContextModelTestCase.java92
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentAttributeTests.java430
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentTypeTests.java302
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmTransientMappingTests.java64
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/JptEclipseLink1_1CoreOrmContextModelTests.java33
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2ContextModelTestCase.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2JpaProjectTests.java173
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/JptEclipseLink1_2CoreContextModelTests.java30
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/EclipseLink2_0ContextModelTestCase.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/JptEclipseLink2_0CoreContextModelTests.java38
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaCollectionTableTests.java724
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java2077
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaEntityTests.java1813
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToManyMappingTests.java1303
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToOneMappingTests.java330
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaMappedSuperclassTests.java528
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToManyMappingTests.java1422
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java818
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/JptEclipseLink2_0JavaContextModelTests.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmCollectionTableTests.java752
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmContextModelTestCase.java92
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java1446
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmEntityTests.java1806
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java963
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java2375
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java1076
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToOneMappingTests.java910
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/Eclipselink2_0OrmManyToOneMappingTests.java589
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/JptEclipseLink2_0OrmContextModelTests.java35
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0ConnectionTests.java173
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0LoggingTests.java431
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0OptionsTests.java519
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java57
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/JptEclipseLink2_0CorePersistenceContextModelTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/test.xml49
134 files changed, 0 insertions, 47474 deletions
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.classpath b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.classpath
deleted file mode 100644
index 3fbf40ae96..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.classpath
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/jpa/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.project b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.project
deleted file mode 100644
index 0dcf45fd19..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.jpa.eclipselink.core.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 093e19af8c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,46 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.jpa.eclipselink.core.tests
-Bundle-Version: 2.0.0.qualifier
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.commands;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)",
- org.eclipse.jpt.common.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jpt.common.core.tests;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.jpa.core;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.jpt.jpa.eclipselink.core;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.jpa.core.tests;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.wst.common.emf;bundle-version="[1.1.201,2.0.0)",
- org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.201,2.0.0)",
- org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.modulecore;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.junit;bundle-version="3.8.0"
-Export-Package: org.eclipse.jpt.jpa.eclipselink.core.tests.internal;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.java;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.orm;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.caching;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.connection;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.customization;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.general;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.logging;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.options;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.schema.generation;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.resource;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.resource.java;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_1.context;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_1.context.orm;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_2.context;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.java;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.orm;x-internal:=true,
- org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.persistence;x-internal:=true
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/about.html b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/build.properties b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/build.properties
deleted file mode 100644
index 96de1ee6d2..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/build.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2008 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
-################################################################################
-javacSource = 1.5
-javacTarget = 1.5
-bin.includes = .,\
- META-INF/,\
- about.html,\
- test.xml,\
- plugin.properties
-source.. = src/
-output.. = bin/
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/plugin.properties
deleted file mode 100644
index 5b9cfcd182..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/plugin.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2009 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
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName=Dali Java Persistence Tools - EclipseLink Support - Core Tests
-providerName=Eclipse Web Tools Platform
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/JptJpaEclipseLinkCoreTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/JptJpaEclipseLinkCoreTests.java
deleted file mode 100644
index d64454a021..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/JptJpaEclipseLinkCoreTests.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal;
-
-import java.io.File;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.JptJpaEclipseLinkCoreContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.resource.JptJpaEclipselinkCoreResourceModelTests;
-
-/**
- * decentralize test creation code
- *
- * Required Java system property:
- * -Dorg.eclipse.jpt.jpa.jar=<jpa.jar path>
- * -Dorg.eclipse.jpt.eclipselink.jar=<eclipselink.jar path>
- */
-@SuppressWarnings("nls")
-public class JptJpaEclipseLinkCoreTests
-{
- private static final String JPA_JAR_PROPERTY = TestJpaProject.JPA_JAR_NAME_SYSTEM_PROPERTY;
- private static final String ECLIPSELINK_JAR_PROPERTY = TestJpaProject.ECLIPSELINK_JAR_NAME_SYSTEM_PROPERTY;
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptJpaEclipseLinkCoreTests.class.getPackage().getName());
- suite.addTest(JptJpaEclipselinkCoreResourceModelTests.suite());
- suite.addTest(JptJpaEclipseLinkCoreContextModelTests.suite());
- return suite;
- }
-
- public static boolean requiredJarsExists() {
- return jpaJarPropertyExists()
- && jpaJarFileExists()
- && eclipselinkJarPropertyExists()
- && eclipselinkJarFileExists();
- }
-
- public static boolean jpaJarPropertyExists() {
- return getSystemProperty(JPA_JAR_PROPERTY) != null;
- }
-
- public static boolean jpaJarFileExists() {
- return (new File(getSystemProperty(JPA_JAR_PROPERTY))).exists();
- }
-
- public static boolean eclipselinkJarPropertyExists() {
- return getSystemProperty(ECLIPSELINK_JAR_PROPERTY) != null;
- }
-
- public static boolean eclipselinkJarFileExists() {
- return (new File(getSystemProperty(ECLIPSELINK_JAR_PROPERTY))).exists();
- }
-
- public static String buildMissingJarErrorMessage() {
- if( ! jpaJarPropertyExists()) {
- return errorMissingProperty(JPA_JAR_PROPERTY);
- }
- else if( ! jpaJarFileExists()) {
- return errorJarFileDoesNotExist(getSystemProperty(JPA_JAR_PROPERTY));
- }
- else if( ! eclipselinkJarPropertyExists()) {
- return errorMissingProperty(ECLIPSELINK_JAR_PROPERTY);
- }
- return errorJarFileDoesNotExist(getSystemProperty(ECLIPSELINK_JAR_PROPERTY));
- }
-
- /*********** private **********/
-
- private static String errorMissingProperty(String propertyName) {
- return "missing Java system property: \"" + propertyName + "\"";
- }
-
- private static String errorJarFileDoesNotExist(String propertyValue) {
- return "JAR file doesn't exist: \"" + propertyValue + "\"";
- }
-
- private static String getSystemProperty(String propertyName) {
- return System.getProperty(propertyName);
- }
-
- private JptJpaEclipseLinkCoreTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java
deleted file mode 100644
index a8c0b43eb0..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkContextModelTestCase.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context;
-
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase;
-import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkJpaProject;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-public abstract class EclipseLinkContextModelTestCase
- extends ContextModelTestCase
-{
- protected EclipseLinkContextModelTestCase(String name) {
- super(name);
- }
-
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM, EclipseLinkPlatform.VERSION_1_0);
- return dataModel;
- }
-
- @Override
- protected EclipseLinkJpaProject getJpaProject() {
- return (EclipseLinkJpaProject) super.getJpaProject();
- }
-
- @Override
- protected EclipseLinkPersistenceUnit getPersistenceUnit() {
- return (EclipseLinkPersistenceUnit) super.getPersistenceUnit();
- }
-
- @Override
- protected JavaEclipseLinkEntity getJavaEntity() {
- return (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkJpaProjectTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkJpaProjectTests.java
deleted file mode 100644
index 40cf67f75d..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLinkJpaProjectTests.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.context;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJpaProjectTests extends EclipseLinkContextModelTestCase
-{
-
- public EclipseLinkJpaProjectTests(String name) {
- super(name);
- }
-
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- // don't build orm.xml
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.FALSE);
- return dataModel;
- }
-
- public void testGetDefaultOrmXmlResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
- //add the orm.xml file with eclipselink orm content type
- createDefaultOrmXmlFileWithEclipseLinkContentType();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
-
- //add the orm.xml file this time with orm content type
- createDefaultOrmXmlFile();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
- }
-
- public void testGetDefaultEclipseLinkOrmXmlResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNull(resource);
-
- //add the eclipselink-orm.xml file
- createDefaultEclipseLinkOrmXmlFile();
- resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/eclipselink-orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the eclipselink-orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNull(resource);
- }
-
- private void createDefaultOrmXmlFile() throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.getDefaultOperation().execute(null, null);
- }
-
- private void createDefaultOrmXmlFileWithEclipseLinkContentType() throws Exception {
- createEclipseLinkOrmXmlFile(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.lastSegment());
- }
-
- private void createDefaultEclipseLinkOrmXmlFile() throws Exception {
- createEclipseLinkOrmXmlFile(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.lastSegment());
- }
-
- private void createEclipseLinkOrmXmlFile(String fileName) throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, fileName);
- config.getDefaultOperation().execute(null, null);
- }
-
- public void testGetMappingFileResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNull(resource);
-
- //add the eclipselink-orm.xml file
- createDefaultEclipseLinkOrmXmlFile();
- resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/eclipselink-orm.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the eclipselink-orm.xml file and verify it is not returned from getMappingFileResource()
- resource.delete(null);
- resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNull(resource);
- }
-
- public void testGetDifferentlyNamedMappingFileResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNull(resource);
-
- //create the orm2.xml file
- createEclipseLinkOrmXmlFile("orm2.xml");
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the orm2.xml file and verify it is not returned from getMappingFileResource()
- resource.delete(null);
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNull(resource);
-
- //add the orm2.xml file back
- createEclipseLinkOrmXmlFile("orm2.xml");
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptEclipseLink1_0CoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptEclipseLink1_0CoreContextModelTests.java
deleted file mode 100644
index 308284ad55..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptEclipseLink1_0CoreContextModelTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.java.JptEclipseLinkCoreJavaContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.orm.JptEclipseLinkCoreOrmContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.JptEclipseLinkCorePersistenceContextModelTests;
-
-public class JptEclipseLink1_0CoreContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink1_0CoreContextModelTests.class.getName());
- suite.addTestSuite(EclipseLinkJpaProjectTests.class);
- suite.addTest(JptEclipseLinkCorePersistenceContextModelTests.suite());
- suite.addTest(JptEclipseLinkCoreJavaContextModelTests.suite());
- suite.addTest(JptEclipseLinkCoreOrmContextModelTests.suite());
- return suite;
- }
-
- private JptEclipseLink1_0CoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptJpaEclipseLinkCoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptJpaEclipseLinkCoreContextModelTests.java
deleted file mode 100644
index a440deb1e9..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/JptJpaEclipseLinkCoreContextModelTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.JptJpaEclipseLinkCoreTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_1.context.JptEclipseLink1_1CoreContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_2.context.JptEclipseLink1_2CoreContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.JptEclipseLink2_0CoreContextModelTests;
-
-/**
- * Required Java system property:
- * -Dorg.eclipse.jpt.jpa.jar=<jpa.jar path>
- * -Dorg.eclipse.jpt.eclipselink.jar=<eclipselink.jar path>
- */
-public class JptJpaEclipseLinkCoreContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptJpaEclipseLinkCoreContextModelTests.class.getName());
- if(JptJpaEclipseLinkCoreTests.requiredJarsExists()) {
- suite.addTest(JptEclipseLink1_0CoreContextModelTests.suite());
- suite.addTest(JptEclipseLink1_1CoreContextModelTests.suite());
- suite.addTest(JptEclipseLink1_2CoreContextModelTests.suite());
- suite.addTest(JptEclipseLink2_0CoreContextModelTests.suite());
- }
- else {
- suite.addTest(TestSuite.warning(JptJpaEclipseLinkCoreTests.buildMissingJarErrorMessage()));
- }
- return suite;
- }
-
- private JptJpaEclipseLinkCoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java
deleted file mode 100644
index c6f779f06a..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaBasicMappingTests.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.TemporalConverter;
-import org.eclipse.jpt.jpa.core.context.TemporalType;
-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.TemporalAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMutable;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkMutableAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaBasicMappingTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- }
- });
- }
-
-
- private ICompilationUnit createTestEntityWithConvert() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"class-instance\")").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableBasic() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.MUTABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append("@Mutable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableBasicDate() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.MUTABLE, "java.util.Date");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append(" @Mutable").append(CR);
- sb.append(" private Date myDate;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- public EclipseLinkJavaBasicMappingTests(String name) {
- super(name);
- }
-
-
- public void testGetConvert() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertEquals(EclipseLinkConvert.class, basicMapping.getConverter().getType());
- }
-
- public void testGetConvert2() throws Exception {
- createTestEntityWithConvert();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertEquals(EclipseLinkConvert.class, basicMapping.getConverter().getType());
- assertEquals(EclipseLinkConvert.CLASS_INSTANCE_CONVERTER, ((EclipseLinkConvert) basicMapping.getConverter()).getConverterName());
- }
-
- public void testSetConvert() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- assertNull(basicMapping.getConverter().getType());
-
- basicMapping.setConverter(TemporalConverter.class);
- ((TemporalConverter) basicMapping.getConverter()).setTemporalType(TemporalType.TIME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.TemporalType.TIME, temporal.getValue());
-
- basicMapping.setConverter(null);
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetConvertUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertNull(basicMapping.getConverter().getType());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- convert.setValue("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(EclipseLinkConvert.class, basicMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) basicMapping.getConverter()).getConverterName());
-
- attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(basicMapping.getConverter().getType());
- assertFalse(basicMapping.isDefault());
- assertSame(basicMapping, persistentAttribute.getMapping());
- }
-
- public void testGetSpecifiedMutable() throws Exception {
- createTestEntityWithMutableBasic();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkBasicMapping basicMapping = (EclipseLinkBasicMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = basicMapping.getMutable();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- mutableAnnotation.setValue(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- mutableAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- mutableAnnotation.setValue(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.FALSE, mutable.getSpecifiedMutable());
-
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, mutable.getSpecifiedMutable());
-
- attributeResource.addAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
- }
-
- public void testSetSpecifiedMutable() throws Exception {
- createTestEntityWithMutableBasic();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkBasicMapping basicMapping = (EclipseLinkBasicMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = basicMapping.getMutable();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(null, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertEquals(null, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(null);
- mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(null, mutableAnnotation);
-
- mutable.setSpecifiedMutable(Boolean.FALSE);
- mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.FALSE, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, mutableAnnotation.getValue());
- }
-
- public void testIsDefaultMutable() throws Exception {
- createTestEntityWithMutableBasic();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkBasicMapping basicMapping = (EclipseLinkBasicMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = basicMapping.getMutable();
- assertTrue(mutable.isDefaultMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertTrue(mutable.isDefaultMutable());
-
- mutable.setSpecifiedMutable(Boolean.FALSE);
- assertTrue(mutable.isDefaultMutable());
-
- //set mutable default to false in the persistence unit properties, verify default in java still true since this is not a Date/Calendar
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.FALSE);
- assertTrue(mutable.isDefaultMutable());
- }
-
- public void testIsDefaultMutableForDate() throws Exception {
- createTestEntityWithMutableBasicDate();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkBasicMapping basicMapping = (EclipseLinkBasicMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = basicMapping.getMutable();
- assertFalse(mutable.isDefaultMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertFalse(mutable.isDefaultMutable());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertFalse(mutable.isDefaultMutable());
-
- //set mutable default to false in the persistence unit properties, verify default in java still true since this is not a Date/Calendar
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.TRUE);
- assertTrue(mutable.isDefaultMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.FALSE);
- assertFalse(mutable.isDefaultMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(null);
- assertFalse(mutable.isDefaultMutable());
- }
-
- public void testIsMutable() throws Exception {
- createTestEntityWithMutableBasic();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkBasicMapping basicMapping = (EclipseLinkBasicMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = basicMapping.getMutable();
- assertTrue(mutable.isMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertTrue(mutable.isMutable());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertTrue(mutable.isMutable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java
deleted file mode 100644
index 9f44676110..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheCoordinationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkExistenceType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTimeOfDay;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCacheAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkExistenceCheckingAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaCachingTests extends EclipseLinkContextModelTestCase
-{
- public EclipseLinkJavaCachingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntity() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- public void testSetSpecifiedShared() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(true, caching.isShared());
-
- caching.setSpecifiedShared(Boolean.FALSE);
-
-
- assertEquals(Boolean.FALSE, entity.getCaching().getSpecifiedShared());
- assertEquals(false, entity.getCaching().isShared());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(Boolean.FALSE, cacheAnnotation.getShared());
- }
-
- public void testSetSpecifiedSharedFalseUnsetsOtherCacheSettings() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- caching.setSpecifiedType(EclipseLinkCacheType.HARD_WEAK);
- caching.setSpecifiedSize(Integer.valueOf(500));
- caching.setSpecifiedAlwaysRefresh(Boolean.FALSE);
- caching.setSpecifiedRefreshOnlyIfNewer(Boolean.FALSE);
- caching.setSpecifiedDisableHits(Boolean.FALSE);
- caching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
- caching.setExistenceChecking(true);
- caching.setSpecifiedExistenceType(EclipseLinkExistenceType.CHECK_CACHE);
- caching.setExpiry(Integer.valueOf(8000));
-
- caching.setSpecifiedShared(Boolean.FALSE);
-
- assertEquals(null, caching.getSpecifiedType());
- assertEquals(null, caching.getSpecifiedSize());
- assertEquals(null, caching.getSpecifiedAlwaysRefresh());
- assertEquals(null, caching.getSpecifiedRefreshOnlyIfNewer());
- assertEquals(null, caching.getSpecifiedDisableHits());
- assertEquals(null, caching.getSpecifiedCoordinationType());
- assertEquals(null, caching.getExpiry());
-
-
- //existence checking is the only thing that isn't unset when shared is set to false
- assertTrue(caching.isExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_CACHE, caching.getSpecifiedExistenceType());
-
- caching.setSpecifiedShared(null);
- EclipseLinkTimeOfDay timeOfDayExpiry = caching.addExpiryTimeOfDay();
- timeOfDayExpiry.setHour(Integer.valueOf(5));
-
- caching.setSpecifiedShared(Boolean.FALSE);
- assertNull(caching.getExpiryTimeOfDay());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(Boolean.FALSE, cacheAnnotation.getShared());
- assertNull(cacheAnnotation.getExpiryTimeOfDay());
- }
-
- public void testGetSpecifiedShared() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(true, caching.isShared());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setShared(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.FALSE, cacheAnnotation.getShared());
- assertEquals(Boolean.FALSE, entity.getCaching().getSpecifiedShared());
- assertEquals(false, entity.getCaching().isShared());
- }
-
- public void testSetSpecifiedType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, caching.getType());
-
- caching.setSpecifiedType(EclipseLinkCacheType.HARD_WEAK);
-
-
- assertEquals(EclipseLinkCacheType.HARD_WEAK, entity.getCaching().getSpecifiedType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, entity.getCaching().getType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheType.HARD_WEAK, cacheAnnotation.getType());
-
-
- //set specified type to the same as the default, verify it is not set to default
- caching.setSpecifiedType(EclipseLinkCacheType.SOFT_WEAK);
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, caching.getSpecifiedType());
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheType.SOFT_WEAK, cacheAnnotation.getType());
-
- caching.setSpecifiedType(null);
- assertNull(caching.getSpecifiedType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, caching.getType());
- }
-
- public void testGetSpecifiedType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, caching.getType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setType(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheType.HARD_WEAK);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheType.HARD_WEAK, cacheAnnotation.getType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, entity.getCaching().getSpecifiedType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, entity.getCaching().getType());
- }
-
- public void testSetSpecifiedAlwaysRefresh() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isAlwaysRefresh());
-
- caching.setSpecifiedAlwaysRefresh(Boolean.FALSE);
-
-
- assertEquals(Boolean.FALSE, entity.getCaching().getSpecifiedAlwaysRefresh());
- assertEquals(false, entity.getCaching().isAlwaysRefresh());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(Boolean.FALSE, cacheAnnotation.getAlwaysRefresh());
- }
-
- public void testGetSpecifiedAlwaysRefresh() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isAlwaysRefresh());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setAlwaysRefresh(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.TRUE, cacheAnnotation.getAlwaysRefresh());
- assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedAlwaysRefresh());
- assertEquals(true, entity.getCaching().isAlwaysRefresh());
- }
-
- public void testSetSpecifiedRefreshOnlyIfNewer() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isRefreshOnlyIfNewer());
-
- caching.setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
-
-
- assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedRefreshOnlyIfNewer());
- assertEquals(true, entity.getCaching().isRefreshOnlyIfNewer());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(Boolean.TRUE, cacheAnnotation.getRefreshOnlyIfNewer());
- }
-
- public void testGetSpecifiedRefreshOnlyIfNewer() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isRefreshOnlyIfNewer());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setRefreshOnlyIfNewer(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.TRUE, cacheAnnotation.getRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedRefreshOnlyIfNewer());
- assertEquals(true, entity.getCaching().isRefreshOnlyIfNewer());
- }
-
- public void testSetSpecifiedDisableHits() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isDisableHits());
-
- caching.setSpecifiedDisableHits(Boolean.TRUE);
-
-
- assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedDisableHits());
- assertEquals(true, entity.getCaching().isDisableHits());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(Boolean.TRUE, cacheAnnotation.getDisableHits());
- }
-
- public void testGetSpecifiedDisableHits() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isDisableHits());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setDisableHits(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.TRUE, cacheAnnotation.getDisableHits());
- assertEquals(Boolean.TRUE, entity.getCaching().getSpecifiedDisableHits());
- assertEquals(true, entity.getCaching().isDisableHits());
- }
-
- public void testSetSpecifiedCoordinationType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, caching.getCoordinationType());
-
- caching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
-
-
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, entity.getCaching().getSpecifiedCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, entity.getCaching().getCoordinationType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, cacheAnnotation.getCoordinationType());
-
-
- //set specified coordination type to the same as the default, verify it is not set to default
- caching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES);
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, caching.getSpecifiedCoordinationType());
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheCoordinationType.SEND_OBJECT_CHANGES, cacheAnnotation.getCoordinationType());
-
- caching.setSpecifiedCoordinationType(null);
- assertNull(caching.getSpecifiedCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, caching.getCoordinationType());
- }
-
- public void testGetSpecifiedCoordinationType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, caching.getCoordinationType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setCoordinationType(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, cacheAnnotation.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, entity.getCaching().getSpecifiedCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, entity.getCaching().getCoordinationType());
- }
-
- public void testHasExistenceChecking() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(false, caching.isExistenceChecking());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.addAnnotation(EclipseLink.EXISTENCE_CHECKING);
- getJpaProject().synchronizeContextModel();
- assertEquals(true, caching.isExistenceChecking());
-
- typeResource.removeAnnotation(EclipseLink.EXISTENCE_CHECKING);
- getJpaProject().synchronizeContextModel();
- assertEquals(false, caching.isExistenceChecking());
- }
-
- public void testSetExistenceChecking() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(false, caching.isExistenceChecking());
- assertNull(typeResource.getAnnotation(EclipseLink.EXISTENCE_CHECKING));
-
- caching.setExistenceChecking(true);
-
- assertEquals(true, caching.isExistenceChecking());
- assertNotNull(typeResource.getAnnotation(EclipseLink.EXISTENCE_CHECKING));
- }
-
- public void testGetDefaultExistenceType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, caching.getDefaultExistenceType());
-
- caching.setExistenceChecking(true);
- assertEquals(EclipseLinkExistenceType.CHECK_CACHE, caching.getDefaultExistenceType());
- }
-
- public void testGetSpecifiedExistenceType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, caching.getExistenceType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkExistenceCheckingAnnotation existenceCheckingAnnotation = (EclipseLinkExistenceCheckingAnnotation) typeResource.addAnnotation(EclipseLink.EXISTENCE_CHECKING);
- existenceCheckingAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ExistenceType.ASSUME_NON_EXISTENCE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ExistenceType.ASSUME_NON_EXISTENCE, existenceCheckingAnnotation.getValue());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, entity.getCaching().getSpecifiedExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, entity.getCaching().getExistenceType());
- }
-
- public void testSetSpecifiedExistenceType() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, caching.getExistenceType());
-
- caching.setExistenceChecking(true);
- caching.setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE);
-
-
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, entity.getCaching().getSpecifiedExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, entity.getCaching().getExistenceType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkExistenceCheckingAnnotation existenceCheckingAnnotation = (EclipseLinkExistenceCheckingAnnotation) typeResource.getAnnotation(EclipseLink.EXISTENCE_CHECKING);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ExistenceType.ASSUME_NON_EXISTENCE, existenceCheckingAnnotation.getValue());
-
-
- //set specified coordination type to the same as the default, verify it is not set to default
- caching.setSpecifiedExistenceType(EclipseLinkExistenceType.CHECK_DATABASE);
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, caching.getSpecifiedExistenceType());
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ExistenceType.CHECK_DATABASE, existenceCheckingAnnotation.getValue());
-
- caching.setSpecifiedExistenceType(null);
- assertNull(caching.getSpecifiedExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_CACHE, caching.getExistenceType());
- }
-
- public void testGetExpiry() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
-
- assertNull(entity.getCaching().getExpiry());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- assertNull(entity.getCaching().getExpiry());
-
- cacheAnnotation.setExpiry(Integer.valueOf(57));
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Integer.valueOf(57), entity.getCaching().getExpiry());
-
- typeResource.removeAnnotation(EclipseLink.CACHE);
- getJpaProject().synchronizeContextModel();
- assertNull(entity.getCaching().getExpiry());
- }
-
- public void testSetExpiry() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- caching.setExpiry(Integer.valueOf(58));
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(58), cacheAnnotation.getExpiry());
-
-
- caching.setExpiry(null);
- cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertNull(cacheAnnotation.getExpiry());
- }
-
- public void testSetExpiryUnsetsExpiryTimeOfDay() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- caching.addExpiryTimeOfDay();
- caching.getExpiryTimeOfDay().setHour(Integer.valueOf(5));
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(5), cacheAnnotation.getExpiryTimeOfDay().getHour());
-
- caching.setExpiry(Integer.valueOf(900));
-
- assertNull(caching.getExpiryTimeOfDay());
- assertNull(cacheAnnotation.getExpiryTimeOfDay());
- assertEquals(Integer.valueOf(900), cacheAnnotation.getExpiry());
- assertEquals(Integer.valueOf(900), caching.getExpiry());
- }
-
- public void testGetTimeOfDayExpiry() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertNull(caching.getExpiryTimeOfDay());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
-
- cacheAnnotation.addExpiryTimeOfDay();
- getJpaProject().synchronizeContextModel();
-
- assertNotNull(caching.getExpiryTimeOfDay());
- }
-
- public void testAddTimeOfDayExpiry() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertNull(caching.getExpiryTimeOfDay());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkTimeOfDay timeOfDayExpiry = caching.addExpiryTimeOfDay();
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertNotNull(cacheAnnotation.getExpiryTimeOfDay());
- assertNotNull(caching.getExpiryTimeOfDay());
- assertEquals(timeOfDayExpiry, caching.getExpiryTimeOfDay());
- }
-
- public void testRemoveTimeOfDayExpiry() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertNull(caching.getExpiryTimeOfDay());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.addExpiryTimeOfDay();
- getJpaProject().synchronizeContextModel();
-
- assertNotNull(caching.getExpiryTimeOfDay());
-
- caching.removeExpiryTimeOfDay();
- getJpaProject().synchronizeContextModel();
- assertNull(caching.getExpiryTimeOfDay());
- }
-
- public void testAddTimeOfDayExpiryUnsetsExpiry() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- caching.setExpiry(Integer.valueOf(800));
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(800), cacheAnnotation.getExpiry());
-
-
- caching.addExpiryTimeOfDay();
-
-
- assertNull(caching.getExpiry());
- assertNull(cacheAnnotation.getExpiry());
- assertNotNull(cacheAnnotation.getExpiryTimeOfDay());
- }
-
-
- public void testSetSpecifiedSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(100, caching.getSize());
-
- caching.setSpecifiedSize(new Integer(50));
-
-
- assertEquals(new Integer(50), entity.getCaching().getSpecifiedSize());
- assertEquals(50, entity.getCaching().getSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertEquals(new Integer(50), cacheAnnotation.getSize());
- }
-
- public void testGetSpecifiedSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaEclipseLinkEntity entity = (JavaEclipseLinkEntity) getJavaPersistentType().getMapping();
- JavaEclipseLinkCaching caching = entity.getCaching();
-
- assertEquals(100, caching.getSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCacheAnnotation cacheAnnotation = (EclipseLinkCacheAnnotation) typeResource.addAnnotation(EclipseLink.CACHE);
- cacheAnnotation.setSize(new Integer(50));
- getJpaProject().synchronizeContextModel();
-
- assertEquals(new Integer(50), cacheAnnotation.getSize());
- assertEquals(new Integer(50), entity.getCaching().getSpecifiedSize());
- assertEquals(50, entity.getCaching().getSize());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java
deleted file mode 100644
index cbf6b68c66..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConvertTests.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaConvertTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- }
- });
- }
-
-
- private ICompilationUnit createTestEntityWithConvert() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"class-instance\")").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndTypeConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"class-instance\")").append(CR);
- sb.append(" @TypeConverter");
- }
- });
- }
-
- public EclipseLinkJavaConvertTests(String name) {
- super(name);
- }
-
-
- public void testGetConverterName() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
-
- assertEquals(EclipseLinkConvert.NO_CONVERTER, eclipseLinkConvert.getConverterName());
- assertEquals(EclipseLinkConvert.NO_CONVERTER, eclipseLinkConvert.getDefaultConverterName());
- assertEquals(null, eclipseLinkConvert.getSpecifiedConverterName());
- }
-
- public void testGetConvertName2() throws Exception {
- createTestEntityWithConvert();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
-
- assertEquals(EclipseLinkConvert.CLASS_INSTANCE_CONVERTER, eclipseLinkConvert.getConverterName());
- }
-
- public void testSetSpecifiedConverterName() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- basicMapping.setConverter(EclipseLinkConvert.class);
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- assertEquals(null, eclipseLinkConvert.getSpecifiedConverterName());
-
- eclipseLinkConvert.setSpecifiedConverterName("foo");
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConvertAnnotation convertAnnotation = (EclipseLinkConvertAnnotation) attributeResource.getAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
-
- assertEquals("foo", convertAnnotation.getValue());
-
- eclipseLinkConvert.setSpecifiedConverterName(null);
- convertAnnotation = (EclipseLinkConvertAnnotation) attributeResource.getAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- assertNotNull(convertAnnotation);
- assertEquals(null, convertAnnotation.getValue());
- }
-
- public void testGetConverterNameUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithBasicMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
-
- assertNull(basicMapping.getConverter().getType());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- convert.setValue("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(EclipseLinkConvert.class, basicMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) basicMapping.getConverter()).getConverterName());
-
- attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(basicMapping.getConverter().getType());
- assertFalse(basicMapping.isDefault());
- assertSame(basicMapping, persistentAttribute.getMapping());
- }
-
-
- public void testGetConverter() throws Exception {
- createTestEntityWithConvertAndTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
-
- assertEquals(EclipseLinkTypeConverter.class, eclipseLinkConvert.getConverter().getType());
- }
-
- public void testSetConverter() throws Exception {
- createTestEntityWithConvert();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
-
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- eclipseLinkConvert.setConverter(EclipseLinkTypeConverter.class);
- assertEquals(EclipseLinkTypeConverter.class, eclipseLinkConvert.getConverter().getType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNotNull(attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME));
-
- eclipseLinkConvert.setConverter(EclipseLinkStructConverter.class);
- assertEquals(EclipseLinkStructConverter.class, eclipseLinkConvert.getConverter().getType());
- assertNotNull(attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME));
-
- eclipseLinkConvert.setConverter(null);
- assertEquals(null, eclipseLinkConvert.getConverter());
- assertNull(attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME));
-
- eclipseLinkConvert.setConverter(EclipseLinkStructConverter.class);
- assertEquals(EclipseLinkStructConverter.class, eclipseLinkConvert.getConverter().getType());
- assertNotNull(attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
-
-
- basicMapping.setConverter(null);
- assertNull(attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME));
-
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java
deleted file mode 100644
index 2446e0148a..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaConverterTests.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaConverterTests extends EclipseLinkContextModelTestCase
-{
-
-
- private ICompilationUnit createTestEntityWithConvertAndConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @Converter(name=\"foo\"");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndConverterClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @Converter(converterClass=Foo.class");
- }
- });
- }
-
- public EclipseLinkJavaConverterTests(String name) {
- super(name);
- }
-
-
- public void testGetName() throws Exception {
- createTestEntityWithConvertAndConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkCustomConverter converter = (EclipseLinkCustomConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithConvertAndConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkCustomConverter converter = (EclipseLinkCustomConverter) eclipseLinkConvert.getConverter();
- assertEquals("foo", converter.getName());
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConverterAnnotation converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
-
-
- converter.setName(null);
- assertEquals(null, converter.getName());
- converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getName());
-
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
- converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
- }
-
- public void testGetNameUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkCustomConverter converter = (EclipseLinkCustomConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConverterAnnotation converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setName("bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("bar", converter.getName());
-
- attributeResource.removeAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.addAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setName("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", eclipseLinkConvert.getConverter().getName());
- }
-
-
- public void testGetConverterClass() throws Exception {
- createTestEntityWithConvertAndConverterClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkCustomConverter converter = (EclipseLinkCustomConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getConverterClass());
- }
-
- public void testSetConverterClass() throws Exception {
- createTestEntityWithConvertAndConverterClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkCustomConverter converter = (EclipseLinkCustomConverter) eclipseLinkConvert.getConverter();
- assertEquals("Foo", converter.getConverterClass());
-
- converter.setConverterClass("Bar");
- assertEquals("Bar", converter.getConverterClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConverterAnnotation converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getConverterClass());
-
-
- converter.setConverterClass(null);
- assertEquals(null, converter.getConverterClass());
- converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getConverterClass());
-
-
- converter.setConverterClass("Bar");
- assertEquals("Bar", converter.getConverterClass());
- converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getConverterClass());
- }
-
- public void testGetConverterClassUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndConverterClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkCustomConverter converter = (EclipseLinkCustomConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getConverterClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConverterAnnotation converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setConverterClass("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", converter.getConverterClass());
-
- attributeResource.removeAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkConverterAnnotation) attributeResource.addAnnotation(EclipseLinkConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setConverterClass("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", ((EclipseLinkCustomConverter) eclipseLinkConvert.getConverter()).getConverterClass());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java
deleted file mode 100644
index f35c289fbb..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEmbeddableTests.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTracking;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomizer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkEmbeddable;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaEmbeddableTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEmbeddableWithConvertAndCustomizerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- sb.append(" @Customizer(Foo.class");
- }
- });
- }
-
- private ICompilationUnit createTestEmbeddableWithChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE, EclipseLink.CHANGE_TRACKING);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- sb.append(" @ChangeTracking").append(CR);
- }
- });
- }
-
- public EclipseLinkJavaEmbeddableTests(String name) {
- super(name);
- }
-
-
- public void testGetCustomizerClass() throws Exception {
- createTestEmbeddableWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkEmbeddable) getJavaPersistentType().getMapping()).getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testSetCustomizerClass() throws Exception {
- createTestEmbeddableWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkEmbeddable) getJavaPersistentType().getMapping()).getCustomizer();
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
-
-
- customizer.setSpecifiedCustomizerClass(null);
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals(null, customizerAnnotation);
-
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
- }
-
- public void testGetCustomizerClassUpdatesFromResourceModelChange() throws Exception {
- createTestEmbeddableWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkEmbeddable embeddable = (EclipseLinkEmbeddable) getJavaPersistentType().getMapping();
- EclipseLinkCustomizer customizer = embeddable.getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- customizerAnnotation.setValue("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation.setValue("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testGetChangeTracking() throws Exception {
- createTestEmbeddableWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEmbeddable embeddable = (EclipseLinkEmbeddable) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = embeddable.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change resource to ATTRIBUTE specifically, test context
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change resource to OBJECT specifically, test context
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change resource to DEFERRED specifically, test context
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change resource to AUTO specifically, test context
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove value from resource, test context
- resourceChangeTracking.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove annotation, text context
- typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertNull(contextChangeTracking.getSpecifiedType());
- }
-
- public void testSetChangeTracking() throws Exception {
- createTestEmbeddableWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEmbeddable embeddable = (EclipseLinkEmbeddable) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = embeddable.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to ATTRIBUTE specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change context to OBJECT specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change context to DEFERRED specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change context to null, test resource
-
- contextChangeTracking.setSpecifiedType(null);
-
- assertNull(typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME));
- assertNull(contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically (this time from no annotation), test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
- resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java
deleted file mode 100644
index 8ac6d21f96..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaEntityTests.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkMappingKeys;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTracking;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomizer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkReadOnly;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaEntityTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntity() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndCustomizerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append(" @Customizer(Foo.class");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CHANGE_TRACKING);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append(" @ChangeTracking").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@ReadOnly").append(CR);
- }
- });
- }
-
- public EclipseLinkJavaEntityTests(String name) {
- super(name);
- }
-
- public void testAttributeMappingKeyAllowed() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = (Entity) getJavaPersistentType().getMapping();
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.BASIC_COLLECTION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.TRANSFORMATION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.VARIABLE_ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- }
-
-
- public void testGetCustomizerClass() throws Exception {
- createTestEntityWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkEntity) getJavaPersistentType().getMapping()).getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testSetCustomizerClass() throws Exception {
- createTestEntityWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkEntity) getJavaPersistentType().getMapping()).getCustomizer();
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
-
-
- customizer.setSpecifiedCustomizerClass(null);
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals(null, customizerAnnotation);
-
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
- }
-
- public void testGetCustomizerClassUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkEntity entity = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkCustomizer customizer = entity.getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- customizerAnnotation.setValue("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation.setValue("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testGetChangeTracking() throws Exception {
- createTestEntityWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity entity = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = entity.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change resource to ATTRIBUTE specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change resource to OBJECT specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change resource to DEFERRED specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change resource to AUTO specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove value from resource, test context
-
- resourceChangeTracking.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove annotation, text context
-
- typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertNull(contextChangeTracking.getSpecifiedType());
- }
-
- public void testSetChangeTracking() throws Exception {
- createTestEntityWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity entity = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = entity.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to ATTRIBUTE specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change context to OBJECT specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change context to DEFERRED specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change context to null, test resource
-
- contextChangeTracking.setSpecifiedType(null);
-
- assertNull(typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME));
- assertNull(contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically (this time from no annotation), test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
- resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
- }
-
- public void testGetReadOnly() throws Exception {
- createTestEntityWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity mappedSuperclass = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(true, readOnly.isReadOnly());
- }
-
- public void testGetSpecifiedReadOnly() throws Exception {
- createTestEntityWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity mappedSuperclass = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
- }
-
- //TODO test inheriting a default readonly from you superclass
- public void testGetDefaultReadOnly() throws Exception {
- createTestEntityWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity mappedSuperclass = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(false, readOnly.isDefaultReadOnly());
- }
-
- public void testSetSpecifiedReadOnly() throws Exception {
- createTestEntityWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity mappedSuperclass = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(true, readOnly.isReadOnly());
-
- readOnly.setSpecifiedReadOnly(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertNull(readOnly.getSpecifiedReadOnly());//Boolean.FALSE and null really mean the same thing since there are only 2 states in the java resource model
-
- readOnly.setSpecifiedReadOnly(Boolean.TRUE);
- assertNotNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
-
- readOnly.setSpecifiedReadOnly(null);
- assertNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertNull(readOnly.getSpecifiedReadOnly());//Boolean.FALSE and null really mean the same thing since there are only 2 states in the java resource model
- }
-
- public void testSpecifiedReadOnlyUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity mappedSuperclass = (EclipseLinkEntity) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.removeAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(readOnly.getSpecifiedReadOnly());
- assertEquals(false, readOnly.isDefaultReadOnly());
-
- typeResource.addAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
- }
-
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java
deleted file mode 100644
index 74970ea236..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaIdMappingTests.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.TemporalConverter;
-import org.eclipse.jpt.jpa.core.context.TemporalType;
-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.TemporalAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkIdMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMutable;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkMutableAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaIdMappingTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithIdMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- }
- });
- }
-
-
- private ICompilationUnit createTestEntityWithConvert() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, EclipseLink.CONVERT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@Convert(\"class-instance\")").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableId() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, EclipseLink.MUTABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append("@Mutable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableIdDate() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, EclipseLink.MUTABLE, "java.util.Date");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append(" @Mutable").append(CR);
- sb.append(" private Date myDate;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- public EclipseLinkJavaIdMappingTests(String name) {
- super(name);
- }
-
-
- public void testGetConvert() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
-
- assertEquals(EclipseLinkConvert.class, idMapping.getConverter().getType());
- }
-
- public void testGetConvert2() throws Exception {
- createTestEntityWithConvert();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
-
- assertEquals(EclipseLinkConvert.class, idMapping.getConverter().getType());
- assertEquals(EclipseLinkConvert.CLASS_INSTANCE_CONVERTER, ((EclipseLinkConvert) idMapping.getConverter()).getConverterName());
- }
-
- public void testSetConvert() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
- assertNull(idMapping.getConverter().getType());
-
- idMapping.setConverter(TemporalConverter.class);
- ((TemporalConverter) idMapping.getConverter()).setTemporalType(TemporalType.TIME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.TemporalType.TIME, temporal.getValue());
-
- idMapping.setConverter(null);
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetConvertUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithIdMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- IdMapping idMapping = (IdMapping) persistentAttribute.getMapping();
-
- assertNull(idMapping.getConverter().getType());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- convert.setValue("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(EclipseLinkConvert.class, idMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) idMapping.getConverter()).getConverterName());
-
- attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(idMapping.getConverter().getType());
- assertFalse(idMapping.isDefault());
- assertSame(idMapping, persistentAttribute.getMapping());
- }
-
- public void testGetSpecifiedMutable() throws Exception {
- createTestEntityWithMutableId();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkIdMapping idMapping = (EclipseLinkIdMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = idMapping.getMutable();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- mutableAnnotation.setValue(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- mutableAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- mutableAnnotation.setValue(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.FALSE, mutable.getSpecifiedMutable());
-
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, mutable.getSpecifiedMutable());
-
- attributeResource.addAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
- }
-
- public void testSetSpecifiedMutable() throws Exception {
- createTestEntityWithMutableId();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkIdMapping idMapping = (EclipseLinkIdMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = idMapping.getMutable();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(null, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertEquals(null, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(null);
- mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(null, mutableAnnotation);
-
- mutable.setSpecifiedMutable(Boolean.FALSE);
- mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.FALSE, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, mutableAnnotation.getValue());
- }
-
- public void testIsDefaultMutable() throws Exception {
- createTestEntityWithMutableId();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkIdMapping idMapping = (EclipseLinkIdMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = idMapping.getMutable();
- assertTrue(mutable.isDefaultMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertTrue(mutable.isDefaultMutable());
-
- mutable.setSpecifiedMutable(Boolean.FALSE);
- assertTrue(mutable.isDefaultMutable());
-
- //set mutable default to false in the persistence unit properties, verify default in java still true since this is not a Date/Calendar
- (getPersistenceUnit()).getOptions().setTemporalMutable(Boolean.FALSE);
- assertTrue(mutable.isDefaultMutable());
- }
-
- public void testIsDefaultMutableForDate() throws Exception {
- createTestEntityWithMutableIdDate();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkIdMapping idMapping = (EclipseLinkIdMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = idMapping.getMutable();
- assertFalse(mutable.isDefaultMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertFalse(mutable.isDefaultMutable());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertFalse(mutable.isDefaultMutable());
-
- //set mutable default to false in the persistence unit properties, verify default in java still true since this is not a Date/Calendar
- (getPersistenceUnit()).getOptions().setTemporalMutable(Boolean.TRUE);
- assertTrue(mutable.isDefaultMutable());
-
- (getPersistenceUnit()).getOptions().setTemporalMutable(Boolean.FALSE);
- assertFalse(mutable.isDefaultMutable());
-
- (getPersistenceUnit()).getOptions().setTemporalMutable(null);
- assertFalse(mutable.isDefaultMutable());
- }
-
- public void testIsMutable() throws Exception {
- createTestEntityWithMutableId();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkIdMapping idMapping = (EclipseLinkIdMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = idMapping.getMutable();
- assertTrue(mutable.isMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertTrue(mutable.isMutable());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertTrue(mutable.isMutable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java
deleted file mode 100644
index fd7a5bb743..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToManyMappingTests.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkJoinFetch;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaManyToManyMappingTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithJoinFetchManyToMany() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, EclipseLink.JOIN_FETCH);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany").append(CR);
- sb.append("@JoinFetch").append(CR);
- }
- });
- }
-
- public EclipseLinkJavaManyToManyMappingTests(String name) {
- super(name);
- }
-
-
- public void testGetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to INNER specifically, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to OUTER, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // remove value from resource, test context
-
- joinFetchAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // remove annotation, text context
-
- attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertNull(contextJoinFetch.getValue());
- }
-
- public void testSetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to INNER specifically, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to OUTER, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // set context to null, test resource
-
- contextJoinFetch.setValue(null);
-
- assertNull(attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME));
- assertNull(contextJoinFetch.getValue());
-
- // change context to INNER specifically (this time from no annotation), test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
- joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java
deleted file mode 100644
index 3aa48ff3aa..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaManyToOneMappingTests.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkJoinFetch;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaManyToOneMappingTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithJoinFetchManyToOne() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, EclipseLink.JOIN_FETCH);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne").append(CR);
- sb.append("@JoinFetch").append(CR);
- }
- });
- }
-
- public EclipseLinkJavaManyToOneMappingTests(String name) {
- super(name);
- }
-
-
- public void testGetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchManyToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to INNER specifically, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to OUTER, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // remove value from resource, test context
-
- joinFetchAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // remove annotation, text context
-
- attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertNull(contextJoinFetch.getValue());
- }
-
- public void testSetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchManyToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to INNER specifically, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to OUTER, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // set context to null, test resource
-
- contextJoinFetch.setValue(null);
-
- assertNull(attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME));
- assertNull(contextJoinFetch.getValue());
-
- // change context to INNER specifically (this time from no annotation), test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
- joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java
deleted file mode 100644
index 4d15562e40..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaMappedSuperclassTests.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTracking;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomizer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkReadOnly;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaMappedSuperclassTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestMappedSuperclassWithReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- sb.append("@ReadOnly").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassWithConvertAndCustomizerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- sb.append(" @Customizer(Foo.class");
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassWithChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CHANGE_TRACKING);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- sb.append(" @ChangeTracking").append(CR);
- }
- });
- }
-
- public EclipseLinkJavaMappedSuperclassTests(String name) {
- super(name);
- }
-
-
- public void testGetReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(true, readOnly.isReadOnly());
- }
-
- public void testGetSpecifiedReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
- }
-
- //TODO test inheriting a default readonly from you superclass
- public void testGetDefaultReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(false, readOnly.isDefaultReadOnly());
- }
-
- public void testSetSpecifiedReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(true, readOnly.isReadOnly());
-
- readOnly.setSpecifiedReadOnly(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertNull(readOnly.getSpecifiedReadOnly());//Boolean.FALSE and null really mean the same thing since there are only 2 states in the java resource model
-
- readOnly.setSpecifiedReadOnly(Boolean.TRUE);
- assertNotNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
-
- readOnly.setSpecifiedReadOnly(null);
- assertNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertNull(readOnly.getSpecifiedReadOnly());//Boolean.FALSE and null really mean the same thing since there are only 2 states in the java resource model
- }
-
- public void testSpecifiedReadOnlyUpdatesFromResourceModelChange() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.removeAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(readOnly.getSpecifiedReadOnly());
- assertEquals(false, readOnly.isDefaultReadOnly());
-
- typeResource.addAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
- }
-
- public void testGetCustomizerClass() throws Exception {
- createTestMappedSuperclassWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping()).getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testSetCustomizerClass() throws Exception {
- createTestMappedSuperclassWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping()).getCustomizer();
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
-
-
- customizer.setSpecifiedCustomizerClass(null);
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals(null, customizerAnnotation);
-
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
- }
-
- public void testGetCustomizerClassUpdatesFromResourceModelChange() throws Exception {
- createTestMappedSuperclassWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkCustomizer customizer = mappedSuperclass.getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- customizerAnnotation.setValue("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation.setValue("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testGetChangeTracking() throws Exception {
- createTestMappedSuperclassWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = mappedSuperclass.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change resource to ATTRIBUTE specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change resource to OBJECT specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change resource to DEFERRED specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change resource to AUTO specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove value from resource, test context
-
- resourceChangeTracking.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove annotation, text context
-
- typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertNull(contextChangeTracking.getSpecifiedType());
- }
-
- public void testSetChangeTracking() throws Exception {
- createTestMappedSuperclassWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = mappedSuperclass.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to ATTRIBUTE specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change context to OBJECT specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change context to DEFERRED specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change context to null, test resource
-
- contextChangeTracking.setSpecifiedType(null);
-
- assertNull(typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME));
- assertNull(contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically (this time from no annotation), test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
- resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java
deleted file mode 100644
index bc40bcaa9e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaObjectTypeConverterTests.java
+++ /dev/null
@@ -1,644 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkConversionValue;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConversionValueAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaObjectTypeConverterTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithConvertAndObjectTypeConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.OBJECT_TYPE_CONVERTER, EclipseLink.CONVERSION_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @ObjectTypeConverter(name=\"foo\", defaultObjectValue=\"bar\")");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndDataType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @ObjectTypeConverter(dataType=Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndObjectType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @ObjectTypeConverter(objectType=Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndObjectTypeConverterConversionValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.OBJECT_TYPE_CONVERTER, EclipseLink.CONVERSION_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @ObjectTypeConverter(name=\"foo\", defaultObjectValue=\"bar\", conversionValues = @ConversionValue(dataValue=\"f\", objectValue=\"female\"))");
- }
- });
- }
-
- public EclipseLinkJavaObjectTypeConverterTests(String name) {
- super(name);
- }
-
-
- public void testGetName() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("foo", converter.getName());
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
-
-
- converter.setName(null);
- assertEquals(null, converter.getName());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getName());
-
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
- }
-
- public void testGetNameUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setName("bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("bar", converter.getName());
-
- attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setName("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", eclipseLinkConvert.getConverter().getName());
- }
-
- public void testGetDataType() throws Exception {
- createTestEntityWithConvertAndDataType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getDataType());
- }
-
- public void testSetDataType() throws Exception {
- createTestEntityWithConvertAndDataType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("Foo", converter.getDataType());
-
- converter.setDataType("Bar");
- assertEquals("Bar", converter.getDataType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getDataType());
-
-
- converter.setDataType(null);
- assertEquals(null, converter.getDataType());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getDataType());
-
-
- converter.setDataType("Bar");
- assertEquals("Bar", converter.getDataType());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getDataType());
- }
-
- public void testGetDataTypeUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndDataType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getDataType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setDataType("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", converter.getDataType());
-
- attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setDataType("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", ((EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter()).getDataType());
- }
-
- public void testGetObjectType() throws Exception {
- createTestEntityWithConvertAndObjectType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getObjectType());
- }
-
- public void testSetObjectType() throws Exception {
- createTestEntityWithConvertAndObjectType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("Foo", converter.getObjectType());
-
- converter.setObjectType("Bar");
- assertEquals("Bar", converter.getObjectType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getObjectType());
-
-
- converter.setObjectType(null);
- assertEquals(null, converter.getObjectType());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getObjectType());
-
-
- converter.setObjectType("Bar");
- assertEquals("Bar", converter.getObjectType());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getObjectType());
- }
-
- public void testGetObjectTypeUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndObjectType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getObjectType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setObjectType("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", converter.getObjectType());
-
- attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setObjectType("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", ((EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter()).getObjectType());
- }
-
-
- public void testAddConversionValue() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
-
- EclipseLinkConversionValue conversionValue = converter.addConversionValue(0);
- conversionValue.setDataValue("F");
- conversionValue.setObjectValue("female");
-
- ListIterator<EclipseLinkConversionValueAnnotation> resourceConversionValues = converterAnnotation.conversionValues();
- EclipseLinkConversionValueAnnotation resourceConversionValue = resourceConversionValues.next();
- assertEquals("F", resourceConversionValue.getDataValue());
- assertEquals("female", resourceConversionValue.getObjectValue());
-
- EclipseLinkConversionValue conversionValue2 = converter.addConversionValue(0);
- conversionValue2.setDataValue("M");
- conversionValue2.setObjectValue("male");
-
- resourceConversionValues = converterAnnotation.conversionValues();
- resourceConversionValue = resourceConversionValues.next();
- assertEquals("M", resourceConversionValue.getDataValue());
- assertEquals("male", resourceConversionValue.getObjectValue());
- resourceConversionValue = resourceConversionValues.next();
- assertEquals("F", resourceConversionValue.getDataValue());
- assertEquals("female", resourceConversionValue.getObjectValue());
-
- EclipseLinkConversionValue conversionValue3 = converter.addConversionValue(1);
- conversionValue3.setDataValue("O");
- conversionValue3.setObjectValue("male");
-
- resourceConversionValues = converterAnnotation.conversionValues();
- resourceConversionValue = resourceConversionValues.next();
- assertEquals("M", resourceConversionValue.getDataValue());
- assertEquals("male", resourceConversionValue.getObjectValue());
- resourceConversionValue = resourceConversionValues.next();
- assertEquals("O", resourceConversionValue.getDataValue());
- assertEquals("male", resourceConversionValue.getObjectValue());
- resourceConversionValue = resourceConversionValues.next();
- assertEquals("F", resourceConversionValue.getDataValue());
- assertEquals("female", resourceConversionValue.getObjectValue());
-
- ListIterator<EclipseLinkConversionValue> conversionValues = converter.conversionValues();
- assertEquals(conversionValue2, conversionValues.next());
- assertEquals(conversionValue3, conversionValues.next());
- assertEquals(conversionValue, conversionValues.next());
-
- conversionValues = converter.conversionValues();
- assertEquals("M", conversionValues.next().getDataValue());
- assertEquals("O", conversionValues.next().getDataValue());
- assertEquals("F", conversionValues.next().getDataValue());
- }
-
- public void testRemoveConversionValue() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
-
- converter.addConversionValue(0).setDataValue("F");
- converter.addConversionValue(1).setDataValue("M");
- converter.addConversionValue(2).setDataValue("O");
-
- ListIterator<EclipseLinkConversionValueAnnotation> resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(3, CollectionTools.size(resourceConversionValues));
-
- converter.removeConversionValue(0);
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(2, CollectionTools.size(resourceConversionValues));
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals("M", resourceConversionValues.next().getDataValue());
- assertEquals("O", resourceConversionValues.next().getDataValue());
-
- converter.removeConversionValue(0);
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(1, CollectionTools.size(resourceConversionValues));
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals("O", resourceConversionValues.next().getDataValue());
-
- converter.removeConversionValue(0);
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(0, CollectionTools.size(resourceConversionValues));
- }
-
- public void testMoveConversionValue() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
-
- converter.addConversionValue(0).setDataValue("F");
- converter.addConversionValue(1).setDataValue("M");
- converter.addConversionValue(2).setDataValue("O");
-
- ListIterator<EclipseLinkConversionValueAnnotation> resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(3, CollectionTools.size(resourceConversionValues));
-
- converter.moveConversionValue(2,0);
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(3, CollectionTools.size(resourceConversionValues));
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals("M", resourceConversionValues.next().getDataValue());
- assertEquals("O", resourceConversionValues.next().getDataValue());
- assertEquals("F", resourceConversionValues.next().getDataValue());
-
- converter.moveConversionValue(0,1);
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals(3, CollectionTools.size(resourceConversionValues));
- resourceConversionValues = converterAnnotation.conversionValues();
- assertEquals("O", resourceConversionValues.next().getDataValue());
- assertEquals("M", resourceConversionValues.next().getDataValue());
- assertEquals("F", resourceConversionValues.next().getDataValue());
- }
-
- public void testUpdateConversionValues() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
-
- converterAnnotation.addConversionValue(0).setDataValue("F");
- converterAnnotation.addConversionValue(1).setDataValue("M");
- converterAnnotation.addConversionValue(2).setDataValue("O");
- getJpaProject().synchronizeContextModel();
-
- ListIterator<EclipseLinkConversionValue> conversionValues = converter.conversionValues();
- assertEquals("F", conversionValues.next().getDataValue());
- assertEquals("M", conversionValues.next().getDataValue());
- assertEquals("O", conversionValues.next().getDataValue());
- assertFalse(conversionValues.hasNext());
-
- converterAnnotation.moveConversionValue(2, 0);
- getJpaProject().synchronizeContextModel();
- conversionValues = converter.conversionValues();
- assertEquals("M", conversionValues.next().getDataValue());
- assertEquals("O", conversionValues.next().getDataValue());
- assertEquals("F", conversionValues.next().getDataValue());
- assertFalse(conversionValues.hasNext());
-
- converterAnnotation.moveConversionValue(0, 1);
- getJpaProject().synchronizeContextModel();
- conversionValues = converter.conversionValues();
- assertEquals("O", conversionValues.next().getDataValue());
- assertEquals("M", conversionValues.next().getDataValue());
- assertEquals("F", conversionValues.next().getDataValue());
- assertFalse(conversionValues.hasNext());
-
- converterAnnotation.removeConversionValue(1);
- getJpaProject().synchronizeContextModel();
- conversionValues = converter.conversionValues();
- assertEquals("O", conversionValues.next().getDataValue());
- assertEquals("F", conversionValues.next().getDataValue());
- assertFalse(conversionValues.hasNext());
-
- converterAnnotation.removeConversionValue(1);
- getJpaProject().synchronizeContextModel();
- conversionValues = converter.conversionValues();
- assertEquals("O", conversionValues.next().getDataValue());
- assertFalse(conversionValues.hasNext());
-
- converterAnnotation.removeConversionValue(0);
- getJpaProject().synchronizeContextModel();
- conversionValues = converter.conversionValues();
- assertFalse(conversionValues.hasNext());
- }
-
- public void testConversionValuesSize() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
-
- assertEquals(0, converter.conversionValuesSize());
-
- converterAnnotation.addConversionValue(0).setDataValue("F");
- converterAnnotation.addConversionValue(1).setDataValue("M");
- converterAnnotation.addConversionValue(2).setDataValue("O");
-
- this.getJpaProject().synchronizeContextModel();
- assertEquals(3, converter.conversionValuesSize());
- }
-
-
- public void testGetDefaultObjectValue() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("bar", converter.getDefaultObjectValue());
- }
-
- public void testSetDefaultObjectValue() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("bar", converter.getDefaultObjectValue());
-
- converter.setDefaultObjectValue("baz");
- assertEquals("baz", converter.getDefaultObjectValue());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("baz", converterAnnotation.getDefaultObjectValue());
-
-
- converter.setDefaultObjectValue(null);
- assertEquals(null, converter.getDefaultObjectValue());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getDefaultObjectValue());
-
-
- converter.setDefaultObjectValue("bar");
- assertEquals("bar", converter.getDefaultObjectValue());
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getDefaultObjectValue());
- }
-
- public void testGetDefaultObjectValueUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("bar", converter.getDefaultObjectValue());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkObjectTypeConverterAnnotation converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setDefaultObjectValue("baz");
- getJpaProject().synchronizeContextModel();
- assertEquals("baz", converter.getDefaultObjectValue());
-
- attributeResource.removeAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setDefaultObjectValue("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", ((EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter()).getDefaultObjectValue());
- }
-
- public void testInitializeConversionValues() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverterConversionValue();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals(1, converter.conversionValuesSize());
- assertEquals("f", converter.conversionValues().next().getDataValue());
- assertEquals("female", converter.conversionValues().next().getObjectValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java
deleted file mode 100644
index 34217a7c21..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java
+++ /dev/null
@@ -1,579 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-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.OneToManyAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetch;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToManyRelationship;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkPrivateOwned;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkPrivateOwnedAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaOneToManyMappingTests extends EclipseLinkContextModelTestCase
-{
- private ICompilationUnit createTestEntityWithOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithPrivateOwnedOneToMany() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, EclipseLink.PRIVATE_OWNED);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany").append(CR);
- sb.append("@PrivateOwned").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithJoinFetchOneToMany() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, EclipseLink.JOIN_FETCH);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany").append(CR);
- sb.append("@JoinFetch").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithDefaultOneToMany() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
-
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("implements java.io.Serializable");
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("private java.util.Collection<" + TYPE_NAME + "> myTypes;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- public EclipseLinkJavaOneToManyMappingTests(String name) {
- super(name);
- }
-
-
- public void testGetPrivateOwned() throws Exception {
- createTestEntityWithPrivateOwnedOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- EclipseLinkPrivateOwned privateOwnable = oneToManyMapping.getPrivateOwned();
- assertEquals(true, privateOwnable.isPrivateOwned());
- }
-
- public void testSetPrivateOwned() throws Exception {
- createTestEntityWithPrivateOwnedOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- EclipseLinkPrivateOwned privateOwnable = oneToManyMapping.getPrivateOwned();
- assertEquals(true, privateOwnable.isPrivateOwned());
-
- privateOwnable.setPrivateOwned(false);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(false, privateOwnable.isPrivateOwned());
-
- privateOwnable.setPrivateOwned(true);
- assertNotNull(attributeResource.getAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(true, privateOwnable.isPrivateOwned());
- }
-
- public void testPrivateOwnedUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithPrivateOwnedOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- EclipseLinkPrivateOwned privateOwnable = oneToManyMapping.getPrivateOwned();
- assertEquals(true, privateOwnable.isPrivateOwned());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(false, privateOwnable.isPrivateOwned());
-
- attributeResource.addAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(true, privateOwnable.isPrivateOwned());
- }
-
- public void testGetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to INNER specifically, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to OUTER, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // remove value from resource, test context
-
- joinFetchAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // remove annotation, text context
-
- attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertNull(contextJoinFetch.getValue());
- }
-
- public void testSetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to INNER specifically, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to OUTER, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // set context to null, test resource
-
- contextJoinFetch.setValue(null);
-
- assertNull(attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME));
- assertNull(contextJoinFetch.getValue());
-
- // change context to INNER specifically (this time from no annotation), test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
- joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- OneToManyAnnotation annotation = (OneToManyAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_MANY);
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToManyMapping mapping = (EclipseLinkOneToManyMapping) contextAttribute.getMapping();
- EclipseLinkOneToManyRelationship rel = mapping.getRelationship();
-
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinColumn();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToMappedBy();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinTable();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- OneToManyAnnotation annotation = (OneToManyAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_MANY);
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToManyMapping mapping = (EclipseLinkOneToManyMapping) contextAttribute.getMapping();
- EclipseLinkOneToManyRelationship rel = mapping.getRelationship();
-
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- annotation.setMappedBy("foo");
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceAttribute.addAnnotation(JPA.JOIN_TABLE);
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceAttribute.addAnnotation(JPA.JOIN_COLUMN);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- annotation.setMappedBy(null);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceAttribute.removeAnnotation(JPA.JOIN_TABLE);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceAttribute.removeAnnotation(JPA.JOIN_COLUMN);
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testDefaultOneToMany() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, attributes.next().getDefaultMappingKey());
- }
-
- public void testDefaultOneToManySetFetch() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setSpecifiedFetch(FetchType.LAZY);
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(FetchType.LAZY, specifiedOneToManyMapping.getFetch());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.FetchType.LAZY, annotation.getFetch());
- }
-
- public void testDefaultOneToManySetTargetEntity() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.setSpecifiedTargetEntity("Foo");
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals("Foo", specifiedOneToManyMapping.getSpecifiedTargetEntity());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals("Foo", annotation.getTargetEntity());
- }
-
- public void testDefaultOneToManySetMappedBy() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("Foo");
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals("Foo", specifiedOneToManyMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals("Foo", annotation.getMappedBy());
- }
-
- public void testDefaultOneToManySetCascadeAll() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.getCascade().setAll(true);
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToManyMapping.getCascade().isAll());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeAll());
- }
-
- public void testDefaultOneToManySetCascadeMerge() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.getCascade().setMerge(true);
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToManyMapping.getCascade().isMerge());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeMerge());
- }
-
- public void testDefaultOneToManySetCascadePersist() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.getCascade().setPersist(true);
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToManyMapping.getCascade().isPersist());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadePersist());
- }
-
- public void testDefaultOneToManySetCascadeRefresh() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.getCascade().setRefresh(true);
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToManyMapping.getCascade().isRefresh());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertEquals(true, annotation.isCascadeRefresh());
- }
-
- public void testDefaultOneToManySetCascadeRemove() throws Exception {
- createTestEntityWithDefaultOneToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getMapping();
- oneToManyMapping.getCascade().setRemove(true);
-
- EclipseLinkOneToManyMapping specifiedOneToManyMapping = (EclipseLinkOneToManyMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToManyMapping.getCascade().isRemove());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToManyAnnotation annotation =
- (OneToManyAnnotation) attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeRemove());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java
deleted file mode 100644
index 38894d1d1c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-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.eclipselink.core.context.EclipseLinkJoinFetch;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToOneMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkPrivateOwned;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkPrivateOwnedAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaOneToOneMappingTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithPrivateOwnedOneToOne() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, EclipseLink.PRIVATE_OWNED);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne").append(CR);
- sb.append("@PrivateOwned").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithJoinFetchOneToOne() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, EclipseLink.JOIN_FETCH);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne").append(CR);
- sb.append("@JoinFetch").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithDefaultOneToOne() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
-
- @Override
- public void appendExtendsImplementsTo(StringBuilder sb) {
- sb.append("implements java.io.Serializable");
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("private " + TYPE_NAME + " myType;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- public EclipseLinkJavaOneToOneMappingTests(String name) {
- super(name);
- }
-
-
- public void testGetPrivateOwned() throws Exception {
- createTestEntityWithPrivateOwnedOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- EclipseLinkPrivateOwned privateOwnable = oneToOneMapping.getPrivateOwned();
- assertEquals(true, privateOwnable.isPrivateOwned());
- }
-
- public void testSetPrivateOwned() throws Exception {
- createTestEntityWithPrivateOwnedOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- EclipseLinkPrivateOwned privateOwnable = oneToOneMapping.getPrivateOwned();
- assertEquals(true, privateOwnable.isPrivateOwned());
-
- privateOwnable.setPrivateOwned(false);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(false, privateOwnable.isPrivateOwned());
-
- privateOwnable.setPrivateOwned(true);
- assertNotNull(attributeResource.getAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(true, privateOwnable.isPrivateOwned());
- }
-
- public void testPrivateOwnedUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithPrivateOwnedOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- EclipseLinkPrivateOwned privateOwnable = oneToOneMapping.getPrivateOwned();
- assertEquals(true, privateOwnable.isPrivateOwned());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(false, privateOwnable.isPrivateOwned());
-
- attributeResource.addAnnotation(EclipseLinkPrivateOwnedAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(true, privateOwnable.isPrivateOwned());
- }
-
- public void testGetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to INNER specifically, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to OUTER, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // remove value from resource, test context
-
- joinFetchAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // remove annotation, text context
-
- attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertNull(contextJoinFetch.getValue());
- }
-
- public void testSetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to INNER specifically, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to OUTER, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // set context to null, test resource
-
- contextJoinFetch.setValue(null);
-
- assertNull(attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME));
- assertNull(contextJoinFetch.getValue());
-
- // change context to INNER specifically (this time from no annotation), test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
- joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
- }
-
- public void testDefaultOneToOne() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, attributes.next().getDefaultMappingKey());
- }
-
- public void testDefaultOneToOneSetFetch() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.setSpecifiedFetch(FetchType.LAZY);
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(FetchType.LAZY, specifiedOneToOneMapping.getFetch());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.FetchType.LAZY, annotation.getFetch());
- }
-
- public void testDefaultOneToOneSetTargetEntity() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.setSpecifiedTargetEntity("Foo");
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals("Foo", specifiedOneToOneMapping.getSpecifiedTargetEntity());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals("Foo", annotation.getTargetEntity());
- }
-
- public void testDefaultOneToOneSetMappedBy() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("Foo");
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals("Foo", specifiedOneToOneMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals("Foo", annotation.getMappedBy());
- }
-
- public void testDefaultOneToOneSetCascadeAll() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.getCascade().setAll(true);
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToOneMapping.getCascade().isAll());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeAll());
- }
-
- public void testDefaultOneToOneSetCascadeMerge() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.getCascade().setMerge(true);
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToOneMapping.getCascade().isMerge());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeMerge());
- }
-
- public void testDefaultOneToOneSetCascadePersist() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.getCascade().setPersist(true);
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToOneMapping.getCascade().isPersist());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadePersist());
- }
-
- public void testDefaultOneToOneSetCascadeRefresh() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.getCascade().setRefresh(true);
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToOneMapping.getCascade().isRefresh());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeRefresh());
- }
-
- public void testDefaultOneToOneSetCascadeRemove() throws Exception {
- createTestEntityWithDefaultOneToOne();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<JavaPersistentAttribute> attributes = getJavaPersistentType().attributes();
- JavaPersistentAttribute persistentAttribute = attributes.next();
- assertTrue(persistentAttribute.getMapping().isDefault());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getDefaultMappingKey());
-
- EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getMapping();
- oneToOneMapping.getCascade().setRemove(true);
-
- EclipseLinkOneToOneMapping specifiedOneToOneMapping = (EclipseLinkOneToOneMapping) getJavaPersistentType().attributes().next().getMapping();
- assertEquals(true, specifiedOneToOneMapping.getCascade().isRemove());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToOneAnnotation annotation =
- (OneToOneAnnotation) attributeResource.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(annotation);
- assertEquals(true, annotation.isCascadeRemove());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java
deleted file mode 100644
index 6cc38836a7..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaStructConverterTests.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaStructConverterTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithConvertAndStructConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.STRUCT_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @StructConverter(name=\"foo\"");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndStructConverterClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.STRUCT_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @StructConverter(converter=\"Foo\"");
- }
- });
- }
-
- public EclipseLinkJavaStructConverterTests(String name) {
- super(name);
- }
-
-
- public void testGetName() throws Exception {
- createTestEntityWithConvertAndStructConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkStructConverter converter = (EclipseLinkStructConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithConvertAndStructConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkStructConverter converter = (EclipseLinkStructConverter) eclipseLinkConvert.getConverter();
- assertEquals("foo", converter.getName());
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkStructConverterAnnotation converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
-
-
- converter.setName(null);
- assertEquals(null, converter.getName());
- converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getName());
-
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
- converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
- }
-
- public void testGetNameUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndStructConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkStructConverter converter = (EclipseLinkStructConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkStructConverterAnnotation converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setName("bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("bar", converter.getName());
-
- attributeResource.removeAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.addAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setName("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", eclipseLinkConvert.getConverter().getName());
- }
-
-
- public void testGetConverterClass() throws Exception {
- createTestEntityWithConvertAndStructConverterClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkStructConverter converter = (EclipseLinkStructConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getConverterClass());
- }
-
- public void testSetConverterClass() throws Exception {
- createTestEntityWithConvertAndStructConverterClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkStructConverter converter = (EclipseLinkStructConverter) eclipseLinkConvert.getConverter();
- assertEquals("Foo", converter.getConverterClass());
-
- converter.setConverterClass("Bar");
- assertEquals("Bar", converter.getConverterClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkStructConverterAnnotation converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getConverter());
-
-
- converter.setConverterClass(null);
- assertEquals(null, converter.getConverterClass());
- converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getConverter());
-
-
- converter.setConverterClass("Bar");
- assertEquals("Bar", converter.getConverterClass());
- converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getConverter());
- }
-
- public void testGetConverterClassUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndStructConverterClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkStructConverter converter = (EclipseLinkStructConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getConverterClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkStructConverterAnnotation converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setConverter("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", converter.getConverterClass());
-
- attributeResource.removeAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkStructConverterAnnotation) attributeResource.addAnnotation(EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setConverter("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", ((EclipseLinkStructConverter) eclipseLinkConvert.getConverter()).getConverterClass());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java
deleted file mode 100644
index 93769d3ec7..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaTypeConverterTests.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-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.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaTypeConverterTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithConvertAndTypeConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @TypeConverter(name=\"foo\"");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndDataType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @TypeConverter(dataType=Foo.class");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithConvertAndObjectType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @TypeConverter(objectType=Foo.class");
- }
- });
- }
-
- public EclipseLinkJavaTypeConverterTests(String name) {
- super(name);
- }
-
-
- public void testGetName() throws Exception {
- createTestEntityWithConvertAndTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
- }
-
- public void testSetName() throws Exception {
- createTestEntityWithConvertAndTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("foo", converter.getName());
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
-
-
- converter.setName(null);
- assertEquals(null, converter.getName());
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getName());
-
-
- converter.setName("bar");
- assertEquals("bar", converter.getName());
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("bar", converterAnnotation.getName());
- }
-
- public void testGetNameUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndTypeConverter();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("foo", converter.getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setName("bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("bar", converter.getName());
-
- attributeResource.removeAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setName("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", eclipseLinkConvert.getConverter().getName());
- }
-
- public void testGetDataType() throws Exception {
- createTestEntityWithConvertAndDataType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getDataType());
- }
-
- public void testSetDataType() throws Exception {
- createTestEntityWithConvertAndDataType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("Foo", converter.getDataType());
-
- converter.setDataType("Bar");
- assertEquals("Bar", converter.getDataType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getDataType());
-
-
- converter.setDataType(null);
- assertEquals(null, converter.getDataType());
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getDataType());
-
-
- converter.setDataType("Bar");
- assertEquals("Bar", converter.getDataType());
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getDataType());
- }
-
- public void testGetDataTypeUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndDataType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getDataType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setDataType("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", converter.getDataType());
-
- attributeResource.removeAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setDataType("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", ((EclipseLinkTypeConverter) eclipseLinkConvert.getConverter()).getDataType());
- }
-
- public void testGetObjectType() throws Exception {
- createTestEntityWithConvertAndObjectType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getObjectType());
- }
-
- public void testSetObjectType() throws Exception {
- createTestEntityWithConvertAndObjectType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
- assertEquals("Foo", converter.getObjectType());
-
- converter.setObjectType("Bar");
- assertEquals("Bar", converter.getObjectType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getObjectType());
-
-
- converter.setObjectType(null);
- assertEquals(null, converter.getObjectType());
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals(null, converterAnnotation.getObjectType());
-
-
- converter.setObjectType("Bar");
- assertEquals("Bar", converter.getObjectType());
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", converterAnnotation.getObjectType());
- }
-
- public void testGetObjectTypeUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithConvertAndObjectType();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- BasicMapping basicMapping = (BasicMapping) persistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) basicMapping.getConverter();
- EclipseLinkTypeConverter converter = (EclipseLinkTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals("Foo", converter.getObjectType());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkTypeConverterAnnotation converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- converterAnnotation.setObjectType("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", converter.getObjectType());
-
- attributeResource.removeAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, eclipseLinkConvert.getConverter());
-
- converterAnnotation = (EclipseLinkTypeConverterAnnotation) attributeResource.addAnnotation(EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNotNull(eclipseLinkConvert.getConverter());
-
- converterAnnotation.setObjectType("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", ((EclipseLinkTypeConverter) eclipseLinkConvert.getConverter()).getObjectType());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java
deleted file mode 100644
index 61c98c5e23..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLinkJavaVersionMappingTests.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.TemporalConverter;
-import org.eclipse.jpt.jpa.core.context.TemporalType;
-import org.eclipse.jpt.jpa.core.context.VersionMapping;
-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.TemporalAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMutable;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkVersionMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkMutableAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLinkJavaVersionMappingTests extends EclipseLinkContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithVersionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- }
- });
- }
-
-
- private ICompilationUnit createTestEntityWithConvert() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION, EclipseLink.CONVERT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- sb.append("@Convert(\"class-instance\")").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableVersion() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION, EclipseLink.MUTABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- sb.append("@Mutable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableVersionDate() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION, EclipseLink.MUTABLE, "java.util.Date");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- sb.append(" @Mutable").append(CR);
- sb.append(" private Date myDate;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- public EclipseLinkJavaVersionMappingTests(String name) {
- super(name);
- }
-
- public void testGetConvert() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
-
- assertEquals(EclipseLinkConvert.class, versionMapping.getConverter().getType());
- }
-
- public void testGetConvert2() throws Exception {
- createTestEntityWithConvert();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
-
- assertEquals(EclipseLinkConvert.class, versionMapping.getConverter().getType());
- assertEquals(EclipseLinkConvert.CLASS_INSTANCE_CONVERTER, ((EclipseLinkConvert) versionMapping.getConverter()).getConverterName());
- }
-
- public void testSetConvert() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
- assertNull(versionMapping.getConverter().getType());
-
- versionMapping.setConverter(TemporalConverter.class);
- ((TemporalConverter) versionMapping.getConverter()).setTemporalType(TemporalType.TIME);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- TemporalAnnotation temporal = (TemporalAnnotation) attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.TemporalType.TIME, temporal.getValue());
-
- versionMapping.setConverter(null);
- assertNull(attributeResource.getAnnotation(TemporalAnnotation.ANNOTATION_NAME));
- }
-
- public void testGetConvertUpdatesFromResourceModelChange() throws Exception {
- createTestEntityWithVersionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- VersionMapping versionMapping = (VersionMapping) persistentAttribute.getMapping();
-
- assertNull(versionMapping.getConverter().getType());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.addAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- convert.setValue("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(EclipseLinkConvert.class, versionMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) versionMapping.getConverter()).getConverterName());
-
- attributeResource.removeAnnotation(EclipseLinkConvertAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(versionMapping.getConverter().getType());
- assertFalse(versionMapping.isDefault());
- assertSame(versionMapping, persistentAttribute.getMapping());
- }
-
- public void testGetSpecifiedMutable() throws Exception {
- createTestEntityWithMutableVersion();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkVersionMapping versionMapping = (EclipseLinkVersionMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = versionMapping.getMutable();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- mutableAnnotation.setValue(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- mutableAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- mutableAnnotation.setValue(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.FALSE, mutable.getSpecifiedMutable());
-
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, mutable.getSpecifiedMutable());
-
- attributeResource.addAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
- }
-
- public void testSetSpecifiedMutable() throws Exception {
- createTestEntityWithMutableVersion();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkVersionMapping versionMapping = (EclipseLinkVersionMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = versionMapping.getMutable();
- assertEquals(Boolean.TRUE, mutable.getSpecifiedMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(null, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertEquals(null, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(null);
- mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(null, mutableAnnotation);
-
- mutable.setSpecifiedMutable(Boolean.FALSE);
- mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertEquals(Boolean.FALSE, mutableAnnotation.getValue());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, mutableAnnotation.getValue());
- }
-
- public void testIsDefaultMutable() throws Exception {
- createTestEntityWithMutableVersion();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkVersionMapping versionMapping = (EclipseLinkVersionMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = versionMapping.getMutable();
- assertTrue(mutable.isDefaultMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertTrue(mutable.isDefaultMutable());
-
- mutable.setSpecifiedMutable(Boolean.FALSE);
- assertTrue(mutable.isDefaultMutable());
-
- //set mutable default to false in the persistence unit properties, verify default in java still true since this is not a Date/Calendar
- (getPersistenceUnit()).getOptions().setTemporalMutable(Boolean.FALSE);
- assertTrue(mutable.isDefaultMutable());
- }
-
- public void testIsDefaultMutableForDate() throws Exception {
- createTestEntityWithMutableVersionDate();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkVersionMapping versionMapping = (EclipseLinkVersionMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = versionMapping.getMutable();
- assertFalse(mutable.isDefaultMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertFalse(mutable.isDefaultMutable());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertFalse(mutable.isDefaultMutable());
-
- //set mutable default to false in the persistence unit properties, verify default in java still true since this is not a Date/Calendar
- (getPersistenceUnit()).getOptions().setTemporalMutable(Boolean.TRUE);
- assertTrue(mutable.isDefaultMutable());
-
- (getPersistenceUnit()).getOptions().setTemporalMutable(Boolean.FALSE);
- assertFalse(mutable.isDefaultMutable());
-
- (getPersistenceUnit()).getOptions().setTemporalMutable(null);
- assertFalse(mutable.isDefaultMutable());
- }
-
- public void testIsMutable() throws Exception {
- createTestEntityWithMutableVersion();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkVersionMapping versionMapping = (EclipseLinkVersionMapping) persistentAttribute.getMapping();
- EclipseLinkMutable mutable = versionMapping.getMutable();
- assertTrue(mutable.isMutable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- attributeResource.removeAnnotation(EclipseLinkMutableAnnotation.ANNOTATION_NAME);
- assertTrue(mutable.isMutable());
-
- mutable.setSpecifiedMutable(Boolean.TRUE);
- assertTrue(mutable.isMutable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java
deleted file mode 100644
index cbf3a302e1..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/JptEclipseLinkCoreJavaContextModelTests.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.java;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptEclipseLinkCoreJavaContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreJavaContextModelTests.class.getName());
- suite.addTestSuite(EclipseLinkJavaBasicMappingTests.class);
- suite.addTestSuite(EclipseLinkJavaCachingTests.class);
- suite.addTestSuite(EclipseLinkJavaConverterTests.class);
- suite.addTestSuite(EclipseLinkJavaConvertTests.class);
- suite.addTestSuite(EclipseLinkJavaEmbeddableTests.class);
- suite.addTestSuite(EclipseLinkJavaEntityTests.class);
- suite.addTestSuite(EclipseLinkJavaIdMappingTests.class);
- suite.addTestSuite(EclipseLinkJavaManyToManyMappingTests.class);
- suite.addTestSuite(EclipseLinkJavaManyToOneMappingTests.class);
- suite.addTestSuite(EclipseLinkJavaMappedSuperclassTests.class);
- suite.addTestSuite(EclipseLinkJavaObjectTypeConverterTests.class);
- suite.addTestSuite(EclipseLinkJavaOneToManyMappingTests.class);
- suite.addTestSuite(EclipseLinkJavaOneToOneMappingTests.class);
- suite.addTestSuite(EclipseLinkJavaStructConverterTests.class);
- suite.addTestSuite(EclipseLinkJavaTypeConverterTests.class);
- suite.addTestSuite(EclipseLinkJavaVersionMappingTests.class);
- return suite;
- }
-
- private JptEclipseLinkCoreJavaContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkEntityMappingsTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkEntityMappingsTests.java
deleted file mode 100644
index e0a4143734..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkEntityMappingsTests.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkEntityMappingsTests extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkEntityMappingsTests(String name) {
- super(name);
- }
-
-
- public void testUpdateCustomConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceEntityMappings.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceEntityMappings.getConverters().add(resourceConverter);
- resourceConverter.setClassName("Foo");
- resourceConverter.setName("myConverter");
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, resourceEntityMappings.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlConverter resourceConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceEntityMappings.getConverters().add(0, resourceConverter2);
- resourceConverter2.setClassName("Foo2");
- resourceConverter2.setName("myConverter2");
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, resourceEntityMappings.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntityMappings.getConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, resourceEntityMappings.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, resourceEntityMappings.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getConverters().remove(resourceConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyCustomConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceEntityMappings.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter(0);
- contextConverter.setConverterClass("Foo");
- contextConverter.setName("myConverter");
-
- assertEquals(1, resourceEntityMappings.getConverters().size());
- assertEquals("Foo", resourceEntityMappings.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceEntityMappings.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter(0);
- contextConverter2.setConverterClass("Foo2");
- contextConverter2.setName("myConverter2");
-
- assertEquals(2, resourceEntityMappings.getConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceEntityMappings.getConverters().get(0).getName());
- assertEquals("Foo", resourceEntityMappings.getConverters().get(1).getClassName());
- assertEquals("myConverter", resourceEntityMappings.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveCustomConverter(0, 1);
-
- assertEquals(2, resourceEntityMappings.getConverters().size());
- assertEquals("Foo", resourceEntityMappings.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceEntityMappings.getConverters().get(0).getName());
- assertEquals("Foo2", resourceEntityMappings.getConverters().get(1).getClassName());
- assertEquals("myConverter2", resourceEntityMappings.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(0);
-
- assertEquals(1, resourceEntityMappings.getConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceEntityMappings.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(contextConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateTypeConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceEntityMappings.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceEntityMappings.getTypeConverters().add(resourceTypeConverter);
- resourceTypeConverter.setDataType("Foo");
- resourceTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, resourceEntityMappings.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceEntityMappings.getTypeConverters().add(0, resourceTypeConverter2);
- resourceTypeConverter2.setDataType("Foo2");
- resourceTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, resourceEntityMappings.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntityMappings.getTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, resourceEntityMappings.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, resourceEntityMappings.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getTypeConverters().remove(resourceTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyTypeConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceEntityMappings.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter.setDataType("Foo");
- contextTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, resourceEntityMappings.getTypeConverters().size());
- assertEquals("Foo", resourceEntityMappings.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceEntityMappings.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter2.setDataType("Foo2");
- contextTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, resourceEntityMappings.getTypeConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceEntityMappings.getTypeConverters().get(0).getName());
- assertEquals("Foo", resourceEntityMappings.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter", resourceEntityMappings.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveTypeConverter(0, 1);
-
- assertEquals(2, resourceEntityMappings.getTypeConverters().size());
- assertEquals("Foo", resourceEntityMappings.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceEntityMappings.getTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceEntityMappings.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter2", resourceEntityMappings.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(0);
-
- assertEquals(1, resourceEntityMappings.getTypeConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceEntityMappings.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(contextTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateObjectTypeConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceEntityMappings.getObjectTypeConverters().add(resourceObjectTypeConverter);
- resourceObjectTypeConverter.setDataType("Foo");
- resourceObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceEntityMappings.getObjectTypeConverters().add(0, resourceObjectTypeConverter2);
- resourceObjectTypeConverter2.setDataType("Foo2");
- resourceObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntityMappings.getObjectTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getObjectTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getObjectTypeConverters().remove(resourceObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyObjectTypeConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter.setDataType("Foo");
- contextObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals("Foo", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter2.setDataType("Foo2");
- contextObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo", resourceEntityMappings.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter", resourceEntityMappings.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveObjectTypeConverter(0, 1);
-
- assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals("Foo", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceEntityMappings.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEntityMappings.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(0);
-
- assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(contextObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateStructConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceEntityMappings.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlStructConverter resourceStructConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceEntityMappings.getStructConverters().add(resourceStructConverter);
- resourceStructConverter.setConverter("Foo");
- resourceStructConverter.setName("myStructConverter");
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, resourceEntityMappings.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlStructConverter resourceStructConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceEntityMappings.getStructConverters().add(0, resourceStructConverter2);
- resourceStructConverter2.setConverter("Foo2");
- resourceStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, resourceEntityMappings.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntityMappings.getStructConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, resourceEntityMappings.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getStructConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, resourceEntityMappings.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntityMappings.getStructConverters().remove(resourceStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyStructConverters() throws Exception {
- XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceEntityMappings.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter.setConverterClass("Foo");
- contextStructConverter.setName("myStructConverter");
-
- assertEquals(1, resourceEntityMappings.getStructConverters().size());
- assertEquals("Foo", resourceEntityMappings.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceEntityMappings.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter2.setConverterClass("Foo2");
- contextStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, resourceEntityMappings.getStructConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceEntityMappings.getStructConverters().get(0).getName());
- assertEquals("Foo", resourceEntityMappings.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter", resourceEntityMappings.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveStructConverter(0, 1);
-
- assertEquals(2, resourceEntityMappings.getStructConverters().size());
- assertEquals("Foo", resourceEntityMappings.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceEntityMappings.getStructConverters().get(0).getName());
- assertEquals("Foo2", resourceEntityMappings.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter2", resourceEntityMappings.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(0);
-
- assertEquals(1, resourceEntityMappings.getStructConverters().size());
- assertEquals("Foo2", resourceEntityMappings.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceEntityMappings.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(contextStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceEntityMappings.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmBasicMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmBasicMappingTests.java
deleted file mode 100644
index 3434ef504d..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmBasicMappingTests.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkBasicMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmBasicMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableBasicDate() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.MUTABLE, "java.util.Date");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append(" @Mutable").append(CR);
- sb.append(" private Date myDate;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- public EclipseLinkOrmBasicMappingTests(String name) {
- super(name);
- }
-
-
- public void testUpdateMutable() throws Exception {
- createTestEntityWithBasicMapping();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmEclipseLinkBasicMapping contextBasic =
- (OrmEclipseLinkBasicMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlBasic resourceBasic =
- (XmlBasic) resourceEntity.getAttributes().getBasics().get(0);
- EclipseLinkBasicMapping javaBasicMapping = (EclipseLinkBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- // check defaults
-
- assertNull(resourceBasic.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
-
- // set xml mutable to false, check context
-
- resourceBasic.setMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceBasic.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- // set xml mutable to true, check context
-
- resourceBasic.setMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceBasic.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
-
- // clear xml mutable, check context
-
- resourceBasic.setMutable(null);
-
- assertNull(resourceBasic.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
-
- // TODO - test defaults for java serializable and date/time types,
- // with and without persistence property
-
- // set mutable on java basic mapping
-
- javaBasicMapping.getMutable().setSpecifiedMutable(Boolean.FALSE);
- assertNull(resourceBasic.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
- assertFalse(javaBasicMapping.getMutable().isMutable());
-
- // remove attribute from xml, test default mutable from java
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- EclipseLinkBasicMapping virtualContextBasic = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
-
- assertNull(resourceBasic.getMutable());
- assertTrue(virtualContextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, virtualContextBasic.getMutable().getSpecifiedMutable());
- assertFalse(virtualContextBasic.getMutable().isMutable());
- assertFalse(javaBasicMapping.getMutable().isMutable());
-
- // set metadata complete
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualContextBasic = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(resourceBasic.getMutable());
- assertTrue(virtualContextBasic.getMutable().isDefaultMutable());
- assertNull(virtualContextBasic.getMutable().getSpecifiedMutable());
- assertTrue(virtualContextBasic.getMutable().isMutable());
- assertFalse(javaBasicMapping.getMutable().isMutable());
- }
-
- public void testUpdateMutableDate() throws Exception {
- createTestEntityWithMutableBasicDate();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "myDate");
- OrmEclipseLinkBasicMapping contextBasic =
- (OrmEclipseLinkBasicMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlBasic resourceBasic =
- (XmlBasic) resourceEntity.getAttributes().getBasics().get(0);
- EclipseLinkBasicMapping javaBasicMapping = (EclipseLinkBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("myDate").getMapping();
-
- // check defaults
-
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- // set xml mutable to false, check context
-
- resourceBasic.setMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- // set xml mutable to true, check context
-
- resourceBasic.setMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
-
- // clear xml mutable, check context
-
- resourceBasic.setMutable(null);
-
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.TRUE);
- assertNull(resourceBasic.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.FALSE);
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(null);
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- // set mutable on java basic mapping
-
- javaBasicMapping.getMutable().setSpecifiedMutable(Boolean.TRUE);
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
- assertTrue(javaBasicMapping.getMutable().isMutable());
-
- // remove attribute from xml, test default mutable from java
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("myDate");
- EclipseLinkBasicMapping virtualContextBasic = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
-
- assertNull(resourceBasic.getMutable());
- assertFalse(virtualContextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, virtualContextBasic.getMutable().getSpecifiedMutable());
- assertTrue(virtualContextBasic.getMutable().isMutable());
- assertTrue(javaBasicMapping.getMutable().isMutable());
-
- // set metadata complete
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("myDate");
- virtualContextBasic = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(resourceBasic.getMutable());
- assertFalse(virtualContextBasic.getMutable().isDefaultMutable());
- assertNull(virtualContextBasic.getMutable().getSpecifiedMutable());
- assertFalse(virtualContextBasic.getMutable().isMutable());
- assertTrue(javaBasicMapping.getMutable().isMutable());
- }
-
- public void testModifyMutable() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basic");
- OrmEclipseLinkBasicMapping contextBasic =
- (OrmEclipseLinkBasicMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlBasic resourceBasic =
- (XmlBasic) resourceEntity.getAttributes().getBasics().get(0);
-
- // check defaults
-
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- // set context mutable to true, check resource
-
- contextBasic.getMutable().setSpecifiedMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
-
- // set context mutable to false, check resource
-
- contextBasic.getMutable().setSpecifiedMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
-
- // set context mutable to null, check resource
-
- contextBasic.getMutable().setSpecifiedMutable(null);
-
- assertNull(resourceBasic.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
- }
-
- public void testUpdateConvert() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = (XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(ormBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
- //set lob in the resource model, verify context model updated
- basicResource.setConvert("myConvert");
- assertEquals(EclipseLinkConvert.class, ormBasicMapping.getConverter().getType());
- assertEquals("myConvert", basicResource.getConvert());
-
- //set lob to null in the resource model
- basicResource.setConvert(null);
- assertNull(ormBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
-
- javaBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) javaBasicMapping.getConverter()).setSpecifiedConverterName("foo");
-
- assertNull(ormBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
- assertEquals("foo", ((EclipseLinkConvert) javaBasicMapping.getConverter()).getSpecifiedConverterName());
-
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- EclipseLinkBasicMapping virtualBasicMapping = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
-
- assertEquals(EclipseLinkConvert.class, virtualBasicMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getSpecifiedConverterName());
- assertEquals(null, basicResource.getConvert());
- assertEquals("foo", ((EclipseLinkConvert) javaBasicMapping.getConverter()).getSpecifiedConverterName());
-
- ((EclipseLinkConvert) javaBasicMapping.getConverter()).setSpecifiedConverterName("bar");
- assertEquals(EclipseLinkConvert.class, virtualBasicMapping.getConverter().getType());
- assertEquals("bar", ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getSpecifiedConverterName());
- assertEquals(null, basicResource.getConvert());
- assertEquals("bar", ((EclipseLinkConvert) javaBasicMapping.getConverter()).getSpecifiedConverterName());
-
- javaBasicMapping.setConverter(null);
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
- assertNull(javaBasicMapping.getConverter().getType());
- }
-
- public void testModifyConvert() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- XmlBasic basicResource = (XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0);
-
- assertNull(ormBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
- //set lob in the context model, verify resource model updated
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- assertEquals("", basicResource.getConvert());
- assertEquals(EclipseLinkConvert.class, ormBasicMapping.getConverter().getType());
-
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setSpecifiedConverterName("bar");
- assertEquals("bar", basicResource.getConvert());
- assertEquals(EclipseLinkConvert.class, ormBasicMapping.getConverter().getType());
- assertEquals("bar", ((EclipseLinkConvert) ormBasicMapping.getConverter()).getSpecifiedConverterName());
-
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setSpecifiedConverterName(null);
-
- assertNull(ormBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
- //set lob to false in the context model
- ormBasicMapping.setConverter(null);
- assertNull(ormBasicMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmContextModelTestCase.java
deleted file mode 100644
index f86fac1a4c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmContextModelTestCase.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.JpaFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationOperation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public abstract class EclipseLinkOrmContextModelTestCase
- extends EclipseLinkContextModelTestCase
-{
- protected JpaXmlResource eclipseLinkOrmXmlResource;
-
-
- protected EclipseLinkOrmContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.eclipseLinkOrmXmlResource = getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- }
-
- @Override
- protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild, IDataModel jpaConfig) throws Exception {
- TestJpaProject testJpaProject = super.buildJpaProject(projectName, autoBuild, jpaConfig);
-
- EclipseLinkOrmFileCreationOperation operation =
- new EclipseLinkOrmFileCreationOperation(buildEclipseLinkOrmConfig(testJpaProject));
- operation.execute(null, null);
-
- return testJpaProject;
- }
-
- protected IDataModel buildEclipseLinkOrmConfig(TestJpaProject testJpaProject) {
- IDataModel dataModel =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- dataModel.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- testJpaProject.getProject().getFolder("src/META-INF").getFullPath());
- dataModel.setProperty(JpaFileCreationDataModelProperties.VERSION, EclipseLink.SCHEMA_VERSION);
- dataModel.setProperty(OrmFileCreationDataModelProperties.ADD_TO_PERSISTENCE_UNIT, Boolean.TRUE);
- return dataModel;
- }
-
- @Override
- protected void tearDown() throws Exception {
- this.eclipseLinkOrmXmlResource = null;
- super.tearDown();
- }
-
- @Override
- protected JpaXmlResource getOrmXmlResource() {
- return this.eclipseLinkOrmXmlResource;
- }
-
- @Override
- protected XmlEntityMappings getXmlEntityMappings() {
- return (XmlEntityMappings) super.getXmlEntityMappings();
- }
-
- @Override
- protected EclipseLinkEntityMappings getEntityMappings() {
- return (EclipseLinkEntityMappings) super.getEntityMappings();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmConverterTests.java
deleted file mode 100644
index 8c8a09fd48..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmConverterTests.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmConverterTests
- extends EclipseLinkOrmContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.CONVERT, EclipseLink.CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append(" @Convert(name=\"foo\")").append(CR);
- sb.append(" @Converter");
- }
- });
- }
-
-
- public EclipseLinkOrmConverterTests(String name) {
- super(name);
- }
-
-
- public void testUpdateConverterClass() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkCustomConverter.class);
- OrmEclipseLinkCustomConverter ormConverter = (OrmEclipseLinkCustomConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getClassName());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setClassName("myConvert");
- assertEquals("myConvert", ormConverter.getConverterClass());
- assertEquals("myConvert", converterResource.getClassName());
-
- //set converter class name to null in the resource model
- converterResource.setClassName(null);
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getClassName());
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- EclipseLinkCustomConverter virtualConverter = (EclipseLinkCustomConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkCustomConverter javaConverter = ((EclipseLinkCustomConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setConverterClass("bar");
- assertEquals("bar", virtualConverter.getConverterClass());
- assertEquals("bar", javaConverter.getConverterClass());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getConverterClass());
- }
-
- public void testModifyConverterClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkCustomConverter.class);
- OrmEclipseLinkCustomConverter ormConverter = (OrmEclipseLinkCustomConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getConverter();
-
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getClassName());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setConverterClass("foo");
- assertEquals("foo", ormConverter.getConverterClass());
- assertEquals("foo", converterResource.getClassName());
-
- ormConverter.setConverterClass(null);
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getClassName());
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkCustomConverter.class);
- OrmEclipseLinkCustomConverter ormConverter = (OrmEclipseLinkCustomConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setName("myConvert");
- assertEquals("myConvert", ormConverter.getName());
- assertEquals("myConvert", converterResource.getName());
-
- //set converter class name to null in the resource model
- converterResource.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- EclipseLinkCustomConverter virtualConverter = (EclipseLinkCustomConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkCustomConverter javaConverter = ((EclipseLinkCustomConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setName("bar");
- assertEquals("bar", virtualConverter.getName());
- assertEquals("bar", javaConverter.getName());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkCustomConverter.class);
- OrmEclipseLinkCustomConverter ormConverter = (OrmEclipseLinkCustomConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getConverter();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setName("foo");
- assertEquals("foo", ormConverter.getName());
- assertEquals("foo", converterResource.getName());
-
- ormConverter.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEmbeddableTests.java
deleted file mode 100644
index 1d4ec1cd9b..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEmbeddableTests.java
+++ /dev/null
@@ -1,1035 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkEmbeddable;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkEmbeddable;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmEmbeddableTests extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmEmbeddableTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEmbeddableForCustomizer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE, EclipseLink.CUSTOMIZER);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEmbeddableForChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE, EclipseLink.CHANGE_TRACKING);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEmbeddableForCustomConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEmbeddableForTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEmbeddableForObjectTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEmbeddableForStructConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.EMBEDDABLE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Embeddable").append(CR);
- }
- });
- }
-
- public void testUpdateCustomizerClass() throws Exception {
- createTestEmbeddableForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkEmbeddable javaContextEmbeddable = (JavaEclipseLinkEmbeddable) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
-
- // check defaults
-
- assertNull(resourceEmbeddable.getCustomizer());
- assertNull(javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- // set xml customizer, check defaults
- resourceEmbeddable.setCustomizer(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(resourceEmbeddable.getCustomizer().getClassName());
- assertNull(javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
-
- // set xml customizer class, check override
-
- resourceEmbeddable.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceEmbeddable.getCustomizer().getClassName());
- assertNull(javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- // clear xml customizer class, set java customizer class, check defaults
-
- resourceEmbeddable.getCustomizer().setClassName(null);
- javaContextEmbeddable.getCustomizer().setSpecifiedCustomizerClass("bar");
-
- assertNull(resourceEmbeddable.getCustomizer().getClassName());
- assertEquals("bar", javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEmbeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceEmbeddable.getCustomizer().getClassName());
- assertEquals("bar", javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- ormContextEmbeddable.setSpecifiedMetadataComplete(null);
-
- // set xml customizer class, check override
-
- resourceEmbeddable.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceEmbeddable.getCustomizer().getClassName());
- assertEquals("bar", javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- //set xml customizer null
- javaContextEmbeddable.getCustomizer().setSpecifiedCustomizerClass(null);
- resourceEmbeddable.setCustomizer(null);
- assertNull(resourceEmbeddable.getCustomizer());
- assertNull(javaContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- }
-
- public void testModifyCustomizerClass() throws Exception {
- createTestEmbeddableForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- // check defaults
-
- assertNull(resourceEmbeddable.getCustomizer());
- assertNull(ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer, check resource
-
- ormContextEmbeddable.getCustomizer().setSpecifiedCustomizerClass("foo");
-
- assertEquals("foo", resourceEmbeddable.getCustomizer().getClassName());
- assertEquals("foo", ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer to null, check resource
-
- ormContextEmbeddable.getCustomizer().setSpecifiedCustomizerClass(null);
-
- assertNull(resourceEmbeddable.getCustomizer());
- assertNull(ormContextEmbeddable.getCustomizer().getCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEmbeddable.getCustomizer().getSpecifiedCustomizerClass());
- }
-
- public void testUpdateChangeTracking() throws Exception {
- createTestEmbeddableForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkEmbeddable javaContextEmbeddable = (JavaEclipseLinkEmbeddable) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- // check defaults
-
- assertNull(resourceEmbeddable.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertNull(ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set xml type to ATTRIBUTE, check context
-
- resourceEmbeddable.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceEmbeddable.getChangeTracking().setType(XmlChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set xml type to OBJECT, check context
-
- resourceEmbeddable.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set xml type to DEFERRED, check context
-
- resourceEmbeddable.getChangeTracking().setType(XmlChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set xml type to AUTO, check context
-
- resourceEmbeddable.getChangeTracking().setType(XmlChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // clear xml change tracking, set java change tracking, check defaults
-
- resourceEmbeddable.setChangeTracking(null);
- javaContextEmbeddable.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertNull(resourceEmbeddable.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertNull(ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEmbeddable.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceEmbeddable.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertNull(ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // unset metadataComplete, set xml change tracking to OBJECT, check context
-
- ormContextEmbeddable.setSpecifiedMetadataComplete(null);
- resourceEmbeddable.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceEmbeddable.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
- }
-
- public void testModifyChangeTracking() throws Exception {
- createTestEmbeddableForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- // check defaults
-
- assertNull(resourceEmbeddable.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertNull(ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to ATTRIBUTE, check resource
-
- ormContextEmbeddable.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to OBJECT, check resource
-
- ormContextEmbeddable.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to DEFERRED, check resource
-
- ormContextEmbeddable.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to AUTO, check resource
-
- ormContextEmbeddable.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to null, check resource
-
- ormContextEmbeddable.getChangeTracking().setSpecifiedType(null);
-
- assertNull(resourceEmbeddable.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEmbeddable.getChangeTracking().getDefaultType());
- assertNull(ormContextEmbeddable.getChangeTracking().getSpecifiedType());
- }
-
- public void testUpdateCustomConverters() throws Exception {
- createTestEmbeddableForCustomConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceEmbeddable.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceEmbeddable.getConverters().add(resourceConverter);
- resourceConverter.setClassName("Foo");
- resourceConverter.setName("myConverter");
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, resourceEmbeddable.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlConverter resourceConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceEmbeddable.getConverters().add(0, resourceConverter2);
- resourceConverter2.setClassName("Foo2");
- resourceConverter2.setName("myConverter2");
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, resourceEmbeddable.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEmbeddable.getConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, resourceEmbeddable.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, resourceEmbeddable.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getConverters().remove(resourceConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyCustomConverters() throws Exception {
- createTestEmbeddableForCustomConverters();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceEmbeddable.getConverters().size());
-
- //add a converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter(0);
- contextConverter.setConverterClass("Foo");
- contextConverter.setName("myConverter");
-
- assertEquals(1, resourceEmbeddable.getConverters().size());
- assertEquals("Foo", resourceEmbeddable.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceEmbeddable.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
-
- //add another converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter(0);
- contextConverter2.setConverterClass("Foo2");
- contextConverter2.setName("myConverter2");
-
- assertEquals(2, resourceEmbeddable.getConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceEmbeddable.getConverters().get(0).getName());
- assertEquals("Foo", resourceEmbeddable.getConverters().get(1).getClassName());
- assertEquals("myConverter", resourceEmbeddable.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveCustomConverter(0, 1);
-
- assertEquals(2, resourceEmbeddable.getConverters().size());
- assertEquals("Foo", resourceEmbeddable.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceEmbeddable.getConverters().get(0).getName());
- assertEquals("Foo2", resourceEmbeddable.getConverters().get(1).getClassName());
- assertEquals("myConverter2", resourceEmbeddable.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(0);
-
- assertEquals(1, resourceEmbeddable.getConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceEmbeddable.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
-
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(contextConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getConverters().size());
- }
-
- public void testUpdateTypeConverters() throws Exception {
- createTestEmbeddableForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceEmbeddable.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceEmbeddable.getTypeConverters().add(resourceTypeConverter);
- resourceTypeConverter.setDataType("Foo");
- resourceTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, resourceEmbeddable.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceEmbeddable.getTypeConverters().add(0, resourceTypeConverter2);
- resourceTypeConverter2.setDataType("Foo2");
- resourceTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, resourceEmbeddable.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEmbeddable.getTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, resourceEmbeddable.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, resourceEmbeddable.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getTypeConverters().remove(resourceTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyTypeConverters() throws Exception {
- createTestEmbeddableForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceEmbeddable.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter.setDataType("Foo");
- contextTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, resourceEmbeddable.getTypeConverters().size());
- assertEquals("Foo", resourceEmbeddable.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceEmbeddable.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter2.setDataType("Foo2");
- contextTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, resourceEmbeddable.getTypeConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceEmbeddable.getTypeConverters().get(0).getName());
- assertEquals("Foo", resourceEmbeddable.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter", resourceEmbeddable.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveTypeConverter(0, 1);
-
- assertEquals(2, resourceEmbeddable.getTypeConverters().size());
- assertEquals("Foo", resourceEmbeddable.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceEmbeddable.getTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceEmbeddable.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter2", resourceEmbeddable.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(0);
-
- assertEquals(1, resourceEmbeddable.getTypeConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceEmbeddable.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(contextTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateObjectTypeConverters() throws Exception {
- createTestEmbeddableForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceEmbeddable.getObjectTypeConverters().add(resourceObjectTypeConverter);
- resourceObjectTypeConverter.setDataType("Foo");
- resourceObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceEmbeddable.getObjectTypeConverters().add(0, resourceObjectTypeConverter2);
- resourceObjectTypeConverter2.setDataType("Foo2");
- resourceObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEmbeddable.getObjectTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getObjectTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getObjectTypeConverters().remove(resourceObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyObjectTypeConverters() throws Exception {
- createTestEmbeddableForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter.setDataType("Foo");
- contextObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals("Foo", resourceEmbeddable.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceEmbeddable.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter2.setDataType("Foo2");
- contextObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEmbeddable.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo", resourceEmbeddable.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter", resourceEmbeddable.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveObjectTypeConverter(0, 1);
-
- assertEquals(2, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals("Foo", resourceEmbeddable.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceEmbeddable.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceEmbeddable.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEmbeddable.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(0);
-
- assertEquals(1, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEmbeddable.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(contextObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateStructConverters() throws Exception {
- createTestEmbeddableForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceEmbeddable.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlStructConverter resourceStructConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceEmbeddable.getStructConverters().add(resourceStructConverter);
- resourceStructConverter.setConverter("Foo");
- resourceStructConverter.setName("myStructConverter");
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, resourceEmbeddable.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlStructConverter resourceStructConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceEmbeddable.getStructConverters().add(0, resourceStructConverter2);
- resourceStructConverter2.setConverter("Foo2");
- resourceStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, resourceEmbeddable.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEmbeddable.getStructConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, resourceEmbeddable.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getStructConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, resourceEmbeddable.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEmbeddable.getStructConverters().remove(resourceStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyStructConverters() throws Exception {
- createTestEmbeddableForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEmbeddable ormContextEmbeddable = (OrmEclipseLinkEmbeddable) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEmbeddable.getConverterContainer();
- XmlEmbeddable resourceEmbeddable = (XmlEmbeddable) getXmlEntityMappings().getEmbeddables().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceEmbeddable.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter.setConverterClass("Foo");
- contextStructConverter.setName("myStructConverter");
-
- assertEquals(1, resourceEmbeddable.getStructConverters().size());
- assertEquals("Foo", resourceEmbeddable.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceEmbeddable.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter2.setConverterClass("Foo2");
- contextStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, resourceEmbeddable.getStructConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceEmbeddable.getStructConverters().get(0).getName());
- assertEquals("Foo", resourceEmbeddable.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter", resourceEmbeddable.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveStructConverter(0, 1);
-
- assertEquals(2, resourceEmbeddable.getStructConverters().size());
- assertEquals("Foo", resourceEmbeddable.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceEmbeddable.getStructConverters().get(0).getName());
- assertEquals("Foo2", resourceEmbeddable.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter2", resourceEmbeddable.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(0);
-
- assertEquals(1, resourceEmbeddable.getStructConverters().size());
- assertEquals("Foo2", resourceEmbeddable.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceEmbeddable.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(contextStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceEmbeddable.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEntityTests.java
deleted file mode 100644
index dc71269610..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEntityTests.java
+++ /dev/null
@@ -1,2394 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheCoordinationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkExistenceType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTimeOfDay;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmEntityTests extends EclipseLinkOrmContextModelTestCase
-{
-
-
- public EclipseLinkOrmEntityTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityForReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForCustomizer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CHANGE_TRACKING);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForCaching() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForObjectTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityForStructConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- public void testUpdateReadOnly() throws Exception {
- createTestEntityForReadOnly();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkEntity javaContextEntity = (JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertNull(resourceEntity.getReadOnly());
- assertFalse(javaContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to false, check override
-
- resourceEntity.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceEntity.getReadOnly());
- assertFalse(javaContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceEntity.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getReadOnly());
- assertFalse(javaContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // clear xml read only, set java read only to true, check defaults
-
- resourceEntity.setReadOnly(null);
- javaContextEntity.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
-
- assertNull(resourceEntity.getReadOnly());
- assertTrue(javaContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceEntity.getReadOnly());
- assertTrue(javaContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- // set xml read only to false, check override
-
- resourceEntity.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceEntity.getReadOnly());
- assertTrue(javaContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceEntity.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getReadOnly());
- assertTrue(javaContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // clear xml read only, set java read only to false, check defaults
-
- resourceEntity.setReadOnly(null);
- javaContextEntity.getReadOnly().setSpecifiedReadOnly(Boolean.FALSE);
-
- assertNull(resourceEntity.getReadOnly());
- assertFalse(javaContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
-
-
- // set xml read only to false, check override
-
- resourceEntity.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceEntity.getReadOnly());
- assertFalse(javaContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceEntity.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getReadOnly());
- assertFalse(javaContextEntity.getReadOnly().isReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
- }
-
- public void testModifyReadOnly() throws Exception {
- createTestEntityForReadOnly();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertNull(resourceEntity.getReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to true, check resource
-
- ormContextEntity.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getReadOnly());
- assertTrue(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to false, check resource
-
- ormContextEntity.getReadOnly().setSpecifiedReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceEntity.getReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextEntity.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to null, check resource
-
- ormContextEntity.getReadOnly().setSpecifiedReadOnly(null);
-
- assertNull(resourceEntity.getReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isReadOnly());
- assertFalse(ormContextEntity.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextEntity.getReadOnly().getSpecifiedReadOnly());
- }
-
-
- public void testUpdateCustomizerClass() throws Exception {
- createTestEntityForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkEntity javaContextEntity = (JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertNull(resourceEntity.getCustomizer());
- assertNull(javaContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- // set xml customizer, check defaults
- resourceEntity.setCustomizer(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(resourceEntity.getCustomizer().getClassName());
- assertNull(javaContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
-
- // set xml customizer class, check override
-
- resourceEntity.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceEntity.getCustomizer().getClassName());
- assertNull(javaContextEntity.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- // clear xml customizer class, set java customizer class, check defaults
-
- resourceEntity.getCustomizer().setClassName(null);
- javaContextEntity.getCustomizer().setSpecifiedCustomizerClass("bar");
-
- assertNull(resourceEntity.getCustomizer().getClassName());
- assertEquals("bar", javaContextEntity.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextEntity.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceEntity.getCustomizer().getClassName());
- assertEquals("bar", javaContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- // set xml customizer class, check override
-
- resourceEntity.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceEntity.getCustomizer().getClassName());
- assertEquals("bar", javaContextEntity.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextEntity.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- //set xml customizer null
- javaContextEntity.getCustomizer().setSpecifiedCustomizerClass(null);
- resourceEntity.setCustomizer(null);
- assertNull(resourceEntity.getCustomizer());
- assertNull(javaContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- }
-
- public void testModifyCustomizerClass() throws Exception {
- createTestEntityForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertNull(resourceEntity.getCustomizer());
- assertNull(ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer, check resource
-
- ormContextEntity.getCustomizer().setSpecifiedCustomizerClass("foo");
-
- assertEquals("foo", resourceEntity.getCustomizer().getClassName());
- assertEquals("foo", ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer to null, check resource
-
- ormContextEntity.getCustomizer().setSpecifiedCustomizerClass(null);
-
- assertNull(resourceEntity.getCustomizer());
- assertNull(ormContextEntity.getCustomizer().getCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextEntity.getCustomizer().getSpecifiedCustomizerClass());
- }
-
- public void testUpdateChangeTracking() throws Exception {
- createTestEntityForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkEntity javaContextEntity = (JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertNull(resourceEntity.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertNull(ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set xml type to ATTRIBUTE, check context
-
- resourceEntity.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceEntity.getChangeTracking().setType(XmlChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set xml type to OBJECT, check context
-
- resourceEntity.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set xml type to DEFERRED, check context
-
- resourceEntity.getChangeTracking().setType(XmlChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set xml type to AUTO, check context
-
- resourceEntity.getChangeTracking().setType(XmlChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // clear xml change tracking, set java change tracking, check defaults
-
- resourceEntity.setChangeTracking(null);
- javaContextEntity.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertNull(resourceEntity.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getDefaultType());
- assertNull(ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceEntity.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertNull(ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // unset metadataComplete, set xml change tracking to OBJECT, check context
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
- resourceEntity.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceEntity.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEntity.getChangeTracking().getSpecifiedType());
- }
-
- public void testModifyChangeTracking() throws Exception {
- createTestEntityForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertNull(resourceEntity.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertNull(ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to ATTRIBUTE, check resource
-
- ormContextEntity.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to OBJECT, check resource
-
- ormContextEntity.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to DEFERRED, check resource
-
- ormContextEntity.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to AUTO, check resource
-
- ormContextEntity.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to null, check resource
-
- ormContextEntity.getChangeTracking().setSpecifiedType(null);
-
- assertNull(resourceEntity.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextEntity.getChangeTracking().getDefaultType());
- assertNull(ormContextEntity.getChangeTracking().getSpecifiedType());
- }
-
- public void testUpdateCacheType() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // set xml cache type, check settings
- resourceEntity.getCache().setType(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL, resourceEntity.getCache().getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getSpecifiedType());
-
-
- // set java cache type, check defaults
-
- javaContextCaching.setSpecifiedType(EclipseLinkCacheType.WEAK);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL, resourceEntity.getCache().getType());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getSpecifiedType());
-
- // clear xml cache type, check defaults
- resourceEntity.getCache().setType(null);
-
- assertEquals(null, resourceEntity.getCache().getType());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheType() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- // set context cache type, check resource
-
- ormContextEntity.getCaching().setSpecifiedType(EclipseLinkCacheType.HARD_WEAK);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.HARD_WEAK, resourceEntity.getCache().getType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, ormContextCaching.getSpecifiedType());
-
- // set context customizer to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedType(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
- }
-
- public void testUpdateCacheCoordinationType() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set xml cache type, check settings
- resourceEntity.getCache().setCoordinationType(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, resourceEntity.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set java cache type, check defaults
-
- javaContextCaching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, resourceEntity.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getSpecifiedCoordinationType());
-
- // clear xml cache type, check defaults
- resourceEntity.getCache().setCoordinationType(null);
-
- assertEquals(null, resourceEntity.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheCoordinationType() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- // set context cache coordination type, check resource
-
- ormContextEntity.getCaching().setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, resourceEntity.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getSpecifiedCoordinationType());
-
- // set context coordination type to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedCoordinationType(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
- }
-
-
- public void testUpdateCacheSize() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity xmlEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, xmlEntity.getCache());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- // set xml cache, check defaults
- xmlEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, xmlEntity.getCache().getSize());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // set xml cache size, check settings
- xmlEntity.getCache().setSize(new Integer(105));
- assertEquals(new Integer(105), xmlEntity.getCache().getSize());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(105, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(105), ormContextCaching.getSpecifiedSize());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedSize(new Integer(50));
-
- assertEquals(new Integer(105), xmlEntity.getCache().getSize());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(105, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(105), ormContextCaching.getSpecifiedSize());
-
- // clear xml cache size, check defaults
- xmlEntity.getCache().setSize(null);
-
- assertEquals(null, xmlEntity.getCache().getSize());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // clear xml cache, check defaults
- xmlEntity.setCache(null);
-
- assertEquals(null, xmlEntity.getCache());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(50, ormContextCaching.getSize());
- assertEquals(50, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, xmlEntity.getCache());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheSize() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- // set context cache size, check resource
-
- ormContextEntity.getCaching().setSpecifiedSize(new Integer(50));
- assertEquals(new Integer(50), resourceEntity.getCache().getSize());
- assertEquals(50, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(50), ormContextCaching.getSpecifiedSize());
-
- // set context cache size to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedSize(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
- }
-
- public void testUpdateCacheAlwaysRefresh() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getAlwaysRefresh());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set xml cache always refresh, check settings
- resourceEntity.getCache().setAlwaysRefresh(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getAlwaysRefresh());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set java cache always refresh, check defaults
-
- javaContextCaching.setSpecifiedAlwaysRefresh(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set xml cache always refresh to false
- resourceEntity.getCache().setAlwaysRefresh(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // clear xml cache always refresh, check defaults
- resourceEntity.getCache().setAlwaysRefresh(null);
-
- assertEquals(null, resourceEntity.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- }
-
- public void testModifyCacheAlwaysRefresh() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set context cache size, check resource
-
- ormContextEntity.getCaching().setSpecifiedAlwaysRefresh(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set context cache size to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedAlwaysRefresh(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- }
-
- public void testUpdateCacheRefreshOnlyIfNewer() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getRefreshOnlyIfNewer());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set xml cache size, check settings
- resourceEntity.getCache().setRefreshOnlyIfNewer(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getRefreshOnlyIfNewer());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set xml cache always refresh to false
- resourceEntity.getCache().setRefreshOnlyIfNewer(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // clear xml cache always refresh, check defaults
- resourceEntity.getCache().setRefreshOnlyIfNewer(null);
-
- assertEquals(null, resourceEntity.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- }
-
- public void testModifyCacheRefreshOnlyIfNewer() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set context cache size, check resource
-
- ormContextEntity.getCaching().setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set context cache size to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedRefreshOnlyIfNewer(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- }
-
- public void testUpdateCacheDisableHits() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getDisableHits());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set xml cache size, check settings
- resourceEntity.getCache().setDisableHits(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getDisableHits());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedDisableHits(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
- // set xml cache always refresh to false
- resourceEntity.getCache().setDisableHits(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedDisableHits());
-
- // clear xml cache always refresh, check defaults
- resourceEntity.getCache().setDisableHits(null);
-
- assertEquals(null, resourceEntity.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- }
-
- public void testModifyCacheDisableHits() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
- // set context cache size, check resource
-
- ormContextEntity.getCaching().setSpecifiedDisableHits(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
- // set context cache size to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedDisableHits(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- }
-
- public void testUpdateCacheShared() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getShared());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set xml cache size, check settings
- resourceEntity.getCache().setShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getShared());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedShared(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
- // set xml cache always refresh to false
- resourceEntity.getCache().setShared(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceEntity.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedShared());
-
- // clear xml cache always refresh, check defaults
- resourceEntity.getCache().setShared(null);
-
- assertEquals(null, resourceEntity.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(false, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(false, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
- }
-
- public void testModifyCacheShared() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
- // set context cache size, check resource
-
- ormContextEntity.getCaching().setSpecifiedShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
- // set context cache size to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedShared(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
- }
- public void testSetSpecifiedSharedFalseUnsetsOtherCacheSettings() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- ormContextCaching.setSpecifiedType(EclipseLinkCacheType.HARD_WEAK);
- ormContextCaching.setSpecifiedSize(Integer.valueOf(500));
- ormContextCaching.setSpecifiedAlwaysRefresh(Boolean.FALSE);
- ormContextCaching.setSpecifiedRefreshOnlyIfNewer(Boolean.FALSE);
- ormContextCaching.setSpecifiedDisableHits(Boolean.FALSE);
- ormContextCaching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
- ormContextCaching.setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE);
- ormContextCaching.setExpiry(Integer.valueOf(8000));
-
- ormContextCaching.setSpecifiedShared(Boolean.FALSE);
-
- assertEquals(null, ormContextCaching.getSpecifiedType());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
- assertEquals(null, ormContextCaching.getExpiry());
-
-
- //existence checking is the only thing that isn't unset when shared is set to false
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- ormContextCaching.setSpecifiedShared(null);
- EclipseLinkTimeOfDay timeOfDayExpiry = ormContextCaching.addExpiryTimeOfDay();
- timeOfDayExpiry.setHour(Integer.valueOf(5));
-
- ormContextCaching.setSpecifiedShared(Boolean.FALSE);
- assertNull(ormContextCaching.getExpiryTimeOfDay());
- assertEquals(Boolean.FALSE, resourceEntity.getCache().getShared());
- assertNull(resourceEntity.getCache().getExpiryTimeOfDay());
- }
-
- public void testUpdateExistenceChecking() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set xml existence checking, check settings
- resourceEntity.setExistenceChecking(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
-
- // set java cache existence checking, check defaults
-
- javaContextCaching.setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- // clear xml existence checking, check defaults
- resourceEntity.setExistenceChecking(null);
-
- assertEquals(null, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- ormContextEntity.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyExistenceChecking() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set context cache existence checking, check resource
-
- ormContextEntity.getCaching().setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_EXISTENCE);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- // set context existence checking to null, check resource
-
- ormContextEntity.getCaching().setSpecifiedExistenceType(null);
-
- assertEquals(null, resourceEntity.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
- }
-
- public void testUpdateCacheExpiry() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(null, javaContextCaching.getExpiry());
- assertEquals(null, ormContextCaching.getExpiry());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getExpiry());
- assertEquals(null, javaContextCaching.getExpiry());
- assertEquals(null, ormContextCaching.getExpiry());
-
-
- // set xml cache expiry, check settings
- resourceEntity.getCache().setExpiry(new Integer(45));
- assertEquals(new Integer(45), resourceEntity.getCache().getExpiry());
- assertEquals(null, javaContextCaching.getExpiry());
- assertEquals(new Integer(45), ormContextCaching.getExpiry());
-
-
- // set java cache expiry, check defaults
-
- javaContextCaching.setExpiry(new Integer(55));
-
- assertEquals(new Integer(45), resourceEntity.getCache().getExpiry());
- assertEquals(new Integer(55), javaContextCaching.getExpiry());
- assertEquals(new Integer(45), ormContextCaching.getExpiry());
-
- // clear xml cache expiry to null, check defaults
- resourceEntity.getCache().setExpiry(null);
-
- assertEquals(null, resourceEntity.getCache().getExpiry());
- assertEquals(new Integer(55), javaContextCaching.getExpiry());
- assertEquals(null, ormContextCaching.getExpiry());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(new Integer(55), javaContextCaching.getExpiry());
- assertEquals(null, ormContextCaching.getExpiry());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(new Integer(55), javaContextCaching.getExpiry());
- assertEquals(null, ormContextCaching.getExpiry());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(new Integer(55), javaContextCaching.getExpiry());
- assertEquals(null, ormContextCaching.getExpiry());
- }
-
- public void testModifyCacheExpiry() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(null, ormContextCaching.getExpiry());
-
- // set context cache expiry, check resource
-
- ormContextEntity.getCaching().setExpiry(new Integer(60));
- assertEquals(new Integer(60), resourceEntity.getCache().getExpiry());
- assertEquals(new Integer(60), ormContextCaching.getExpiry());
-
- // set context cache size to null, check resource
-
- ormContextEntity.getCaching().setExpiry(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(null, ormContextCaching.getExpiry());
- }
-
- public void testUpdateCacheExpiryTimeOfDay() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkEntity) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(null, javaContextCaching.getExpiryTimeOfDay());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
-
- // set xml cache, check defaults
- resourceEntity.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceEntity.getCache().getExpiryTimeOfDay());
- assertEquals(null, javaContextCaching.getExpiryTimeOfDay());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
-
-
- // set xml cache expiry, check settings
- resourceEntity.getCache().setExpiryTimeOfDay(EclipseLinkOrmFactory.eINSTANCE.createXmlTimeOfDay());
- resourceEntity.getCache().getExpiryTimeOfDay().setHour(new Integer(10));
- assertEquals(new Integer(10), resourceEntity.getCache().getExpiryTimeOfDay().getHour());
- assertEquals(null, javaContextCaching.getExpiryTimeOfDay());
- assertEquals(new Integer(10), ormContextCaching.getExpiryTimeOfDay().getHour());
-
-
- // set java cache expiry, check defaults
-
- javaContextCaching.addExpiryTimeOfDay();
- javaContextCaching.getExpiryTimeOfDay().setHour(new Integer(12));
-
- assertEquals(new Integer(10), resourceEntity.getCache().getExpiryTimeOfDay().getHour());
- assertEquals(new Integer(12), javaContextCaching.getExpiryTimeOfDay().getHour());
- assertEquals(new Integer(10), ormContextCaching.getExpiryTimeOfDay().getHour());
-
- // clear xml cache expiry to null, check defaults
- resourceEntity.getCache().setExpiryTimeOfDay(null);
-
- assertEquals(null, resourceEntity.getCache().getExpiryTimeOfDay());
- assertEquals(new Integer(12), javaContextCaching.getExpiryTimeOfDay().getHour());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
-
-
- // clear xml cache, check defaults
- resourceEntity.setCache(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(new Integer(12), javaContextCaching.getExpiryTimeOfDay().getHour());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextEntity.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(new Integer(12), javaContextCaching.getExpiryTimeOfDay().getHour());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextEntity.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(new Integer(12), javaContextCaching.getExpiryTimeOfDay().getHour());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
- }
-
- public void testModifyCacheExpiryTimeOfDay() throws Exception {
- createTestEntityForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextEntity.getCaching();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- // check defaults
-
- assertEquals(null, resourceEntity.getCache());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
-
- // set context cache expiry, check resource
-
- ormContextEntity.getCaching().addExpiryTimeOfDay().setHour(new Integer(12));
- assertEquals(new Integer(12), resourceEntity.getCache().getExpiryTimeOfDay().getHour());
- assertEquals(new Integer(12), ormContextCaching.getExpiryTimeOfDay().getHour());
-
- // set context expiry time of day minute, check resource
-
- ormContextEntity.getCaching().getExpiryTimeOfDay().setMinute(new Integer(35));
-
- assertEquals(new Integer(12), resourceEntity.getCache().getExpiryTimeOfDay().getHour());
- assertEquals(new Integer(12), ormContextCaching.getExpiryTimeOfDay().getHour());
- assertEquals(new Integer(35), resourceEntity.getCache().getExpiryTimeOfDay().getMinute());
- assertEquals(new Integer(35), ormContextCaching.getExpiryTimeOfDay().getMinute());
-
- // set context expiry time of day null, check resource
-
- ormContextEntity.getCaching().removeExpiryTimeOfDay();
- assertEquals(null, resourceEntity.getCache());
- assertEquals(null, ormContextCaching.getExpiryTimeOfDay());
- }
-
- public void testUpdateCustomConverters() throws Exception {
- createTestEntityForConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceEntity.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceEntity.getConverters().add(resourceConverter);
- resourceConverter.setClassName("Foo");
- resourceConverter.setName("myConverter");
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, resourceEntity.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlConverter resourceConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceEntity.getConverters().add(0, resourceConverter2);
- resourceConverter2.setClassName("Foo2");
- resourceConverter2.setName("myConverter2");
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, resourceEntity.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntity.getConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, resourceEntity.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, resourceEntity.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getConverters().remove(resourceConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceEntity.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyCustomConverters() throws Exception {
- createTestEntityForConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceEntity.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter(0);
- contextConverter.setConverterClass("Foo");
- contextConverter.setName("myConverter");
-
- assertEquals(1, resourceEntity.getConverters().size());
- assertEquals("Foo", resourceEntity.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceEntity.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter(0);
- contextConverter2.setConverterClass("Foo2");
- contextConverter2.setName("myConverter2");
-
- assertEquals(2, resourceEntity.getConverters().size());
- assertEquals("Foo2", resourceEntity.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceEntity.getConverters().get(0).getName());
- assertEquals("Foo", resourceEntity.getConverters().get(1).getClassName());
- assertEquals("myConverter", resourceEntity.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveCustomConverter(0, 1);
-
- assertEquals(2, resourceEntity.getConverters().size());
- assertEquals("Foo", resourceEntity.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceEntity.getConverters().get(0).getName());
- assertEquals("Foo2", resourceEntity.getConverters().get(1).getClassName());
- assertEquals("myConverter2", resourceEntity.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(0);
-
- assertEquals(1, resourceEntity.getConverters().size());
- assertEquals("Foo2", resourceEntity.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceEntity.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(contextConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceEntity.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateTypeConverters() throws Exception {
- createTestEntityForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceEntity.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceEntity.getTypeConverters().add(resourceTypeConverter);
- resourceTypeConverter.setDataType("Foo");
- resourceTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, resourceEntity.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceEntity.getTypeConverters().add(0, resourceTypeConverter2);
- resourceTypeConverter2.setDataType("Foo2");
- resourceTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, resourceEntity.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntity.getTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, resourceEntity.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, resourceEntity.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getTypeConverters().remove(resourceTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceEntity.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyTypeConverters() throws Exception {
- createTestEntityForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceEntity.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter.setDataType("Foo");
- contextTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, resourceEntity.getTypeConverters().size());
- assertEquals("Foo", resourceEntity.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceEntity.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter2.setDataType("Foo2");
- contextTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, resourceEntity.getTypeConverters().size());
- assertEquals("Foo2", resourceEntity.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceEntity.getTypeConverters().get(0).getName());
- assertEquals("Foo", resourceEntity.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter", resourceEntity.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveTypeConverter(0, 1);
-
- assertEquals(2, resourceEntity.getTypeConverters().size());
- assertEquals("Foo", resourceEntity.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceEntity.getTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceEntity.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter2", resourceEntity.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(0);
-
- assertEquals(1, resourceEntity.getTypeConverters().size());
- assertEquals("Foo2", resourceEntity.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceEntity.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(contextTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceEntity.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateObjectTypeConverters() throws Exception {
- createTestEntityForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceEntity.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceEntity.getObjectTypeConverters().add(resourceObjectTypeConverter);
- resourceObjectTypeConverter.setDataType("Foo");
- resourceObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceEntity.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceEntity.getObjectTypeConverters().add(0, resourceObjectTypeConverter2);
- resourceObjectTypeConverter2.setDataType("Foo2");
- resourceObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceEntity.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntity.getObjectTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceEntity.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getObjectTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceEntity.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getObjectTypeConverters().remove(resourceObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceEntity.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyObjectTypeConverters() throws Exception {
- createTestEntityForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceEntity.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter.setDataType("Foo");
- contextObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, resourceEntity.getObjectTypeConverters().size());
- assertEquals("Foo", resourceEntity.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceEntity.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter2.setDataType("Foo2");
- contextObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, resourceEntity.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceEntity.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEntity.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo", resourceEntity.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter", resourceEntity.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveObjectTypeConverter(0, 1);
-
- assertEquals(2, resourceEntity.getObjectTypeConverters().size());
- assertEquals("Foo", resourceEntity.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceEntity.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceEntity.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEntity.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(0);
-
- assertEquals(1, resourceEntity.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceEntity.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceEntity.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(contextObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceEntity.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateStructConverters() throws Exception {
- createTestEntityForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceEntity.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlStructConverter resourceStructConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceEntity.getStructConverters().add(resourceStructConverter);
- resourceStructConverter.setConverter("Foo");
- resourceStructConverter.setName("myStructConverter");
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, resourceEntity.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlStructConverter resourceStructConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceEntity.getStructConverters().add(0, resourceStructConverter2);
- resourceStructConverter2.setConverter("Foo2");
- resourceStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, resourceEntity.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceEntity.getStructConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, resourceEntity.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getStructConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, resourceEntity.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceEntity.getStructConverters().remove(resourceStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceEntity.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyStructConverters() throws Exception {
- createTestEntityForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkEntity ormContextEntity = (OrmEclipseLinkEntity) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextEntity.getConverterContainer();
- XmlEntity resourceEntity = (XmlEntity) getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceEntity.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter.setConverterClass("Foo");
- contextStructConverter.setName("myStructConverter");
-
- assertEquals(1, resourceEntity.getStructConverters().size());
- assertEquals("Foo", resourceEntity.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceEntity.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter2.setConverterClass("Foo2");
- contextStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, resourceEntity.getStructConverters().size());
- assertEquals("Foo2", resourceEntity.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceEntity.getStructConverters().get(0).getName());
- assertEquals("Foo", resourceEntity.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter", resourceEntity.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveStructConverter(0, 1);
-
- assertEquals(2, resourceEntity.getStructConverters().size());
- assertEquals("Foo", resourceEntity.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceEntity.getStructConverters().get(0).getName());
- assertEquals("Foo2", resourceEntity.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter2", resourceEntity.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(0);
-
- assertEquals(1, resourceEntity.getStructConverters().size());
- assertEquals("Foo2", resourceEntity.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceEntity.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(contextStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceEntity.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmIdMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmIdMappingTests.java
deleted file mode 100644
index f239980bfb..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmIdMappingTests.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkIdMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkIdMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlId;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmIdMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmIdMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithIdMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableIdDate() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, EclipseLink.MUTABLE, "java.util.Date");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id").append(CR);
- sb.append(" @Mutable").append(CR);
- sb.append(" private Date myDate;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- public void testUpdateMutable() throws Exception {
- createTestEntityWithIdMapping();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
- OrmEclipseLinkIdMapping contextId =
- (OrmEclipseLinkIdMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlId resourceId =
- (XmlId) resourceEntity.getAttributes().getIds().get(0);
- EclipseLinkIdMapping javaIdMapping = (EclipseLinkIdMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- // check defaults
-
- assertNull(resourceId.getMutable());
- assertTrue(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
-
- // set xml mutable to false, check context
-
- resourceId.setMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceId.getMutable());
- assertTrue(contextId.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- // set xml mutable to true, check context
-
- resourceId.setMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceId.getMutable());
- assertTrue(contextId.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
-
- // clear xml mutable, check context
-
- resourceId.setMutable(null);
-
- assertNull(resourceId.getMutable());
- assertTrue(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
-
- // TODO - test defaults for java serializable and date/time types,
- // with and without persistence property
-
- // set mutable on java basic mapping
-
- javaIdMapping.getMutable().setSpecifiedMutable(Boolean.FALSE);
- assertNull(resourceId.getMutable());
- assertTrue(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
- assertFalse(javaIdMapping.getMutable().isMutable());
-
- // remove attribute from xml, test default mutable from java
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- EclipseLinkIdMapping virtualIdMapping = (EclipseLinkIdMapping) ormPersistentAttribute2.getMapping();
-
- assertNull(resourceId.getMutable());
- assertTrue(virtualIdMapping.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, virtualIdMapping.getMutable().getSpecifiedMutable());
- assertFalse(virtualIdMapping.getMutable().isMutable());
- assertFalse(javaIdMapping.getMutable().isMutable());
-
- // set metadata complete
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- EclipseLinkBasicMapping virtualBasicMapping = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(resourceId.getMutable());
- assertTrue(virtualBasicMapping.getMutable().isDefaultMutable());
- assertNull(virtualBasicMapping.getMutable().getSpecifiedMutable());
- assertTrue(virtualBasicMapping.getMutable().isMutable());
- assertFalse(javaIdMapping.getMutable().isMutable());
- }
-
- public void testUpdateMutableDate() throws Exception {
- createTestEntityWithMutableIdDate();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "myDate");
- OrmEclipseLinkIdMapping contextId =
- (OrmEclipseLinkIdMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlId resourceId =
- (XmlId) resourceEntity.getAttributes().getIds().get(0);
- EclipseLinkIdMapping javaIdMapping = (EclipseLinkIdMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("myDate").getMapping();
-
- // check defaults
-
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- // set xml mutable to false, check context
-
- resourceId.setMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- // set xml mutable to true, check context
-
- resourceId.setMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
-
- // clear xml mutable, check context
-
- resourceId.setMutable(null);
-
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.TRUE);
- assertNull(resourceId.getMutable());
- assertTrue(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.FALSE);
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(null);
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- // set mutable on java id mapping
-
- javaIdMapping.getMutable().setSpecifiedMutable(Boolean.TRUE);
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
- assertTrue(javaIdMapping.getMutable().isMutable());
-
- // remove attribute from xml, test default mutable from java
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("myDate");
- EclipseLinkIdMapping virtualIdMapping = (EclipseLinkIdMapping) ormPersistentAttribute2.getMapping();
-
- assertNull(resourceId.getMutable());
- assertFalse(virtualIdMapping.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, virtualIdMapping.getMutable().getSpecifiedMutable());
- assertTrue(virtualIdMapping.getMutable().isMutable());
- assertTrue(javaIdMapping.getMutable().isMutable());
-
- // set metadata complete
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("myDate");
- EclipseLinkBasicMapping virtualBasicMapping = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(resourceId.getMutable());
- assertFalse(virtualBasicMapping.getMutable().isDefaultMutable());
- assertNull(virtualBasicMapping.getMutable().getSpecifiedMutable());
- assertFalse(virtualBasicMapping.getMutable().isMutable());
- assertTrue(javaIdMapping.getMutable().isMutable());
- }
-
- public void testModifyMutable() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "basic");
- OrmEclipseLinkIdMapping contextId =
- (OrmEclipseLinkIdMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlId resourceId =
- (XmlId) resourceEntity.getAttributes().getIds().get(0);
-
- // check defaults
-
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- // set context mutable to true, check resource
-
- contextId.getMutable().setSpecifiedMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextId.getMutable().getSpecifiedMutable());
- assertTrue(contextId.getMutable().isMutable());
-
- // set context mutable to false, check resource
-
- contextId.getMutable().setSpecifiedMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
-
- // set context read only to null, check resource
-
- contextId.getMutable().setSpecifiedMutable(null);
-
- assertNull(resourceId.getMutable());
- assertFalse(contextId.getMutable().isDefaultMutable());
- assertNull(contextId.getMutable().getSpecifiedMutable());
- assertFalse(contextId.getMutable().isMutable());
- }
-
- public void testUpdateConvert() throws Exception {
- createTestEntityWithIdMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId basicResource = (XmlId) getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
- JavaIdMapping javaIdMapping = (JavaIdMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(ormIdMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
- //set lob in the resource model, verify context model updated
- basicResource.setConvert("myConvert");
- assertEquals(EclipseLinkConvert.class, ormIdMapping.getConverter().getType());
- assertEquals("myConvert", basicResource.getConvert());
-
- //set lob to null in the resource model
- basicResource.setConvert(null);
- assertNull(ormIdMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
-
- javaIdMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) javaIdMapping.getConverter()).setSpecifiedConverterName("foo");
-
- assertNull(ormIdMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
- assertEquals("foo", ((EclipseLinkConvert) javaIdMapping.getConverter()).getSpecifiedConverterName());
-
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- IdMapping virtualIdMapping = (IdMapping) ormPersistentAttribute2.getMapping();
-
- assertEquals(EclipseLinkConvert.class, virtualIdMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) virtualIdMapping.getConverter()).getSpecifiedConverterName());
- assertEquals(null, basicResource.getConvert());
- assertEquals("foo", ((EclipseLinkConvert) javaIdMapping.getConverter()).getSpecifiedConverterName());
-
- ((EclipseLinkConvert) javaIdMapping.getConverter()).setSpecifiedConverterName("bar");
- assertEquals(EclipseLinkConvert.class, virtualIdMapping.getConverter().getType());
- assertEquals("bar", ((EclipseLinkConvert) virtualIdMapping.getConverter()).getSpecifiedConverterName());
- assertEquals(null, basicResource.getConvert());
- assertEquals("bar", ((EclipseLinkConvert) javaIdMapping.getConverter()).getSpecifiedConverterName());
-
- javaIdMapping.setConverter(null);
- assertNull(virtualIdMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
- assertNull(javaIdMapping.getConverter().getType());
- }
-
- public void testModifyConvert() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmIdMapping ormIdMapping = (OrmIdMapping) ormPersistentAttribute.getMapping();
- XmlId basicResource = (XmlId) getXmlEntityMappings().getEntities().get(0).getAttributes().getIds().get(0);
-
- assertNull(ormIdMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
-
- //set lob in the context model, verify resource model updated
- ormIdMapping.setConverter(EclipseLinkConvert.class);
- assertEquals("", basicResource.getConvert());
- assertEquals(EclipseLinkConvert.class, ormIdMapping.getConverter().getType());
-
- ((EclipseLinkConvert) ormIdMapping.getConverter()).setSpecifiedConverterName("bar");
- assertEquals("bar", basicResource.getConvert());
- assertEquals(EclipseLinkConvert.class, ormIdMapping.getConverter().getType());
- assertEquals("bar", ((EclipseLinkConvert) ormIdMapping.getConverter()).getSpecifiedConverterName());
-
- ((EclipseLinkConvert) ormIdMapping.getConverter()).setSpecifiedConverterName(null);
-
- assertNull(ormIdMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
-
- //set lob to false in the context model
- ormIdMapping.setConverter(null);
- assertNull(ormIdMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToManyMappingTests.java
deleted file mode 100644
index 5e7e168e4b..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToManyMappingTests.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.Cascade;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkManyToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlManyToMany;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmManyToManyMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmManyToManyMappingTests(String name) {
- super(name);
- }
-
- private void createTestDepartment() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append("import java.util.Collection;");
- sb.append(CR);
- sb.append("import ").append(JPA.MANY_TO_MANY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.JOIN_TABLE).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.JOIN_COLUMN).append(";");
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Department").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(" @ManyToMany").append(CR);
- sb.append(" @JoinTable(name=\"DEP_EMP\", joinColumns=@JoinColumn(name=\"DEPT_ID\"), inverseJoinColumns=@JoinColumn(name=\"EMP_ID\"))").append(CR);
- sb.append(" private Collection<Employee> employees;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Department.java", sourceWriter);
- }
-
- private void createTestEmployee() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Employee").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int empId;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Employee.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, JPA.ORDER_BY, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany(fetch=FetchType.EAGER, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH})");
- sb.append(CR);
- sb.append(" @OrderBy(\"city\"");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" private java.util.Collection<Address> address;").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(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(" 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);
- }
-
- public void testUpdateJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
- EclipseLinkRelationshipMapping contextManyToMany =
- (EclipseLinkRelationshipMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity) getXmlEntityMappings().getEntities().get(0);
- XmlManyToMany resourceManyToMany =
- (XmlManyToMany) resourceEntity.getAttributes().getManyToManys().get(0);
-
- // check defaults
-
- assertNull(resourceManyToMany.getJoinFetch());
- assertNull(contextManyToMany.getJoinFetch().getValue());
-
- // set xml join fetch to INNER, check context
-
- resourceManyToMany.setJoinFetch(XmlJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceManyToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextManyToMany.getJoinFetch().getValue());
-
- // set xml join fetch to OUTER, check context
-
- resourceManyToMany.setJoinFetch(XmlJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceManyToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextManyToMany.getJoinFetch().getValue());
-
- // set xml join fetch to null, check context
-
- resourceManyToMany.setJoinFetch(null);
-
- assertNull(resourceManyToMany.getJoinFetch());
- assertNull(contextManyToMany.getJoinFetch().getValue());
- }
-
- public void testModifyJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToMany");
- EclipseLinkRelationshipMapping contextManyToMany =
- (EclipseLinkRelationshipMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlManyToMany resourceManyToMany =
- (XmlManyToMany) resourceEntity.getAttributes().getManyToManys().get(0);
-
- // check defaults
-
- assertNull(resourceManyToMany.getJoinFetch());
- assertNull(contextManyToMany.getJoinFetch().getValue());
-
- // set context join fetch to INNER, check resource
-
- contextManyToMany.getJoinFetch().setValue(EclipseLinkJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceManyToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextManyToMany.getJoinFetch().getValue());
-
- // set context join fetch to OUTER, check resource
-
- contextManyToMany.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceManyToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextManyToMany.getJoinFetch().getValue());
-
- // set context join fetch to null, check resource
-
- contextManyToMany.getJoinFetch().setValue(null);
-
- assertNull(resourceManyToMany.getJoinFetch());
- assertNull(contextManyToMany.getJoinFetch().getValue());
- }
-
- public void testJoinFetchDefault() throws Exception {
- createTestEmployee();
- createTestDepartment();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Department");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Employee");
-
- OrmPersistentType departmentPersistentType = getEntityMappings().getPersistentTypes().iterator().next();
- EclipseLinkRelationshipMapping manyToMany = (EclipseLinkRelationshipMapping) departmentPersistentType.getAttributeNamed("employees").getMapping();
-
- assertNull(manyToMany.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- EclipseLinkOneToManyMapping oneToMany = (EclipseLinkOneToManyMapping) departmentPersistentType.getAttributeNamed("employees").getMapping();
- assertNull(oneToMany.getJoinFetch().getValue());
-
-
- EclipseLinkRelationshipMapping javaRelationshipMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getJavaPersistentType().getAttributeNamed("employees").getMapping();
- javaRelationshipMapping.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
- assertNull(oneToMany.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- manyToMany = (EclipseLinkRelationshipMapping) departmentPersistentType.getAttributeNamed("employees").getMapping();
- assertEquals(EclipseLinkJoinFetchType.OUTER, manyToMany.getJoinFetch().getValue());
- }
-
- public void testDefaultJoinTable() throws Exception {
- createTestEmployee();
- createTestDepartment();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Department");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Employee");
-
- OrmPersistentType departmentPersistentType = getEntityMappings().getPersistentTypes().iterator().next();
- OrmReadOnlyPersistentAttribute attribute = departmentPersistentType.getAttributeNamed("employees");
- ManyToManyMapping manyToMany = (ManyToManyMapping) attribute.getMapping();
-
- assertEquals(true, attribute.isVirtual());
- JoinTable ormJoinTable = manyToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("DEP_EMP", ormJoinTable.getName());
- assertEquals("DEPT_ID", ormJoinTable.specifiedJoinColumns().next().getName());
- assertEquals("id", ormJoinTable.specifiedJoinColumns().next().getReferencedColumnName());
- assertEquals("EMP_ID", ormJoinTable.specifiedInverseJoinColumns().next().getName());
- assertEquals("empId", ormJoinTable.specifiedInverseJoinColumns().next().getReferencedColumnName());
-
- //set metadata-complete and verify JoinTable info is not taken from the java
- departmentPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- departmentPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
- attribute = departmentPersistentType.getAttributeNamed("employees");
- OneToManyMapping oneToMany = (OneToManyMapping) attribute.getMapping();
-
- assertEquals(true, attribute.isVirtual());
- ormJoinTable = oneToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("Department_Employee", ormJoinTable.getName());
- assertEquals("Department_id", ormJoinTable.getDefaultJoinColumn().getName());
- assertEquals("id", ormJoinTable.getDefaultJoinColumn().getReferencedColumnName());
- assertEquals("employees_empId", ormJoinTable.getDefaultInverseJoinColumn().getName());
- assertEquals("empId", ormJoinTable.getDefaultInverseJoinColumn().getReferencedColumnName());
-
- //set metadata-complete to false, add mapping to orm.xml verify JoinTable info is not taken from the java
- departmentPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.FALSE);
- attribute = departmentPersistentType.getAttributeNamed("employees");
- manyToMany = (ManyToManyMapping) attribute.getMapping();
- assertEquals(true, attribute.isVirtual());
- ormJoinTable = manyToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("DEP_EMP", ormJoinTable.getName());
- assertEquals("DEPT_ID", ormJoinTable.specifiedJoinColumns().next().getName());
- assertEquals("id", ormJoinTable.specifiedJoinColumns().next().getReferencedColumnName());
- assertEquals("EMP_ID", ormJoinTable.specifiedInverseJoinColumns().next().getName());
- assertEquals("empId", ormJoinTable.specifiedInverseJoinColumns().next().getReferencedColumnName());
-
-
- departmentPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "employees");
- attribute = departmentPersistentType.getAttributeNamed("employees");
- manyToMany = (ManyToManyMapping) attribute.getMapping();
- assertEquals(false, attribute.isVirtual());
- ormJoinTable = manyToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("Department_Employee", ormJoinTable.getName());
- assertEquals(0, ormJoinTable.specifiedJoinColumnsSize());
- assertEquals("Department_id", ormJoinTable.getDefaultJoinColumn().getName());
- assertEquals("id", ormJoinTable.getDefaultJoinColumn().getReferencedColumnName());
- assertEquals(0, ormJoinTable.specifiedInverseJoinColumnsSize());
- assertEquals("employees_empId", ormJoinTable.getDefaultInverseJoinColumn().getName());
- assertEquals("empId", ormJoinTable.getDefaultInverseJoinColumn().getReferencedColumnName());
- }
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityManyToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualManyToManyMapping.getName());
- assertEquals(FetchType.EAGER, virtualManyToManyMapping.getSpecifiedFetch());
- assertEquals("Address", virtualManyToManyMapping.getSpecifiedTargetEntity());
- assertNull(virtualManyToManyMapping.getRelationship().
- getMappedByStrategy().getMappedByAttribute());
-
- Cascade cascade = virtualManyToManyMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
-
- assertTrue(virtualManyToManyMapping.getOrderable().isCustomOrdering());
- assertEquals("city", virtualManyToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertEquals(EclipseLinkJoinFetchType.INNER, ((EclipseLinkJoinFetchMapping) virtualManyToManyMapping).getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityManyToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
- assertTrue(virtualPersistentAttribute.isVirtual());
-
- OrmPersistentAttribute ormPersistentAttribute = virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
-
- OrmEclipseLinkManyToManyMapping ormManyToManyMapping = (OrmEclipseLinkManyToManyMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormManyToManyMapping.getName());
- assertEquals(FetchType.LAZY, ormManyToManyMapping.getFetch());
- assertEquals("test.Address", ormManyToManyMapping.getTargetEntity());
- assertNull(ormManyToManyMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
-
- Cascade cascade = ormManyToManyMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
-
- assertTrue(ormManyToManyMapping.getOrderable().isNoOrdering());
- assertEquals(null, ormManyToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertEquals(null, ormManyToManyMapping.getJoinFetch().getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToOneMappingTests.java
deleted file mode 100644
index 97930e67d2..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmManyToOneMappingTests.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.Cascade;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToOneMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkManyToOneMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlManyToOne;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmManyToOneMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmManyToOneMappingTests(String name) {
- super(name);
- }
-
- private void createTestDepartment() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("import ").append(JPA.MANY_TO_ONE).append(";");
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Department").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(" @ManyToOne").append(CR);
- sb.append(" private Employee employee;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Department.java", sourceWriter);
- }
-
- private void createTestEmployee() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Employee").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int empId;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Employee.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityManyToOneMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, JPA.JOIN_COLUMN, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToOne(fetch=FetchType.LAZY, optional=false, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH})");
- sb.append(CR);
- sb.append(" @JoinColumn(name=\"MY_COLUMN\", referencedColumnName=\"MY_REFERENCED_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\")");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" private Address address;").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(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(" private String 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);
- }
-
- public void testUpdateJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOne");
- EclipseLinkRelationshipMapping contextManyToOne =
- (EclipseLinkRelationshipMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity) getXmlEntityMappings().getEntities().get(0);
- XmlManyToOne resourceManyToOne =
- (XmlManyToOne) resourceEntity.getAttributes().getManyToOnes().get(0);
-
- // check defaults
-
- assertNull(resourceManyToOne.getJoinFetch());
- assertNull(contextManyToOne.getJoinFetch().getValue());
-
- // set xml join fetch to INNER, check context
-
- resourceManyToOne.setJoinFetch(XmlJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceManyToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextManyToOne.getJoinFetch().getValue());
-
- // set xml join fetch to OUTER, check context
-
- resourceManyToOne.setJoinFetch(XmlJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceManyToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextManyToOne.getJoinFetch().getValue());
-
- // set xml join fetch to null, check context
-
- resourceManyToOne.setJoinFetch(null);
-
- assertNull(resourceManyToOne.getJoinFetch());
- assertNull(contextManyToOne.getJoinFetch().getValue());
- }
-
- public void testModifyJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "manyToOne");
- EclipseLinkRelationshipMapping contextManyToOne =
- (EclipseLinkRelationshipMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlManyToOne resourceManyToOne =
- (XmlManyToOne) resourceEntity.getAttributes().getManyToOnes().get(0);
-
- // check defaults
-
- assertNull(resourceManyToOne.getJoinFetch());
- assertNull(contextManyToOne.getJoinFetch().getValue());
-
- // set context join fetch to INNER, check resource
-
- contextManyToOne.getJoinFetch().setValue(EclipseLinkJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceManyToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextManyToOne.getJoinFetch().getValue());
-
- // set context join fetch to OUTER, check resource
-
- contextManyToOne.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceManyToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextManyToOne.getJoinFetch().getValue());
-
- // set context join fetch to null, check resource
-
- contextManyToOne.getJoinFetch().setValue(null);
-
- assertNull(resourceManyToOne.getJoinFetch());
- assertNull(contextManyToOne.getJoinFetch().getValue());
- }
-
- public void testJoinFetchDefaultFromJava() throws Exception {
- createTestEmployee();
- createTestDepartment();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Department");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Employee");
-
- OrmPersistentType departmentPersistentType = getEntityMappings().getPersistentTypes().iterator().next();
- EclipseLinkRelationshipMapping manyToOneMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
-
- assertNull(manyToOneMapping.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- EclipseLinkOneToOneMapping oneToOne = (EclipseLinkOneToOneMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
- assertNull(oneToOne.getJoinFetch().getValue());
-
-
- EclipseLinkRelationshipMapping javaRelationshipMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getJavaPersistentType().getAttributeNamed("employee").getMapping();
- javaRelationshipMapping.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
- manyToOneMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
- assertNull(manyToOneMapping.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- manyToOneMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
- assertEquals(EclipseLinkJoinFetchType.OUTER, manyToOneMapping.getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityManyToOneMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- ManyToOneMapping virtualManyToOneMapping = (ManyToOneMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualManyToOneMapping.getName());
- assertEquals(FetchType.LAZY, virtualManyToOneMapping.getSpecifiedFetch());
- assertEquals(Boolean.FALSE, virtualManyToOneMapping.getSpecifiedOptional());
- assertEquals("Address", virtualManyToOneMapping.getSpecifiedTargetEntity());
-
- JoinColumn virtualJoinColumn = virtualManyToOneMapping.getRelationship().getJoinColumnStrategy().specifiedJoinColumns().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.getSpecifiedTable());
-
- Cascade cascade = virtualManyToOneMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
-
- assertEquals(EclipseLinkJoinFetchType.INNER, ((EclipseLinkJoinFetchMapping) virtualManyToOneMapping).getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityManyToOneMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
- assertTrue(virtualPersistentAttribute.isVirtual());
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
-
- OrmEclipseLinkManyToOneMapping ormManyToOneMapping = (OrmEclipseLinkManyToOneMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormManyToOneMapping.getName());
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getDefaultFetch());
- assertEquals(true, ormManyToOneMapping.isDefaultOptional());
- assertEquals("test.Address", ormManyToOneMapping.getDefaultTargetEntity());
-
- Cascade cascade = ormManyToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
-
- assertEquals(null, ormManyToOneMapping.getJoinFetch().getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmMappedSuperclassTests.java
deleted file mode 100644
index ebb5dd821e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmMappedSuperclassTests.java
+++ /dev/null
@@ -1,2147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheCoordinationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkExistenceType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmMappedSuperclassTests extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmMappedSuperclassTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTestMappedSuperclassForReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForCustomizer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CHANGE_TRACKING);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForCaching() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForObjectTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForStructConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- public void testUpdateReadOnly() throws Exception {
- createTestMappedSuperclassForReadOnly();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkMappedSuperclass javaContextMappedSuperclass = (JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to false, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // clear xml read only, set java read only to true, check defaults
-
- resourceMappedSuperclass.setReadOnly(null);
- javaContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- // set xml read only to false, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // clear xml read only, set java read only to false, check defaults
-
- resourceMappedSuperclass.setReadOnly(null);
- javaContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.FALSE);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to false, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
- }
-
- public void testModifyReadOnly() throws Exception {
- createTestMappedSuperclassForReadOnly();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to true, check resource
-
- ormContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to false, check resource
-
- ormContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to null, check resource
-
- ormContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(null);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
- }
-
- public void testUpdateCustomizerClass() throws Exception {
- createTestMappedSuperclassForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkMappedSuperclass javaContextMappedSuperclass = (JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set xml customizer, check defaults
- resourceMappedSuperclass.setCustomizer(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(resourceMappedSuperclass.getCustomizer().getClassName());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
-
- // set xml customizer class, check override
-
- resourceMappedSuperclass.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceMappedSuperclass.getCustomizer().getClassName());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // clear xml customizer class, set java customizer class, check defaults
-
- resourceMappedSuperclass.getCustomizer().setClassName(null);
- javaContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass("bar");
-
- assertNull(resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("bar", javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("bar", javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- // set xml customizer class, check override
-
- resourceMappedSuperclass.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("bar", javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- //set xml customizer null
- javaContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass(null);
- resourceMappedSuperclass.setCustomizer(null);
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- }
-
- public void testModifyCustomizerClass() throws Exception {
- createTestMappedSuperclassForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer, check resource
-
- ormContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass("foo");
-
- assertEquals("foo", resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer to null, check resource
-
- ormContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass(null);
-
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
- }
-
- public void testUpdateChangeTracking() throws Exception {
- createTestMappedSuperclassForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkMappedSuperclass javaContextMappedSuperclass = (JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to ATTRIBUTE, check context
-
- resourceMappedSuperclass.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to OBJECT, check context
-
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to DEFERRED, check context
-
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to AUTO, check context
-
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // clear xml change tracking, set java change tracking, check defaults
-
- resourceMappedSuperclass.setChangeTracking(null);
- javaContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // unset metadataComplete, set xml change tracking to OBJECT, check context
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- resourceMappedSuperclass.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
- }
-
- public void testModifyChangeTracking() throws Exception {
- createTestMappedSuperclassForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to ATTRIBUTE, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to OBJECT, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to DEFERRED, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to AUTO, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to null, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(null);
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
- }
-
- public void testUpdateCacheType() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // set xml cache type, check settings
- resourceMappedSuperclass.getCache().setType(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getSpecifiedType());
-
-
- // set java cache type, check defaults
-
- javaContextCaching.setSpecifiedType(EclipseLinkCacheType.WEAK);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getSpecifiedType());
-
- // clear xml cache type, check defaults
- resourceMappedSuperclass.getCache().setType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheType() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- // set context cache type, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedType(EclipseLinkCacheType.HARD_WEAK);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.HARD_WEAK, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, ormContextCaching.getSpecifiedType());
-
- // set context customizer to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
- }
-
- public void testUpdateCacheCoordinationType() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set xml cache type, check settings
- resourceMappedSuperclass.getCache().setCoordinationType(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set java cache type, check defaults
-
- javaContextCaching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getSpecifiedCoordinationType());
-
- // clear xml cache type, check defaults
- resourceMappedSuperclass.getCache().setCoordinationType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheCoordinationType() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- // set context cache coordination type, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getSpecifiedCoordinationType());
-
- // set context coordination type to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedCoordinationType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
- }
-
-
- public void testUpdateCacheSize() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getSize());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setSize(new Integer(105));
- assertEquals(new Integer(105), resourceMappedSuperclass.getCache().getSize());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(105, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(105), ormContextCaching.getSpecifiedSize());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedSize(new Integer(50));
-
- assertEquals(new Integer(105), resourceMappedSuperclass.getCache().getSize());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(105, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(105), ormContextCaching.getSpecifiedSize());
-
- // clear xml cache size, check defaults
- resourceMappedSuperclass.getCache().setSize(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getSize());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(50, ormContextCaching.getSize());
- assertEquals(50, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheSize() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedSize(new Integer(50));
- assertEquals(new Integer(50), resourceMappedSuperclass.getCache().getSize());
- assertEquals(50, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(50), ormContextCaching.getSpecifiedSize());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedSize(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
- }
-
- public void testUpdateCacheAlwaysRefresh() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set xml cache always refresh, check settings
- resourceMappedSuperclass.getCache().setAlwaysRefresh(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set java cache always refresh, check defaults
-
- javaContextCaching.setSpecifiedAlwaysRefresh(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setAlwaysRefresh(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setAlwaysRefresh(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- }
-
- public void testModifyCacheAlwaysRefresh() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedAlwaysRefresh(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedAlwaysRefresh(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- }
-
- public void testUpdateCacheRefreshOnlyIfNewer() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setRefreshOnlyIfNewer(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setRefreshOnlyIfNewer(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setRefreshOnlyIfNewer(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- }
-
- public void testModifyCacheRefreshOnlyIfNewer() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedRefreshOnlyIfNewer(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- }
-
- public void testUpdateCacheDisableHits() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setDisableHits(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedDisableHits(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setDisableHits(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedDisableHits());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setDisableHits(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- }
-
- public void testModifyCacheDisableHits() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedDisableHits(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedDisableHits(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- }
-
- public void testUpdateCacheShared() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getShared());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedShared(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setShared(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedShared());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setShared(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(false, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(false, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
- }
-
- public void testModifyCacheShared() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedShared(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
- }
-
- public void testUpdateExistenceChecking() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set xml existence checking, check settings
- resourceMappedSuperclass.setExistenceChecking(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
-
- // set java cache existence checking, check defaults
-
- javaContextCaching.setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- // clear xml existence checking, check defaults
- resourceMappedSuperclass.setExistenceChecking(null);
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyExistenceChecking() throws Exception {
- createTestMappedSuperclassForCaching();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set context cache existence checking, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_EXISTENCE);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- // set context existence checking to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedExistenceType(null);
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
- }
- public void testUpdateCustomConverters() throws Exception {
- createTestMappedSuperclassForConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceMappedSuperclass.getConverters().add(resourceConverter);
- resourceConverter.setClassName("Foo");
- resourceConverter.setName("myConverter");
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlConverter resourceConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceMappedSuperclass.getConverters().add(0, resourceConverter2);
- resourceConverter2.setClassName("Foo2");
- resourceConverter2.setName("myConverter2");
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getConverters().remove(resourceConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyCustomConverters() throws Exception {
- createTestMappedSuperclassForConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter(0);
- contextConverter.setConverterClass("Foo");
- contextConverter.setName("myConverter");
-
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter(0);
- contextConverter2.setConverterClass("Foo2");
- contextConverter2.setName("myConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getConverters().get(1).getClassName());
- assertEquals("myConverter", resourceMappedSuperclass.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveCustomConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getConverters().get(1).getClassName());
- assertEquals("myConverter2", resourceMappedSuperclass.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(contextConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateTypeConverters() throws Exception {
- createTestMappedSuperclassForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceMappedSuperclass.getTypeConverters().add(resourceTypeConverter);
- resourceTypeConverter.setDataType("Foo");
- resourceTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceMappedSuperclass.getTypeConverters().add(0, resourceTypeConverter2);
- resourceTypeConverter2.setDataType("Foo2");
- resourceTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getTypeConverters().remove(resourceTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyTypeConverters() throws Exception {
- createTestMappedSuperclassForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter.setDataType("Foo");
- contextTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter2.setDataType("Foo2");
- contextTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter", resourceMappedSuperclass.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveTypeConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter2", resourceMappedSuperclass.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(contextTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateObjectTypeConverters() throws Exception {
- createTestMappedSuperclassForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceMappedSuperclass.getObjectTypeConverters().add(resourceObjectTypeConverter);
- resourceObjectTypeConverter.setDataType("Foo");
- resourceObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceMappedSuperclass.getObjectTypeConverters().add(0, resourceObjectTypeConverter2);
- resourceObjectTypeConverter2.setDataType("Foo2");
- resourceObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getObjectTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getObjectTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getObjectTypeConverters().remove(resourceObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyObjectTypeConverters() throws Exception {
- createTestMappedSuperclassForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter.setDataType("Foo");
- contextObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter2.setDataType("Foo2");
- contextObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter", resourceMappedSuperclass.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveObjectTypeConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter2", resourceMappedSuperclass.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(contextObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateStructConverters() throws Exception {
- createTestMappedSuperclassForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlStructConverter resourceStructConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceMappedSuperclass.getStructConverters().add(resourceStructConverter);
- resourceStructConverter.setConverter("Foo");
- resourceStructConverter.setName("myStructConverter");
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlStructConverter resourceStructConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceMappedSuperclass.getStructConverters().add(0, resourceStructConverter2);
- resourceStructConverter2.setConverter("Foo2");
- resourceStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getStructConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getStructConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getStructConverters().remove(resourceStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyStructConverters() throws Exception {
- createTestMappedSuperclassForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter.setConverterClass("Foo");
- contextStructConverter.setName("myStructConverter");
-
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter2.setConverterClass("Foo2");
- contextStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter", resourceMappedSuperclass.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveStructConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter2", resourceMappedSuperclass.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(contextStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmObjectTypeConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmObjectTypeConverterTests.java
deleted file mode 100644
index 2189d0cdc9..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmObjectTypeConverterTests.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConversionValue;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.JavaEclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConversionValue;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmObjectTypeConverterTests
- extends EclipseLinkOrmContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.CONVERT, EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append(" @Convert(name=\"foo\")").append(CR);
- sb.append(" @ObjectTypeConverter");
- }
- });
- }
-
-
- private ICompilationUnit createTestEntityWithConvertAndObjectTypeConverterConversionValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, EclipseLink.CONVERT, EclipseLink.OBJECT_TYPE_CONVERTER, EclipseLink.CONVERSION_VALUE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(\"foo\")").append(CR);
- sb.append(" @ObjectTypeConverter(name=\"foo\", defaultObjectValue=\"bar\", conversionValues = @ConversionValue(dataValue=\"f\", objectValue=\"female\"))");
- }
- });
- }
-
- public EclipseLinkOrmObjectTypeConverterTests(String name) {
- super(name);
- }
-
-
- public void testUpdateDataType() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setDataType("myConvert");
- assertEquals("myConvert", ormConverter.getDataType());
- assertEquals("myConvert", converterResource.getDataType());
-
- //set converter class name to null in the resource model
- converterResource.setDataType(null);
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkObjectTypeConverter javaConverter = ((EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setDataType("bar");
- assertEquals("bar", ormConverter.getDataType());
- assertEquals("bar", javaConverter.getDataType());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getDataType());
- }
-
- public void testModifyDataType() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
-
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setDataType("foo");
- assertEquals("foo", ormConverter.getDataType());
- assertEquals("foo", converterResource.getDataType());
-
- ormConverter.setDataType(null);
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
- }
-
- public void testUpdateObjectType() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setObjectType("myConvert");
- assertEquals("myConvert", ormConverter.getObjectType());
- assertEquals("myConvert", converterResource.getObjectType());
-
- //set converter class name to null in the resource model
- converterResource.setObjectType(null);
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkObjectTypeConverter javaConverter = ((EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setObjectType("bar");
- assertEquals("bar", ormConverter.getObjectType());
- assertEquals("bar", javaConverter.getObjectType());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getObjectType());
- }
-
- public void testModifyObjectType() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
-
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setObjectType("foo");
- assertEquals("foo", ormConverter.getObjectType());
- assertEquals("foo", converterResource.getObjectType());
-
- ormConverter.setObjectType(null);
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- OrmEclipseLinkObjectTypeConverter ormConverter = (OrmEclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setName("myConvert");
- assertEquals("myConvert", ormConverter.getName());
- assertEquals("myConvert", converterResource.getName());
-
- //set converter class name to null in the resource model
- converterResource.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
-
- //remove the specified persistent attribute, test virtual mapping
-
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- EclipseLinkObjectTypeConverter virtualConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkObjectTypeConverter javaConverter = ((EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setName("bar");
- assertEquals("bar", virtualConverter.getName());
- assertEquals("bar", javaConverter.getName());
-
-
- //set metadata-complete, test virtual mapping
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- OrmEclipseLinkObjectTypeConverter ormConverter = (OrmEclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setName("foo");
- assertEquals("foo", ormConverter.getName());
- assertEquals("foo", converterResource.getName());
-
- ormConverter.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
- }
-
- public void testUpdateDefaultObjectValue() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getDefaultObjectValue());
- assertEquals(null, converterResource.getDefaultObjectValue());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setDefaultObjectValue("myConvert");
- assertEquals("myConvert", ormConverter.getDefaultObjectValue());
- assertEquals("myConvert", converterResource.getDefaultObjectValue());
-
- //set converter class name to null in the resource model
- converterResource.setDefaultObjectValue(null);
- assertEquals(null, ormConverter.getDefaultObjectValue());
- assertEquals(null, converterResource.getDefaultObjectValue());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkObjectTypeConverter javaConverter = ((EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setDefaultObjectValue("bar");
- assertEquals("bar", ormConverter.getDefaultObjectValue());
- assertEquals("bar", javaConverter.getDefaultObjectValue());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getDefaultObjectValue());
- }
-
- public void testModifyDefaultObjectValue() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
-
- assertEquals(null, ormConverter.getDefaultObjectValue());
- assertEquals(null, converterResource.getDefaultObjectValue());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setDefaultObjectValue("foo");
- assertEquals("foo", ormConverter.getDefaultObjectValue());
- assertEquals("foo", converterResource.getDefaultObjectValue());
-
- ormConverter.setDefaultObjectValue(null);
- assertEquals(null, ormConverter.getDefaultObjectValue());
- assertEquals(null, converterResource.getDefaultObjectValue());
- }
-
-
- public void testUpdateConversionValues() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(0, ormConverter.conversionValuesSize());
- assertEquals(0, converterResource.getConversionValues().size());
-
- //add conversion value to resource model, check context model
- XmlConversionValue resourceConversionValue = EclipseLinkOrmFactory.eINSTANCE.createXmlConversionValue();
- converterResource.getConversionValues().add(resourceConversionValue);
- resourceConversionValue.setDataValue("foo");
- resourceConversionValue.setObjectValue("bar");
-
- assertEquals(1, ormConverter.conversionValuesSize());
- ListIterator<EclipseLinkConversionValue> contextConversionValues = ormConverter.conversionValues();
- EclipseLinkConversionValue contextConversionValue = contextConversionValues.next();
- assertEquals("foo", contextConversionValue.getDataValue());
- assertEquals("bar", contextConversionValue.getObjectValue());
- assertEquals(1, converterResource.getConversionValues().size());
- assertEquals("foo", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar", converterResource.getConversionValues().get(0).getObjectValue());
-
- //add a conversion to the beginning of the resource model list
- XmlConversionValue xmlConversionValue2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConversionValue();
- converterResource.getConversionValues().add(0, xmlConversionValue2);
- xmlConversionValue2.setDataValue("foo2");
- xmlConversionValue2.setObjectValue("bar2");
-
- assertEquals(2, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo2", contextConversionValue.getDataValue());
- assertEquals("bar2", contextConversionValue.getObjectValue());
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo", contextConversionValue.getDataValue());
- assertEquals("bar", contextConversionValue.getObjectValue());
- assertEquals(2, converterResource.getConversionValues().size());
- assertEquals("foo2", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar2", converterResource.getConversionValues().get(0).getObjectValue());
- assertEquals("foo", converterResource.getConversionValues().get(1).getDataValue());
- assertEquals("bar", converterResource.getConversionValues().get(1).getObjectValue());
-
- //move a conversion value in the resource model list
-
- converterResource.getConversionValues().move(0, 1);
- assertEquals(2, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo", contextConversionValue.getDataValue());
- assertEquals("bar", contextConversionValue.getObjectValue());
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo2", contextConversionValue.getDataValue());
- assertEquals("bar2", contextConversionValue.getObjectValue());
- assertEquals(2, converterResource.getConversionValues().size());
- assertEquals("foo", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar", converterResource.getConversionValues().get(0).getObjectValue());
- assertEquals("foo2", converterResource.getConversionValues().get(1).getDataValue());
- assertEquals("bar2", converterResource.getConversionValues().get(1).getObjectValue());
-
- //remove a conversion value from the resource model list
-
- converterResource.getConversionValues().remove(0);
- assertEquals(1, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo2", contextConversionValue.getDataValue());
- assertEquals("bar2", contextConversionValue.getObjectValue());
- assertEquals(1, converterResource.getConversionValues().size());
- assertEquals("foo2", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar2", converterResource.getConversionValues().get(0).getObjectValue());
-
- //clear the conversion value resource model list
- converterResource.getConversionValues().clear();
- assertEquals(0, ormConverter.conversionValuesSize());
- assertEquals(0, converterResource.getConversionValues().size());
-
- //add conversion value to java context model, verify does not affect orm context model
-
- EclipseLinkObjectTypeConverter javaConverter = (EclipseLinkObjectTypeConverter) ((JavaEclipseLinkConvert) javaBasicMapping.getConverter()).getConverter();
- EclipseLinkConversionValue javaConversionValue = javaConverter.addConversionValue();
- javaConversionValue.setDataValue("baz");
-
- assertEquals(0, ormConverter.conversionValuesSize());
- assertEquals(0, converterResource.getConversionValues().size());
- assertEquals(1, javaConverter.conversionValuesSize());
-
- //remove orm attribute mapping, verify virtual mapping has conversion values from java
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- assertEquals(1, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("baz", contextConversionValue.getDataValue());
- assertEquals(0, converterResource.getConversionValues().size());
- assertEquals(1, javaConverter.conversionValuesSize());
-
- //set metadata-complete to true, verify virtual mapping ignores the conversion values from java
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- }
-
- public void testModifyConversionValues() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkObjectTypeConverter.class);
- EclipseLinkObjectTypeConverter ormConverter = (EclipseLinkObjectTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlObjectTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getObjectTypeConverter();
-
- assertEquals(0, ormConverter.conversionValuesSize());
- assertEquals(0, converterResource.getConversionValues().size());
-
- //add conversion value to context model, check resource model
- EclipseLinkConversionValue contextConversionValue = ormConverter.addConversionValue();
- contextConversionValue.setDataValue("foo");
- contextConversionValue.setObjectValue("bar");
-
- assertEquals(1, ormConverter.conversionValuesSize());
- ListIterator<EclipseLinkConversionValue> contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo", contextConversionValue.getDataValue());
- assertEquals("bar", contextConversionValue.getObjectValue());
- assertEquals(1, converterResource.getConversionValues().size());
- assertEquals("foo", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar", converterResource.getConversionValues().get(0).getObjectValue());
-
- //add a conversion to the beginning of the context model list
- EclipseLinkConversionValue contextConversionValue2 = ormConverter.addConversionValue(0);
- contextConversionValue2.setDataValue("foo2");
- contextConversionValue2.setObjectValue("bar2");
-
- assertEquals(2, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo2", contextConversionValue.getDataValue());
- assertEquals("bar2", contextConversionValue.getObjectValue());
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo", contextConversionValue.getDataValue());
- assertEquals("bar", contextConversionValue.getObjectValue());
- assertEquals(2, converterResource.getConversionValues().size());
- assertEquals("foo2", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar2", converterResource.getConversionValues().get(0).getObjectValue());
- assertEquals("foo", converterResource.getConversionValues().get(1).getDataValue());
- assertEquals("bar", converterResource.getConversionValues().get(1).getObjectValue());
-
- //move a conversion value in the context model list
-
- ormConverter.moveConversionValue(0, 1);
- assertEquals(2, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo", contextConversionValue.getDataValue());
- assertEquals("bar", contextConversionValue.getObjectValue());
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo2", contextConversionValue.getDataValue());
- assertEquals("bar2", contextConversionValue.getObjectValue());
- assertEquals(2, converterResource.getConversionValues().size());
- assertEquals("foo", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar", converterResource.getConversionValues().get(0).getObjectValue());
- assertEquals("foo2", converterResource.getConversionValues().get(1).getDataValue());
- assertEquals("bar2", converterResource.getConversionValues().get(1).getObjectValue());
-
- //remove a conversion value from the context model list
-
- ormConverter.removeConversionValue(0);
- assertEquals(1, ormConverter.conversionValuesSize());
- contextConversionValues = ormConverter.conversionValues();
- contextConversionValue = contextConversionValues.next();
- assertEquals("foo2", contextConversionValue.getDataValue());
- assertEquals("bar2", contextConversionValue.getObjectValue());
- assertEquals(1, converterResource.getConversionValues().size());
- assertEquals("foo2", converterResource.getConversionValues().get(0).getDataValue());
- assertEquals("bar2", converterResource.getConversionValues().get(0).getObjectValue());
-
- //clear the conversion value resource model list
- ormConverter.removeConversionValue(0);
- assertEquals(0, ormConverter.conversionValuesSize());
- assertEquals(0, converterResource.getConversionValues().size());
- }
-
- public void testInitializeConversionValues() throws Exception {
- createTestEntityWithConvertAndObjectTypeConverterConversionValue();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- BasicMapping ormBasicMapping = (BasicMapping) ormPersistentAttribute.getMapping();
- EclipseLinkConvert eclipseLinkConvert = (EclipseLinkConvert) ormBasicMapping.getConverter();
- EclipseLinkObjectTypeConverter converter = (EclipseLinkObjectTypeConverter) eclipseLinkConvert.getConverter();
-
- assertEquals(1, converter.conversionValuesSize());
- assertEquals("f", converter.conversionValues().next().getDataValue());
- assertEquals("female", converter.conversionValues().next().getObjectValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java
deleted file mode 100644
index e9a4c2f46f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToManyMappingTests.java
+++ /dev/null
@@ -1,747 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.Cascade;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkOneToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.EclipseLinkOneToManyRelationship2_0;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmOneToManyMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmOneToManyMappingTests(String name) {
- super(name);
- }
-
- private void createTestDepartment() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append("import java.util.Collection;");
- sb.append(CR);
- sb.append("import ").append(JPA.JOIN_TABLE).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.JOIN_COLUMN).append(";");
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Department").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(" @JoinTable(name=\"DEP_EMP\", joinColumns=@JoinColumn(name=\"DEPT_ID\"), inverseJoinColumns=@JoinColumn(name=\"EMP_ID\"))").append(CR);
- sb.append(" private Collection<Employee> employees;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Department.java", sourceWriter);
- }
-
- private void createTestEmployee() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Employee").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int empId;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Employee.java", sourceWriter);
- }
-
- 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(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(" 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 createTestEntityWithOneToManyMapping() throws Exception {
- createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany").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 createTestEntityWithValidMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- 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);
- }
-
- private ICompilationUnit createTestEntityOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, JPA.ORDER_BY, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany(fetch=FetchType.EAGER, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH})");
- sb.append(CR);
- sb.append(" @OrderBy(\"city\"");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(" private java.util.Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- public void testUpdatePrivateOwned() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
- EclipseLinkOneToManyMapping contextOneToMany =
- (EclipseLinkOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity) getXmlEntityMappings().getEntities().get(0);
- XmlOneToMany resourceOneToMany =
- (XmlOneToMany) resourceEntity.getAttributes().getOneToManys().get(0);
-
- // check defaults
-
- assertFalse(resourceOneToMany.isPrivateOwned());
- assertFalse(contextOneToMany.getPrivateOwned().isPrivateOwned());
-
- // set xml private owned to true, check context
-
- resourceOneToMany.setPrivateOwned(true);
-
- assertTrue(resourceOneToMany.isPrivateOwned());
- assertTrue(contextOneToMany.getPrivateOwned().isPrivateOwned());
-
- // set xml private owned back to false, check context
-
- resourceOneToMany.setPrivateOwned(false);
-
- assertFalse(resourceOneToMany.isPrivateOwned());
- assertFalse(contextOneToMany.getPrivateOwned().isPrivateOwned());
- }
-
- public void testModifyPrivateOwned() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
- EclipseLinkOneToManyMapping contextOneToMany =
- (EclipseLinkOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlOneToMany resourceOneToMany =
- (XmlOneToMany) resourceEntity.getAttributes().getOneToManys().get(0);
-
- // check defaults
-
- assertFalse(resourceOneToMany.isPrivateOwned());
- assertFalse(contextOneToMany.getPrivateOwned().isPrivateOwned());
-
- // set context private owned to true, check resource
-
- contextOneToMany.getPrivateOwned().setPrivateOwned(true);
-
- assertTrue(resourceOneToMany.isPrivateOwned());
- assertTrue(contextOneToMany.getPrivateOwned().isPrivateOwned());
-
- // set context private owned back to false, check resource
-
- contextOneToMany.getPrivateOwned().setPrivateOwned(false);
-
- assertFalse(resourceOneToMany.isPrivateOwned());
- assertFalse(contextOneToMany.getPrivateOwned().isPrivateOwned());
- }
-
- public void testUpdateJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
- EclipseLinkOneToManyMapping contextOneToMany =
- (EclipseLinkOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity) getXmlEntityMappings().getEntities().get(0);
- XmlOneToMany resourceOneToMany =
- (XmlOneToMany) resourceEntity.getAttributes().getOneToManys().get(0);
-
- // check defaults
-
- assertNull(resourceOneToMany.getJoinFetch());
- assertNull(contextOneToMany.getJoinFetch().getValue());
-
- // set xml join fetch to INNER, check context
-
- resourceOneToMany.setJoinFetch(XmlJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceOneToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextOneToMany.getJoinFetch().getValue());
-
- // set xml join fetch to OUTER, check context
-
- resourceOneToMany.setJoinFetch(XmlJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceOneToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextOneToMany.getJoinFetch().getValue());
-
- // set xml join fetch to null, check context
-
- resourceOneToMany.setJoinFetch(null);
-
- assertNull(resourceOneToMany.getJoinFetch());
- assertNull(contextOneToMany.getJoinFetch().getValue());
- }
-
- public void testModifyJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToMany");
- EclipseLinkOneToManyMapping contextOneToMany =
- (EclipseLinkOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlOneToMany resourceOneToMany =
- (XmlOneToMany) resourceEntity.getAttributes().getOneToManys().get(0);
-
- // check defaults
-
- assertNull(resourceOneToMany.getJoinFetch());
- assertNull(contextOneToMany.getJoinFetch().getValue());
-
- // set context join fetch to INNER, check resource
-
- contextOneToMany.getJoinFetch().setValue(EclipseLinkJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceOneToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextOneToMany.getJoinFetch().getValue());
-
- // set context join fetch to OUTER, check resource
-
- contextOneToMany.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceOneToMany.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextOneToMany.getJoinFetch().getValue());
-
- // set context join fetch to null, check resource
-
- contextOneToMany.getJoinFetch().setValue(null);
-
- assertNull(resourceOneToMany.getJoinFetch());
- assertNull(contextOneToMany.getJoinFetch().getValue());
- }
-
- public void testJoinFetchDefault() throws Exception {
- createTestEmployee();
- createTestDepartment();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Department");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Employee");
-
- OrmPersistentType departmentPersistentType = getEntityMappings().getPersistentTypes().iterator().next();
- EclipseLinkOneToManyMapping oneToMany = (EclipseLinkOneToManyMapping) departmentPersistentType.getAttributeNamed("employees").getMapping();
-
- assertNull(oneToMany.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- oneToMany = (EclipseLinkOneToManyMapping) departmentPersistentType.getAttributeNamed("employees").getMapping();
- assertNull(oneToMany.getJoinFetch().getValue());
-
- EclipseLinkRelationshipMapping javaRelationshipMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getJavaPersistentType().getAttributeNamed("employees").getMapping();
- javaRelationshipMapping.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
- assertNull(oneToMany.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- oneToMany = (EclipseLinkOneToManyMapping) departmentPersistentType.getAttributeNamed("employees").getMapping();
- assertEquals(EclipseLinkJoinFetchType.OUTER, oneToMany.getJoinFetch().getValue());
- }
-
- public void testDefaultJoinTable() throws Exception {
- createTestEmployee();
- createTestDepartment();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Department");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Employee");
-
- OrmPersistentType departmentPersistentType = getEntityMappings().getPersistentTypes().iterator().next();
- OrmReadOnlyPersistentAttribute attribute = departmentPersistentType.getAttributeNamed("employees");
- OneToManyMapping oneToMany = (OneToManyMapping) attribute.getMapping();
-
- assertEquals(true, attribute.isVirtual());
- JoinTable ormJoinTable = oneToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("DEP_EMP", ormJoinTable.getName());
- assertEquals("DEPT_ID", ormJoinTable.specifiedJoinColumns().next().getName());
- assertEquals("id", ormJoinTable.specifiedJoinColumns().next().getReferencedColumnName());
- assertEquals("EMP_ID", ormJoinTable.specifiedInverseJoinColumns().next().getName());
- assertEquals("empId", ormJoinTable.specifiedInverseJoinColumns().next().getReferencedColumnName());
-
- //set metadata-complete and verify JoinTable info is not taken from the java
- departmentPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- departmentPersistentType.addSpecifiedAttribute(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, "id");
- attribute = departmentPersistentType.getAttributeNamed("employees");
- oneToMany = (OneToManyMapping) attribute.getMapping();
-
- assertEquals(true, attribute.isVirtual());
- ormJoinTable = oneToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("Department_Employee", ormJoinTable.getName());
- assertEquals("Department_id", ormJoinTable.getDefaultJoinColumn().getName());
- assertEquals("id", ormJoinTable.getDefaultJoinColumn().getReferencedColumnName());
- assertEquals("employees_empId", ormJoinTable.getDefaultInverseJoinColumn().getName());
- assertEquals("empId", ormJoinTable.getDefaultInverseJoinColumn().getReferencedColumnName());
-
- //set metadata-complete to false, add mapping to orm.xml verify JoinTable info is not taken from the java
- departmentPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.FALSE);
- attribute = departmentPersistentType.getAttributeNamed("employees");
- oneToMany = (OneToManyMapping) attribute.getMapping();
- assertEquals(true, attribute.isVirtual());
- ormJoinTable = oneToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("DEP_EMP", ormJoinTable.getName());
- assertEquals("DEPT_ID", ormJoinTable.specifiedJoinColumns().next().getName());
- assertEquals("id", ormJoinTable.specifiedJoinColumns().next().getReferencedColumnName());
- assertEquals("EMP_ID", ormJoinTable.specifiedInverseJoinColumns().next().getName());
- assertEquals("empId", ormJoinTable.specifiedInverseJoinColumns().next().getReferencedColumnName());
-
-
- departmentPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "employees");
- attribute = departmentPersistentType.getAttributeNamed("employees");
- oneToMany = (OneToManyMapping) attribute.getMapping();
- assertEquals(false, attribute.isVirtual());
- ormJoinTable = oneToMany.getRelationship().getJoinTableStrategy().getJoinTable();
- assertEquals("Department_Employee", ormJoinTable.getName());
- assertEquals(0, ormJoinTable.specifiedJoinColumnsSize());
- assertEquals("Department_id", ormJoinTable.getDefaultJoinColumn().getName());
- assertEquals("id", ormJoinTable.getDefaultJoinColumn().getReferencedColumnName());
- assertEquals(0, ormJoinTable.specifiedInverseJoinColumnsSize());
- assertEquals("employees_empId", ormJoinTable.getDefaultInverseJoinColumn().getName());
- assertEquals("empId", ormJoinTable.getDefaultInverseJoinColumn().getReferencedColumnName());
- }
-
- public void testUpdateVirtualMapKey() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- OneToManyMapping ormOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNull(ormOneToManyMapping.getMapKey());
- assertFalse(ormOneToManyMapping.isPkMapKey());
- assertFalse(ormOneToManyMapping.isCustomMapKey());
- assertTrue(ormOneToManyMapping.isNoMapKey());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaOneToManyMapping.setPkMapKey(true);
- assertEquals("id", ormOneToManyMapping.getMapKey());
- assertTrue(ormOneToManyMapping.isPkMapKey());
- assertFalse(ormOneToManyMapping.isCustomMapKey());
- assertFalse(ormOneToManyMapping.isNoMapKey());
-
-
- //set custom specified mapKey in the java, verify virtual orm mapping updates
- javaOneToManyMapping.setCustomMapKey(true);
- javaOneToManyMapping.setSpecifiedMapKey("city");
- assertEquals("city", ormOneToManyMapping.getSpecifiedMapKey());
- assertEquals("city", ormOneToManyMapping.getMapKey());
- assertFalse(ormOneToManyMapping.isPkMapKey());
- assertTrue(ormOneToManyMapping.isCustomMapKey());
- assertFalse(ormOneToManyMapping.isNoMapKey());
-
- //set metadata complete and verify that the orm model ignores the java annotations
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- assertEquals(null, ormOneToManyMapping.getSpecifiedMapKey());
- assertEquals(null, ormOneToManyMapping.getMapKey());
- assertFalse(ormOneToManyMapping.isPkMapKey());
- assertFalse(ormOneToManyMapping.isCustomMapKey());
- assertTrue(ormOneToManyMapping.isNoMapKey());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames =
- oneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- OneToManyMapping ormOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- ormPersistentType.getAttributeNamed("addresses").convertToSpecified();
- ormOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- ormOneToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- ormOneToManyMapping.setSpecifiedTargetEntity("String");
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntityWithOneToManyMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("id");
- OrmEclipseLinkOneToManyMapping contextMapping = (OrmEclipseLinkOneToManyMapping) contextAttribute.getMapping();
- EclipseLinkOneToManyRelationship2_0 rel = contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlOneToMany resourceMapping = (XmlOneToMany) resourceEntity.getAttributes().getOneToManys().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinColumn();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToMappedBy();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinTable();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntityWithOneToManyMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("id");
- OrmEclipseLinkOneToManyMapping contextMapping = (OrmEclipseLinkOneToManyMapping) contextAttribute.getMapping();
- EclipseLinkOneToManyRelationship2_0 rel = contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlOneToMany resourceMapping = (XmlOneToMany) resourceEntity.getAttributes().getOneToManys().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceMapping.setMappedBy("foo");
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceMapping.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTable());
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceMapping.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceMapping.setMappedBy(null);
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceMapping.setJoinTable(null);
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceMapping.getJoinColumns().clear();
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityOneToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- EclipseLinkOneToManyMapping virtualOneToManyMapping = (EclipseLinkOneToManyMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualOneToManyMapping.getName());
- assertEquals(FetchType.EAGER, virtualOneToManyMapping.getSpecifiedFetch());
- assertEquals("Address", virtualOneToManyMapping.getSpecifiedTargetEntity());
- assertNull(virtualOneToManyMapping.getRelationship().
- getMappedByStrategy().getMappedByAttribute());
-
- Cascade cascade = virtualOneToManyMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
-
- assertTrue(virtualOneToManyMapping.getOrderable().isCustomOrdering());
- assertEquals("city", virtualOneToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertEquals(EclipseLinkJoinFetchType.INNER, virtualOneToManyMapping.getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityOneToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
-
- EclipseLinkOneToManyMapping virtualOneToManyMapping = (EclipseLinkOneToManyMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualOneToManyMapping.getName());
- assertEquals(FetchType.LAZY, virtualOneToManyMapping.getFetch());
- assertEquals("test.Address", virtualOneToManyMapping.getTargetEntity());
- assertNull(virtualOneToManyMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
-
- Cascade cascade = virtualOneToManyMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
-
- assertTrue(virtualOneToManyMapping.getOrderable().isNoOrdering());
- assertEquals(null, virtualOneToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertEquals(null, virtualOneToManyMapping.getJoinFetch().getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToOneMappingTests.java
deleted file mode 100644
index fe55468065..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmOneToOneMappingTests.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.Cascade;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToOneMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkOneToOneMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlOneToOne;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmOneToOneMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmOneToOneMappingTests(String name) {
- super(name);
- }
-
- private void createTestDepartment() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("import ").append(JPA.ONE_TO_ONE).append(";");
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Department").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(" @OneToOne").append(CR);
- sb.append(" private Employee employee;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Department.java", sourceWriter);
- }
-
- private void createTestEmployee() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ").append(JPA.ENTITY).append(";");
- sb.append(CR);
- sb.append("import ").append(JPA.ID).append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("Employee").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private int empId;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Employee.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityOneToOneMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.JOIN_COLUMN, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE, EclipseLink.PRIVATE_OWNED);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToOne(fetch=FetchType.LAZY, optional=false, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH})");
- sb.append(CR);
- sb.append(" @JoinColumn(name=\"MY_COLUMN\", referencedColumnName=\"MY_REFERENCED_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\")");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" @PrivateOwned)");
- sb.append(CR);
- sb.append(" private Address address;").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(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(" 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);
- }
-
- public void testUpdatePrivateOwned() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
- EclipseLinkOneToOneMapping contextOneToOne =
- (EclipseLinkOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlOneToOne resourceOneToOne =
- (XmlOneToOne) resourceEntity.getAttributes().getOneToOnes().get(0);
-
- // check defaults
-
- assertFalse(resourceOneToOne.isPrivateOwned());
- assertFalse(contextOneToOne.getPrivateOwned().isPrivateOwned());
-
- // set xml private owned to true, check context
-
- resourceOneToOne.setPrivateOwned(true);
-
- assertTrue(resourceOneToOne.isPrivateOwned());
- assertTrue(contextOneToOne.getPrivateOwned().isPrivateOwned());
-
- // set xml private owned back to false, check context
-
- resourceOneToOne.setPrivateOwned(false);
-
- assertFalse(resourceOneToOne.isPrivateOwned());
- assertFalse(contextOneToOne.getPrivateOwned().isPrivateOwned());
- }
-
- public void testModifyPrivateOwned() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
- EclipseLinkOneToOneMapping contextOneToOne =
- (EclipseLinkOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlOneToOne resourceOneToOne =
- (XmlOneToOne) resourceEntity.getAttributes().getOneToOnes().get(0);
-
- // check defaults
-
- assertFalse(resourceOneToOne.isPrivateOwned());
- assertFalse(contextOneToOne.getPrivateOwned().isPrivateOwned());
-
- // set context private owned to true, check resource
-
- contextOneToOne.getPrivateOwned().setPrivateOwned(true);
-
- assertTrue(resourceOneToOne.isPrivateOwned());
- assertTrue(contextOneToOne.getPrivateOwned().isPrivateOwned());
-
- // set context private owned back to false, check resource
-
- contextOneToOne.getPrivateOwned().setPrivateOwned(false);
- }
-
- public void testUpdateJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
- EclipseLinkOneToOneMapping contextOneToOne =
- (EclipseLinkOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity) getXmlEntityMappings().getEntities().get(0);
- XmlOneToOne resourceOneToOne =
- (XmlOneToOne) resourceEntity.getAttributes().getOneToOnes().get(0);
-
- // check defaults
-
- assertNull(resourceOneToOne.getJoinFetch());
- assertNull(contextOneToOne.getJoinFetch().getValue());
-
- // set xml join fetch to INNER, check context
-
- resourceOneToOne.setJoinFetch(XmlJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceOneToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextOneToOne.getJoinFetch().getValue());
-
- // set xml join fetch to OUTER, check context
-
- resourceOneToOne.setJoinFetch(XmlJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceOneToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextOneToOne.getJoinFetch().getValue());
-
- // set xml join fetch to null, check context
-
- resourceOneToOne.setJoinFetch(null);
-
- assertNull(resourceOneToOne.getJoinFetch());
- assertNull(contextOneToOne.getJoinFetch().getValue());
- }
-
- public void testModifyJoinFetch() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOne");
- EclipseLinkOneToOneMapping contextOneToOne =
- (EclipseLinkOneToOneMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlOneToOne resourceOneToOne =
- (XmlOneToOne) resourceEntity.getAttributes().getOneToOnes().get(0);
-
- // check defaults
-
- assertNull(resourceOneToOne.getJoinFetch());
- assertNull(contextOneToOne.getJoinFetch().getValue());
-
- // set context join fetch to INNER, check resource
-
- contextOneToOne.getJoinFetch().setValue(EclipseLinkJoinFetchType.INNER);
-
- assertEquals(XmlJoinFetchType.INNER, resourceOneToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextOneToOne.getJoinFetch().getValue());
-
- // set context join fetch to OUTER, check resource
-
- contextOneToOne.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(XmlJoinFetchType.OUTER, resourceOneToOne.getJoinFetch());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextOneToOne.getJoinFetch().getValue());
-
- // set context join fetch to null, check resource
-
- contextOneToOne.getJoinFetch().setValue(null);
-
- assertNull(resourceOneToOne.getJoinFetch());
- assertNull(contextOneToOne.getJoinFetch().getValue());
- }
-
- public void testJoinFetchDefaultFromJava() throws Exception {
- createTestEmployee();
- createTestDepartment();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Department");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Employee");
-
- OrmPersistentType departmentPersistentType = getEntityMappings().getPersistentTypes().iterator().next();
- EclipseLinkOneToOneMapping oneToOne = (EclipseLinkOneToOneMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
-
- assertNull(oneToOne.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- oneToOne = (EclipseLinkOneToOneMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
- assertNull(oneToOne.getJoinFetch().getValue());
-
- EclipseLinkRelationshipMapping javaRelationshipMapping = (EclipseLinkRelationshipMapping) departmentPersistentType.getJavaPersistentType().getAttributeNamed("employee").getMapping();
- javaRelationshipMapping.getJoinFetch().setValue(EclipseLinkJoinFetchType.OUTER);
- assertNull(oneToOne.getJoinFetch().getValue());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- oneToOne = (EclipseLinkOneToOneMapping) departmentPersistentType.getAttributeNamed("employee").getMapping();
- assertEquals(EclipseLinkJoinFetchType.OUTER, oneToOne.getJoinFetch().getValue());
- }
-
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().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());
-
- JoinColumn virtualJoinColumn =
- virtualOneToOneMapping.getRelationship().getJoinColumnStrategy().specifiedJoinColumns().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.getSpecifiedTable());
-
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute 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.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmEclipseLinkOneToOneMapping ormOneToOneMapping = (OrmEclipseLinkOneToOneMapping) 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().joinColumnsSize() > 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());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmPersistentAttributeTests.java
deleted file mode 100644
index 6c0078b579..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmPersistentAttributeTests.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-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.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaNullAttributeMapping;
-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.persistence.PersistenceFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkIdMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkOneToOneMapping;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmPersistentAttributeTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmPersistentAttributeTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString());
- getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- getPersistenceXmlResource().save(null);
- }
-
- private ICompilationUnit createTestTypeNullAttributeMapping() throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityIdMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append("@Column(name=\"FOO\")");
- }
- });
- }
-
- private ICompilationUnit createTestEntityOneToOneMapping() throws Exception {
- return this.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");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne");
- sb.append(" private Address address;");
- }
- });
- }
-
- public void testMakeSpecified() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertTrue(ormPersistentAttribute.isVirtual());
- ormPersistentAttribute.convertToSpecified();
-
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ormPersistentAttribute.convertToSpecified();
-
- assertEquals(0, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.specifiedAttributes();
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("name", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- }
-
- public void testMakeSpecifiedMappingKey() throws Exception {
- createTestTypeNullAttributeMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- //take a virtual mapping with a mapping type and make it specified
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertTrue(ormPersistentAttribute.isVirtual());
- assertTrue(ormPersistentAttribute.getMapping() instanceof GenericJavaNullAttributeMapping);
- ormPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("address", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- assertEquals(specifiedOrmPersistentAttribute.getMappingKey(), MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof OrmEclipseLinkOneToOneMapping);
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ormPersistentAttribute.convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
-
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.specifiedAttributes();
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof OrmEclipseLinkIdMapping);
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("address", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- }
-
- public void testMakeVirtual() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- ormPersistentType.virtualAttributes().next().convertToSpecified();
- ormPersistentType.virtualAttributes().next().convertToSpecified();
-
- assertEquals(0, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- specifiedOrmPersistentAttribute.convertToVirtual();
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
-
- specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- specifiedOrmPersistentAttribute.convertToVirtual();
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- assertEquals(0, ormPersistentType.specifiedAttributesSize());
-
- Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.virtualAttributes();
- OrmReadOnlyPersistentAttribute virtualAttribute = virtualAttributes.next();
- assertEquals("id", virtualAttribute.getName());
- virtualAttribute = virtualAttributes.next();
- assertEquals("name", virtualAttribute.getName());
- }
-
- public void testMakeVirtualNoUnderlyingJavaAttribute() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- ormPersistentType.virtualAttributes().next().convertToSpecified();
- ormPersistentType.virtualAttributes().next().convertToSpecified();
-
-
- ormPersistentType.specifiedAttributes().next().getMapping().setName("noJavaAttribute");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
-
-
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- specifiedOrmPersistentAttribute.convertToVirtual();
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
-
- assertEquals("id", ormPersistentType.virtualAttributes().next().getName());
- assertEquals("name", ormPersistentType.specifiedAttributes().next().getName());
- }
-
- public void testVirtualMappingTypeWhenMetadataComplete() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getName());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertEquals("id", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals("id", ((BasicMapping) ormPersistentAttribute.getMapping()).getColumn().getName());
- }
-
- public void testVirtualMappingTypeWhenMetadataComplete2() throws Exception {
- createTestEntityOneToOneMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("address");
- assertEquals("address", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- }
-
- public void testGetJavaPersistentAttribute() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- JavaPersistentAttribute javaPersistentAttribute = javaPersistentType.getAttributeNamed("id");
-
- //virtual orm attribute, access type matches java : FIELD, name matches java
- assertTrue(ormPersistentAttribute.isVirtual());
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- JavaResourcePersistentAttribute javaResourcePersistentAttribute = ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute();
- assertTrue(javaResourcePersistentAttribute.isField());
- assertEquals("id", javaResourcePersistentAttribute.getName());
- assertEquals(javaPersistentType.getResourcePersistentType().persistableFields().next(), javaResourcePersistentAttribute);
-
-
- //specified orm attribute, access type matches java : FIELD, name matches java
- //javaPersistentAttribute should be == to java context model object
- ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
-
-
- //virtual orm attribute, java access type FIELD, orm access type PROPERTY, name matches java
- //verify the property java resource persistent attribute is used in orm.
- ((OrmPersistentAttribute) ormPersistentAttribute).convertToVirtual();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- ormPersistentType.setSpecifiedAccess(AccessType.PROPERTY);
- assertNotSame(ormPersistentAttribute, ormPersistentType.getAttributeNamed("id"));
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- javaResourcePersistentAttribute = ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute();
- assertTrue(javaResourcePersistentAttribute.isProperty());
- assertEquals("id", javaResourcePersistentAttribute.getName());
- assertEquals(javaPersistentType.getResourcePersistentType().persistableProperties().next(), javaResourcePersistentAttribute);
-
-
- ormPersistentType.setSpecifiedAccess(null);//default access will be field
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- OrmPersistentAttribute ormPersistentAttribute2 = ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute2.getMapping().setName("id2");
- assertEquals(null, ormPersistentAttribute2.getJavaPersistentAttribute());
-
- ormPersistentAttribute2.getMapping().setName(null);
- assertEquals(null, ormPersistentAttribute2.getJavaPersistentAttribute());
-
- ormPersistentAttribute2.getMapping().setName("id");
- assertEquals(javaPersistentAttribute, ormPersistentAttribute2.getJavaPersistentAttribute());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(javaPersistentAttribute, ormPersistentAttribute2.getJavaPersistentAttribute());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmStructConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmStructConverterTests.java
deleted file mode 100644
index f6a3cfca97..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmStructConverterTests.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmStructConverterTests
- extends EclipseLinkOrmContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.CONVERT, EclipseLink.STRUCT_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append(" @Convert(name=\"foo\")").append(CR);
- sb.append(" @StructConverter");
- }
- });
- }
-
-
- public EclipseLinkOrmStructConverterTests(String name) {
- super(name);
- }
-
-
- public void testUpdateConverter() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkStructConverter.class);
- EclipseLinkStructConverter ormConverter = (EclipseLinkStructConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlStructConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getStructConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getConverter());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setConverter("myConvert");
- assertEquals("myConvert", ormConverter.getConverterClass());
- assertEquals("myConvert", converterResource.getConverter());
-
- //set converter class name to null in the resource model
- converterResource.setConverter(null);
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getConverter());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkStructConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkStructConverter javaConverter = ((EclipseLinkStructConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setConverterClass("bar");
- assertEquals("bar", ormConverter.getConverterClass());
- assertEquals("bar", javaConverter.getConverterClass());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getConverterClass());
- }
-
- public void testModifyConverter() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkStructConverter.class);
- EclipseLinkStructConverter ormConverter = (EclipseLinkStructConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlStructConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getStructConverter();
-
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getConverter());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setConverterClass("foo");
- assertEquals("foo", ormConverter.getConverterClass());
- assertEquals("foo", converterResource.getConverter());
-
- ormConverter.setConverterClass(null);
- assertEquals(null, ormConverter.getConverterClass());
- assertEquals(null, converterResource.getConverter());
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkStructConverter.class);
- OrmEclipseLinkStructConverter ormConverter = (OrmEclipseLinkStructConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlStructConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getStructConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setName("myConvert");
- assertEquals("myConvert", ormConverter.getName());
- assertEquals("myConvert", converterResource.getName());
-
- //set converter class name to null in the resource model
- converterResource.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
-
- //remove the specified persistent attribute, test virtual mapping
-
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- EclipseLinkStructConverter virtualConverter = (EclipseLinkStructConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkStructConverter javaConverter = ((EclipseLinkStructConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setName("bar");
- assertEquals("bar", virtualConverter.getName());
- assertEquals("bar", javaConverter.getName());
-
-
- //set metadata-complete, test virtual mapping
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.virtualAttributes().next();
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkStructConverter.class);
- OrmEclipseLinkStructConverter ormConverter = (OrmEclipseLinkStructConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlStructConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getStructConverter();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setName("foo");
- assertEquals("foo", ormConverter.getName());
- assertEquals("foo", converterResource.getName());
-
- ormConverter.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTransientMappingTests.java
deleted file mode 100644
index 1af98f5581..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTransientMappingTests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmTransientMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmTransientMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithTransientMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TRANSIENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transient").append(CR);
- }
- });
- }
-
- public void testCreateTransientMapping() throws Exception {
- createTestEntityWithTransientMapping();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertTrue(persistentAttribute.isVirtual());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
-
- OrmPersistentAttribute persistentAttribute2 = persistentAttribute.convertToSpecified(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertFalse(persistentAttribute2.isVirtual());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, persistentAttribute2.getMappingKey());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, persistentAttribute2.getMapping().getKey());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTypeConverterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTypeConverterTests.java
deleted file mode 100644
index e08e36ab7f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTypeConverterTests.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmTypeConverterTests
- extends EclipseLinkOrmContextModelTestCase
-{
-
- private ICompilationUnit createTestEntityWithBasicMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, EclipseLink.CONVERT, EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Basic").append(CR);
- sb.append(" @Convert(name=\"foo\")").append(CR);
- sb.append(" @TypeConverter");
- }
- });
- }
-
-
- public EclipseLinkOrmTypeConverterTests(String name) {
- super(name);
- }
-
-
- public void testUpdateDataType() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkTypeConverter.class);
- EclipseLinkTypeConverter ormConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setDataType("myConvert");
- assertEquals("myConvert", ormConverter.getDataType());
- assertEquals("myConvert", converterResource.getDataType());
-
- //set converter class name to null in the resource model
- converterResource.setDataType(null);
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkTypeConverter javaConverter = ((EclipseLinkTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setDataType("bar");
- assertEquals("bar", ormConverter.getDataType());
- assertEquals("bar", javaConverter.getDataType());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getDataType());
- }
-
- public void testModifyDataType() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkTypeConverter.class);
- EclipseLinkTypeConverter ormConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getTypeConverter();
-
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setDataType("foo");
- assertEquals("foo", ormConverter.getDataType());
- assertEquals("foo", converterResource.getDataType());
-
- ormConverter.setDataType(null);
- assertEquals(null, ormConverter.getDataType());
- assertEquals(null, converterResource.getDataType());
- }
-
- public void testUpdateObjectType() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = (OrmBasicMapping) ormPersistentAttribute.getMapping();
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkTypeConverter.class);
- EclipseLinkTypeConverter ormConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setObjectType("myConvert");
- assertEquals("myConvert", ormConverter.getObjectType());
- assertEquals("myConvert", converterResource.getObjectType());
-
- //set converter class name to null in the resource model
- converterResource.setObjectType(null);
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- ormConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkTypeConverter javaConverter = ((EclipseLinkTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setObjectType("bar");
- assertEquals("bar", ormConverter.getObjectType());
- assertEquals("bar", javaConverter.getObjectType());
-
- //set metadata-complete, test virtual mapping
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getObjectType());
- }
-
- public void testModifyObjectType() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkTypeConverter.class);
- EclipseLinkTypeConverter ormConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getTypeConverter();
-
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setObjectType("foo");
- assertEquals("foo", ormConverter.getObjectType());
- assertEquals("foo", converterResource.getObjectType());
-
- ormConverter.setObjectType(null);
- assertEquals(null, ormConverter.getObjectType());
- assertEquals(null, converterResource.getObjectType());
- }
-
- public void testUpdateName() throws Exception {
- createTestEntityWithBasicMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "id");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkTypeConverter.class);
- OrmEclipseLinkTypeConverter ormConverter = (OrmEclipseLinkTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getTypeConverter();
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class name in the resource model, verify context model updated
- converterResource.setName("myConvert");
- assertEquals("myConvert", ormConverter.getName());
- assertEquals("myConvert", converterResource.getName());
-
- //set converter class name to null in the resource model
- converterResource.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
-
- //remove the specified persistent attribute, test virtual mapping
- ormPersistentAttribute.convertToVirtual();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- BasicMapping virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- EclipseLinkTypeConverter virtualConverter = (EclipseLinkTypeConverter) ((EclipseLinkConvert) virtualBasicMapping.getConverter()).getConverter();
-
- EclipseLinkTypeConverter javaConverter = ((EclipseLinkTypeConverter) ((EclipseLinkConvert) javaBasicMapping.getConverter()).getConverter());
- javaConverter.setName("bar");
- assertEquals("bar", virtualConverter.getName());
- assertEquals("bar", javaConverter.getName());
-
-
- //set metadata-complete, test virtual mapping
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.virtualAttributes().next();
- virtualBasicMapping = (BasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(virtualBasicMapping.getConverter().getType());
- assertEquals("bar", javaConverter.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmBasicMapping ormBasicMapping = ((OrmBasicMapping) ormPersistentAttribute.getMapping());
- ormBasicMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) ormBasicMapping.getConverter()).setConverter(EclipseLinkTypeConverter.class);
- OrmEclipseLinkTypeConverter ormConverter = (OrmEclipseLinkTypeConverter) ((EclipseLinkConvert) ormBasicMapping.getConverter()).getConverter();
- XmlTypeConverter converterResource = ((XmlBasic) getXmlEntityMappings().getEntities().get(0).getAttributes().getBasics().get(0)).getTypeConverter();
-
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
-
- //set converter class in the context model, verify resource model updated
- ormConverter.setName("foo");
- assertEquals("foo", ormConverter.getName());
- assertEquals("foo", converterResource.getName());
-
- ormConverter.setName(null);
- assertEquals(null, ormConverter.getName());
- assertEquals(null, converterResource.getName());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmVersionMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmVersionMappingTests.java
deleted file mode 100644
index e9483bac5f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmVersionMappingTests.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.VersionMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkBasicMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkVersionMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkVersionMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlVersion;
-
-@SuppressWarnings("nls")
-public class EclipseLinkOrmVersionMappingTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkOrmVersionMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithVersionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithMutableVersionDate() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.VERSION, EclipseLink.MUTABLE, "java.util.Date");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Version").append(CR);
- sb.append(" @Mutable").append(CR);
- sb.append(" private Date myDate;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- public void testUpdateMutable() throws Exception {
- createTestEntityWithVersionMapping();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "id");
- OrmEclipseLinkVersionMapping contextVersion =
- (OrmEclipseLinkVersionMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlVersion resourceVersion =
- (XmlVersion) resourceEntity.getAttributes().getVersions().get(0);
- EclipseLinkVersionMapping javaVersionMapping = (EclipseLinkVersionMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- // check defaults
-
- assertNull(resourceVersion.getMutable());
- assertTrue(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
-
- // set xml mutable to false, check context
-
- resourceVersion.setMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceVersion.getMutable());
- assertTrue(contextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- // set xml mutable to true, check context
-
- resourceVersion.setMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceVersion.getMutable());
- assertTrue(contextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
-
- // clear xml mutable, check context
-
- resourceVersion.setMutable(null);
-
- assertNull(resourceVersion.getMutable());
- assertTrue(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
-
- // TODO - test defaults for java serializable and date/time types,
- // with and without persistence property
-
- // set mutable on java basic mapping
-
- javaVersionMapping.getMutable().setSpecifiedMutable(Boolean.FALSE);
- assertNull(resourceVersion.getMutable());
- assertTrue(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
- assertFalse(javaVersionMapping.getMutable().isMutable());
-
- // remove attribute from xml, test default mutable from java
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- EclipseLinkVersionMapping virtualContextVersion = (EclipseLinkVersionMapping) ormPersistentAttribute2.getMapping();
-
- assertNull(resourceVersion.getMutable());
- assertTrue(virtualContextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, virtualContextVersion.getMutable().getSpecifiedMutable());
- assertFalse(virtualContextVersion.getMutable().isMutable());
- assertFalse(javaVersionMapping.getMutable().isMutable());
-
- // set metadata complete
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- EclipseLinkBasicMapping contextBasic = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(resourceVersion.getMutable());
- assertTrue(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertTrue(contextBasic.getMutable().isMutable());
- assertFalse(javaVersionMapping.getMutable().isMutable());
- }
-
- public void testUpdateMutableDate() throws Exception {
- createTestEntityWithMutableVersionDate();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "myDate");
- OrmEclipseLinkVersionMapping contextVersion =
- (OrmEclipseLinkVersionMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlVersion resourceVersion =
- (XmlVersion) resourceEntity.getAttributes().getVersions().get(0);
- EclipseLinkVersionMapping javaVersionMapping = (EclipseLinkVersionMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("myDate").getMapping();
-
- // check defaults
-
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- // set xml mutable to false, check context
-
- resourceVersion.setMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- // set xml mutable to true, check context
-
- resourceVersion.setMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
-
- // clear xml mutable, check context
-
- resourceVersion.setMutable(null);
-
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.TRUE);
- assertNull(resourceVersion.getMutable());
- assertTrue(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(Boolean.FALSE);
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- getPersistenceUnit().getOptions().setTemporalMutable(null);
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- // set mutable on java version mapping
-
- javaVersionMapping.getMutable().setSpecifiedMutable(Boolean.TRUE);
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
- assertTrue(javaVersionMapping.getMutable().isMutable());
-
- // remove attribute from xml, test default mutable from java
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("myDate");
- EclipseLinkVersionMapping virtualContextVersion = (EclipseLinkVersionMapping) ormPersistentAttribute2.getMapping();
-
- assertNull(resourceVersion.getMutable());
- assertFalse(virtualContextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, virtualContextVersion.getMutable().getSpecifiedMutable());
- assertTrue(virtualContextVersion.getMutable().isMutable());
- assertTrue(javaVersionMapping.getMutable().isMutable());
-
- // set metadata complete
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("myDate");
- EclipseLinkBasicMapping contextBasic = (EclipseLinkBasicMapping) ormPersistentAttribute2.getMapping();
- assertNull(resourceVersion.getMutable());
- assertFalse(contextBasic.getMutable().isDefaultMutable());
- assertNull(contextBasic.getMutable().getSpecifiedMutable());
- assertFalse(contextBasic.getMutable().isMutable());
- assertTrue(javaVersionMapping.getMutable().isMutable());
- }
-
- public void testModifyMutable() throws Exception {
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute =
- ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "basic");
- OrmEclipseLinkVersionMapping contextVersion =
- (OrmEclipseLinkVersionMapping) ormPersistentAttribute.getMapping();
- XmlEntity resourceEntity =
- (XmlEntity)getXmlEntityMappings().getEntities().get(0);
- XmlVersion resourceVersion =
- (XmlVersion) resourceEntity.getAttributes().getVersions().get(0);
-
- // check defaults
-
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- // set context mutable to true, check resource
-
- contextVersion.getMutable().setSpecifiedMutable(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.TRUE, contextVersion.getMutable().getSpecifiedMutable());
- assertTrue(contextVersion.getMutable().isMutable());
-
- // set context mutable to false, check resource
-
- contextVersion.getMutable().setSpecifiedMutable(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertEquals(Boolean.FALSE, contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
-
- // set context read only to null, check resource
-
- contextVersion.getMutable().setSpecifiedMutable(null);
-
- assertNull(resourceVersion.getMutable());
- assertFalse(contextVersion.getMutable().isDefaultMutable());
- assertNull(contextVersion.getMutable().getSpecifiedMutable());
- assertFalse(contextVersion.getMutable().isMutable());
- }
-
- public void testUpdateConvert() throws Exception {
- createTestEntityWithVersionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "id");
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- XmlVersion basicResource = (XmlVersion) getXmlEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0);
- JavaVersionMapping javaVersionMapping = (JavaVersionMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("id").getMapping();
-
- assertNull(ormVersionMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
- //set lob in the resource model, verify context model updated
- basicResource.setConvert("myConvert");
- assertEquals(EclipseLinkConvert.class, ormVersionMapping.getConverter().getType());
- assertEquals("myConvert", basicResource.getConvert());
-
- //set lob to null in the resource model
- basicResource.setConvert(null);
- assertNull(ormVersionMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
-
- javaVersionMapping.setConverter(EclipseLinkConvert.class);
- ((EclipseLinkConvert) javaVersionMapping.getConverter()).setSpecifiedConverterName("foo");
-
- assertNull(ormVersionMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
- assertEquals("foo", ((EclipseLinkConvert) javaVersionMapping.getConverter()).getSpecifiedConverterName());
-
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("id");
- VersionMapping virtualVersionMapping = (VersionMapping) ormPersistentAttribute2.getMapping();
-
- assertEquals(EclipseLinkConvert.class, virtualVersionMapping.getConverter().getType());
- assertEquals("foo", ((EclipseLinkConvert) virtualVersionMapping.getConverter()).getSpecifiedConverterName());
- assertEquals(null, basicResource.getConvert());
- assertEquals("foo", ((EclipseLinkConvert) javaVersionMapping.getConverter()).getSpecifiedConverterName());
-
- ((EclipseLinkConvert) javaVersionMapping.getConverter()).setSpecifiedConverterName("bar");
- assertEquals(EclipseLinkConvert.class, virtualVersionMapping.getConverter().getType());
- assertEquals("bar", ((EclipseLinkConvert) virtualVersionMapping.getConverter()).getSpecifiedConverterName());
- assertEquals(null, basicResource.getConvert());
- assertEquals("bar", ((EclipseLinkConvert) javaVersionMapping.getConverter()).getSpecifiedConverterName());
-
- javaVersionMapping.setConverter(null);
- assertNull(virtualVersionMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
- assertNull(javaVersionMapping.getConverter().getType());
- }
-
- public void testModifyConvert() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY, "basicMapping");
- OrmVersionMapping ormVersionMapping = (OrmVersionMapping) ormPersistentAttribute.getMapping();
- XmlVersion basicResource = (XmlVersion) getXmlEntityMappings().getEntities().get(0).getAttributes().getVersions().get(0);
-
- assertNull(ormVersionMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
-
- //set lob in the context model, verify resource model updated
- ormVersionMapping.setConverter(EclipseLinkConvert.class);
- assertEquals("", basicResource.getConvert());
- assertEquals(EclipseLinkConvert.class, ormVersionMapping.getConverter().getType());
-
- ((EclipseLinkConvert) ormVersionMapping.getConverter()).setSpecifiedConverterName("bar");
- assertEquals("bar", basicResource.getConvert());
- assertEquals(EclipseLinkConvert.class, ormVersionMapping.getConverter().getType());
- assertEquals("bar", ((EclipseLinkConvert) ormVersionMapping.getConverter()).getSpecifiedConverterName());
-
- ((EclipseLinkConvert) ormVersionMapping.getConverter()).setSpecifiedConverterName(null);
-
- assertNull(ormVersionMapping.getConverter().getType());
- assertEquals(null, basicResource.getConvert());
-
- //set lob to false in the context model
- ormVersionMapping.setConverter(null);
- assertNull(ormVersionMapping.getConverter().getType());
- assertNull(basicResource.getConvert());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitDefaultsTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitDefaultsTests.java
deleted file mode 100644
index 4375217453..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitDefaultsTests.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitDefaults;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-
-@SuppressWarnings("nls")
-public class EclipseLinkPersistenceUnitDefaultsTests extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkPersistenceUnitDefaultsTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.toString());
- getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- getPersistenceXmlResource().save(null);
- }
-
- protected OrmPersistenceUnitDefaults persistenceUnitDefaults() {
- return getEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults();
- }
-
- public void testIsAllFeaturesUnset() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- XmlPersistenceUnitMetadata persistenceUnitMetadata = EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata();
- getXmlEntityMappings().setPersistenceUnitMetadata(persistenceUnitMetadata);
- assertTrue(persistenceUnitMetadata.isUnset());
-
- org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitDefaults persistenceUnitDefaultsResource = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults();
- persistenceUnitMetadata.setPersistenceUnitDefaults(persistenceUnitDefaultsResource);
- assertTrue(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setCascadePersist(true);
- assertFalse(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setCascadePersist(false);
- assertTrue(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setSchema("asdf");
- assertFalse(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setSchema(null);
- assertTrue(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setCatalog("asdf");
- assertFalse(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setCatalog(null);
- assertTrue(persistenceUnitDefaultsResource.isUnset());
-
-
- persistenceUnitDefaultsResource.setAccess(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY);
- assertFalse(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setAccess(org.eclipse.jpt.jpa.core.resource.orm.AccessType.FIELD);
- assertFalse(persistenceUnitDefaultsResource.isUnset());
-
- persistenceUnitDefaultsResource.setAccess(null);
- assertTrue(persistenceUnitDefaultsResource.isUnset());
- }
-
- public void testUpdateSchema() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set schema in the resource model, verify context model updated
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set schema to null in the resource model
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
- }
-
- public void testModifySchema() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set schema in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set schema to null in the context model
- persistenceUnitDefaults.setSpecifiedSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifySchema2() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set schema in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("MY_CATALOG");
- //set schema to null in the context model
- persistenceUnitDefaults.setSpecifiedSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
- }
-
- public void testModifySchema3() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set schema in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedSchema("MY_SCHEMA");
- assertEquals("MY_SCHEMA", persistenceUnitDefaults.getSchema());
- assertEquals("MY_SCHEMA", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getSchema());
-
- //set schema to null in the context model
- persistenceUnitDefaults.setSpecifiedSchema(null);
- assertNull(persistenceUnitDefaults.getSchema());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
- public void testUpdateCatalog() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set catalog in the resource model, verify context model updated
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set catalog to null in the resource model
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
- }
-
- public void testModifyCatalog() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set catalog in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set catalog to null in the context model
- persistenceUnitDefaults.setSpecifiedCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyCatalog2() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set catalog in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSchema("MY_SCHEMA");
- //set catalog to null in the context model
- persistenceUnitDefaults.setSpecifiedCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
- }
-
- public void testModifyCatalog3() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set catalog in the context model, verify resource model modified
- persistenceUnitDefaults.setSpecifiedCatalog("MY_CATALOG");
- assertEquals("MY_CATALOG", persistenceUnitDefaults.getCatalog());
- assertEquals("MY_CATALOG", getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getCatalog());
-
- //set catalog to null in the context model
- persistenceUnitDefaults.setSpecifiedCatalog(null);
- assertNull(persistenceUnitDefaults.getCatalog());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
- public void testUpdateCascadePersist() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set cascadePersist in the resource model, verify context model updated
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set cascadePersist to null in the resource model, persistence-unit-defaults tag not removed
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertFalse(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
- }
-
- public void testModifyCascadePersist() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set cascadePersist in the context model, verify resource model modified
- persistenceUnitDefaults.setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set cascadePersist to null in the context model
- persistenceUnitDefaults.setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyCascadePersist2() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set cascadePersist in the context model, verify resource model modified
- persistenceUnitDefaults.setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCatalog("MY_CATALOG");
- //set cascadePersist to null in the context model
- persistenceUnitDefaults.setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertFalse(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
- }
-
- public void testModifyCascadePersist3() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set cascadePersist in the context model, verify resource model modified
- persistenceUnitDefaults.setCascadePersist(true);
- assertTrue(persistenceUnitDefaults.isCascadePersist());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().isCascadePersist());
-
- //set cascadePersist to null in the context model
- persistenceUnitDefaults.setCascadePersist(false);
- assertFalse(persistenceUnitDefaults.isCascadePersist());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
-
- public void testUpdateAccess() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set access in the resource model, verify context model updated
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(org.eclipse.jpt.jpa.core.resource.orm.AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.FIELD, getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set access to null in the resource model
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
- }
-
- public void testModifyAccess() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set access in the context model, verify resource model modified
- persistenceUnitDefaults.setAccess(AccessType.PROPERTY);
- assertEquals(AccessType.PROPERTY, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set access to null in the context model
- persistenceUnitDefaults.setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyAccess2() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set access in the context model, verify resource model modified
- persistenceUnitDefaults.setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.FIELD, getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set another element on the persistence-unit-defaults element so it doesn't get removed
- getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setCascadePersist(true);
- //set access to null in the context model
- persistenceUnitDefaults.setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
- }
-
- public void testModifyAccess3() throws Exception {
- OrmPersistenceUnitDefaults persistenceUnitDefaults = persistenceUnitDefaults();
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- //set another element on the persistence-unit-metadata element so only persistence-unit-defaults element gets removed
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
-
- //set access in the context model, verify resource model modified
- persistenceUnitDefaults.setAccess(AccessType.FIELD);
- assertEquals(AccessType.FIELD, persistenceUnitDefaults.getAccess());
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.FIELD, getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults().getAccess());
-
- //set access to null in the context model
- persistenceUnitDefaults.setAccess(null);
- assertNull(persistenceUnitDefaults.getAccess());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata().getPersistenceUnitDefaults());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitMetadataTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitMetadataTests.java
deleted file mode 100644
index 801aab9ed0..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkPersistenceUnitMetadataTests.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlPersistenceUnitMetadata;
-
-public class EclipseLinkPersistenceUnitMetadataTests extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkPersistenceUnitMetadataTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.toString());
- getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- getPersistenceXmlResource().save(null);
- }
-
- protected OrmPersistenceUnitMetadata persistenceUnitMetadata() {
- return getEntityMappings().getPersistenceUnitMetadata();
- }
-
- public void testIsAllFeaturesUnset() throws Exception {
- XmlPersistenceUnitMetadata persistenceUnitMetadata = EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata();
- getXmlEntityMappings().setPersistenceUnitMetadata(persistenceUnitMetadata);
- assertTrue(persistenceUnitMetadata.isUnset());
-
- persistenceUnitMetadata.setXmlMappingMetadataComplete(true);
- assertFalse(persistenceUnitMetadata.isUnset());
-
- persistenceUnitMetadata.setXmlMappingMetadataComplete(false);
- assertTrue(persistenceUnitMetadata.isUnset());
-
- persistenceUnitMetadata.setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- assertFalse(persistenceUnitMetadata.isUnset());
- }
-
- public void testUpdateXmlMappingMetadataComplete() throws Exception {
- OrmPersistenceUnitMetadata persistenceUnitMetadata = getEntityMappings().getPersistenceUnitMetadata();
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set xmlMappingMetadataComplete in the resource model, verify context model updated
- getXmlEntityMappings().setPersistenceUnitMetadata(EclipseLinkOrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata());
- getXmlEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertTrue(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
-
- //set xmlMappingMetadataComplete to null in the resource model
- getXmlEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertFalse(getXmlEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
- }
-
- public void testModifyXmlMappingMetadataComplete() throws Exception {
- OrmPersistenceUnitMetadata persistenceUnitMetadata = getEntityMappings().getPersistenceUnitMetadata();
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set xmlMappingMetadataComplete in the context model, verify resource model modified
- persistenceUnitMetadata.setXmlMappingMetadataComplete(true);
- assertTrue(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
-
- //set xmlMappingMetadataComplete to null in the context model
- persistenceUnitMetadata.setXmlMappingMetadataComplete(false);
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
- }
-
- public void testModifyXmlMappingMetadataComplete2() throws Exception {
- OrmPersistenceUnitMetadata persistenceUnitMetadata = getEntityMappings().getPersistenceUnitMetadata();
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertNull(getXmlEntityMappings().getPersistenceUnitMetadata());
-
- //set xmlMappingMetadataComplete in the context model, verify resource model modified
- persistenceUnitMetadata.setXmlMappingMetadataComplete(true);
- assertTrue(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertTrue(getXmlEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
-
- //set xmlMappingMetadataComplete to null in the context model
- //set another element on the persistence-unit-metadata element so it doesn't get removed
- getXmlEntityMappings().getPersistenceUnitMetadata().setPersistenceUnitDefaults(OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults());
- persistenceUnitMetadata.setXmlMappingMetadataComplete(false);
- assertFalse(persistenceUnitMetadata.isXmlMappingMetadataComplete());
- assertFalse(getXmlEntityMappings().getPersistenceUnitMetadata().isXmlMappingMetadataComplete());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/JptEclipseLinkCoreOrmContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/JptEclipseLinkCoreOrmContextModelTests.java
deleted file mode 100644
index 95ba5bd68e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/JptEclipseLinkCoreOrmContextModelTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.context.orm;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptEclipseLinkCoreOrmContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreOrmContextModelTests.class.getName());
- suite.addTestSuite(EclipseLinkEntityMappingsTests.class);
- suite.addTestSuite(EclipseLinkPersistenceUnitMetadataTests.class);
- suite.addTestSuite(EclipseLinkPersistenceUnitDefaultsTests.class);
- suite.addTestSuite(EclipseLinkOrmEmbeddableTests.class);
- suite.addTestSuite(EclipseLinkOrmEntityTests.class);
- suite.addTestSuite(EclipseLinkOrmMappedSuperclassTests.class);
- suite.addTestSuite(EclipseLinkOrmBasicMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmIdMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmManyToManyMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmManyToOneMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmOneToManyMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmOneToOneMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmPersistentAttributeTests.class);
- suite.addTestSuite(EclipseLinkOrmVersionMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmTransientMappingTests.class);
- suite.addTestSuite(EclipseLinkOrmConverterTests.class);
- suite.addTestSuite(EclipseLinkOrmObjectTypeConverterTests.class);
- suite.addTestSuite(EclipseLinkOrmStructConverterTests.class);
- suite.addTestSuite(EclipseLinkOrmTypeConverterTests.class);
- return suite;
- }
-
-
- private JptEclipseLinkCoreOrmContextModelTests() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java
deleted file mode 100644
index d6ca4d10f5..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTestCase.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.persistence;
-
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.jpa.core.tests.internal.context.persistence.PersistenceUnitTestCase;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * PersistenceUnitTestCase
- */
-public abstract class EclipseLinkPersistenceUnitTestCase extends PersistenceUnitTestCase
-{
- protected EclipseLinkPersistenceUnit subject;
-
- protected PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder;
-
- // ********** constructors **********
- protected EclipseLinkPersistenceUnitTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject = this.getPersistenceUnit();
- this.subjectHolder = new SimplePropertyValueModel<EclipseLinkPersistenceUnit>(this.subject);
- this.populatePu();
- }
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, EclipseLinkPlatform.VERSION_1_0);
- return dataModel;
- }
-
- @Override
- protected EclipseLinkPersistenceUnit getPersistenceUnit() {
- return (EclipseLinkPersistenceUnit) super.getPersistenceUnit();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTests.java
deleted file mode 100644
index 6aee690a4e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTests.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.persistence;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.orm.EclipseLinkOrmContextModelTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public class EclipseLinkPersistenceUnitTests
- extends EclipseLinkOrmContextModelTestCase
-{
- public EclipseLinkPersistenceUnitTests(String name) {
- super(name);
- }
-
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-
- @Override
- protected IDataModel buildEclipseLinkOrmConfig(TestJpaProject testJpaProject) {
- IDataModel dataModel =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- dataModel.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- testJpaProject.getProject().getFolder("src/META-INF").getFullPath());
- dataModel.setProperty(OrmFileCreationDataModelProperties.ADD_TO_PERSISTENCE_UNIT, Boolean.FALSE);
- return dataModel;
- }
-
- private ICompilationUnit createTestEntity() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
- });
- }
-
- public void testUpdateEclipseLinkImpliedMappingFileRef1() throws Exception {
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
-
- // test that there is one initially
- JpaXmlResource eclipseLinkOrmResource = getOrmXmlResource();
- assertTrue(eclipseLinkOrmResource.fileExists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
- assertNotNull(persistenceUnit.getImpliedEclipseLinkMappingFileRef());
-
- // remove eclipselink-orm.xml
- deleteResource(eclipseLinkOrmResource);
-
- assertFalse(eclipseLinkOrmResource.fileExists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
- assertNull(persistenceUnit.getImpliedEclipseLinkMappingFileRef());
- }
-
- public void testUpdateEclipseLinkImpliedMappingFileRef2() {
- XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
-
- // test that there is one initially
- JpaXmlResource eclipseLinkOrmResource = getOrmXmlResource();
- assertTrue(eclipseLinkOrmResource.fileExists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
- assertNotNull(persistenceUnit.getImpliedEclipseLinkMappingFileRef());
-
- // add specified eclipselink-orm.xml
- XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- xmlMappingFileRef.setFileName("META-INF/eclipselink-orm.xml");
- xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
-
- assertEquals(1, CollectionTools.size(persistenceUnit.specifiedMappingFileRefs()));
-
- assertTrue(eclipseLinkOrmResource.fileExists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
- assertNull(persistenceUnit.getImpliedEclipseLinkMappingFileRef());
- }
-
- public void testUpdateEclipseLinkImpliedMappingFileRef3() {
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
-
- // test that there is one initially
- JpaXmlResource eclipseLinkOrmResource = getOrmXmlResource();
- assertTrue(eclipseLinkOrmResource.fileExists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
- assertNotNull(persistenceUnit.getImpliedEclipseLinkMappingFileRef());
-
- // ignore in persistence unit
- persistenceUnit.getGeneralProperties().setExcludeEclipselinkOrm(Boolean.TRUE);
-
- assertTrue(eclipseLinkOrmResource.fileExists());
- assertNotNull(persistenceUnit.getImpliedMappingFileRef());
- assertNull(persistenceUnit.getImpliedEclipseLinkMappingFileRef());
- }
-
- public void testMappingFileRefs() {
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- ListIterator<MappingFileRef> mappingFileRefs = persistenceUnit.mappingFileRefs();
-
- assertEquals(persistenceUnit.getImpliedMappingFileRef(), mappingFileRefs.next().getMappingFile().getParent());
- assertEquals(persistenceUnit.getImpliedEclipseLinkMappingFileRef(), mappingFileRefs.next().getMappingFile().getParent());
- }
-
- public void testMappingFileRefsSize() {
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- assertEquals(2, persistenceUnit.mappingFileRefsSize());
- }
-
- public void testPersistentType() throws Exception {
- getJpaProject().setDiscoversAnnotatedClasses(false);
- PersistenceUnit persistenceUnit = getPersistenceUnit();
- createTestEntity();
-
- //persistentType not listed in persistence.xml and discoverAnnotatedClasses is false
- //still find the persistentType because of changes for bug 190317
- assertFalse(getJpaProject().discoversAnnotatedClasses());
- assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
-
- //test persistentType not listed in persistence.xml, discover annotated classes set to true
- getJpaProject().setDiscoversAnnotatedClasses(true);
- assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
-
- //test persistentType list as class in persistence.xml
- getJpaProject().setDiscoversAnnotatedClasses(false);
- XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- classRef.setJavaClass(FULLY_QUALIFIED_TYPE_NAME);
- getXmlPersistenceUnit().getClasses().add(classRef);
- assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
-
-
- //test persistentType from orm.xml file that is specified in the persistence.xml
- addXmlMappingFileRef(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.toString());
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
- assertEquals(ormPersistentType, persistenceUnit.getPersistentType("model.Foo"));
-
- //test persistentType from eclipselink-orm.xml file that is implied(not specified) in the persistence.xml
- getXmlPersistenceUnit().getMappingFiles().remove(0);
- assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/JptEclipseLinkCorePersistenceContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/JptEclipseLinkCorePersistenceContextModelTests.java
deleted file mode 100644
index dffd65e090..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/JptEclipseLinkCorePersistenceContextModelTests.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.eclipselink.core.tests.internal.context.persistence;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.caching.JptEclipseLinkPersistenceCachingTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.connection.JptEclipseLinkPersistenceConnectionTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.customization.JptEclipseLinkPersistenceCustomizationTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.general.JptEclipseLinkPersistenceGeneralTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.logging.JptEclipseLinkPersistenceLoggingTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.options.JptEclipseLinkPersistenceOptionsTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.schema.generation.JptEclipseLinkPersistenceSchemaGenerationTests;
-
-public class JptEclipseLinkCorePersistenceContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCorePersistenceContextModelTests.class.getName());
- suite.addTestSuite(EclipseLinkPersistenceUnitTests.class);
- suite.addTest(JptEclipseLinkPersistenceGeneralTests.suite());
- suite.addTest(JptEclipseLinkPersistenceConnectionTests.suite());
- suite.addTest(JptEclipseLinkPersistenceCustomizationTests.suite());
- suite.addTest(JptEclipseLinkPersistenceCachingTests.suite());
- suite.addTest(JptEclipseLinkPersistenceLoggingTests.suite());
- suite.addTest(JptEclipseLinkPersistenceOptionsTests.suite());
- suite.addTest(JptEclipseLinkPersistenceSchemaGenerationTests.suite());
- return suite;
- }
-
- private JptEclipseLinkCorePersistenceContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java
deleted file mode 100644
index bb2a737f6d..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingAdapterTests.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 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.eclipselink.core.tests.internal.context.persistence.caching;
-
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.CacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.Caching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.Entity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.FlushClearCache;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * Tests the update of model objects by the Caching adapter when the
- * PersistenceUnit changes.
- */
-@SuppressWarnings("nls")
-public class CachingAdapterTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Caching caching;
- private ListEvent entitiesEvent;
-
- public static final String ENTITY_TEST = "Employee";
- public static final String ENTITY_TEST_2 = "Address";
-
- public static final String CACHE_TYPE_DEFAULT_KEY = Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT;
- public static final CacheType CACHE_TYPE_DEFAULT_TEST_VALUE = CacheType.soft_weak;
- public static final CacheType CACHE_TYPE_DEFAULT_TEST_VALUE_2 = CacheType.full;
-
- public static final String CACHE_SIZE_DEFAULT_KEY = Caching.ECLIPSELINK_CACHE_SIZE_DEFAULT;
- public static final Integer CACHE_SIZE_DEFAULT_TEST_VALUE = 12345;
- public static final Integer CACHE_SIZE_DEFAULT_TEST_VALUE_2 = 67890;
-
- public static final String SHARED_CACHE_DEFAULT_KEY = Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT;
- public static final Boolean SHARED_CACHE_DEFAULT_TEST_VALUE = false;
- public static final Boolean SHARED_CACHE_DEFAULT_TEST_VALUE_2 = true;
-
- public static final String CACHE_TYPE_KEY = Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_TEST;
- public static final CacheType CACHE_TYPE_TEST_VALUE = CacheType.soft_weak;
- public static final CacheType CACHE_TYPE_TEST_VALUE_2 = CacheType.full;
-
- public static final String SHARED_CACHE_KEY = Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_TEST;
- public static final Boolean SHARED_CACHE_TEST_VALUE = false;
- public static final Boolean SHARED_CACHE_TEST_VALUE_2 = true;
-
- public static final String CACHE_SIZE_KEY = Caching.ECLIPSELINK_CACHE_SIZE + ENTITY_TEST;
- public static final Integer CACHE_SIZE_TEST_VALUE = 12345;
- public static final Integer CACHE_SIZE_TEST_VALUE_2 = 67890;
-
- public static final String FLUSH_CLEAR_CACHE_KEY = Caching.ECLIPSELINK_FLUSH_CLEAR_CACHE;
- public static final FlushClearCache FLUSH_CLEAR_CACHE_TEST_VALUE = FlushClearCache.drop;
- public static final FlushClearCache FLUSH_CLEAR_CACHE_TEST_VALUE_2 = FlushClearCache.merge;
-
- public CachingAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.caching = this.getPersistenceUnit().getCaching();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.caching.addPropertyChangeListener(Caching.CACHE_TYPE_DEFAULT_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.CACHE_SIZE_DEFAULT_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.SHARED_CACHE_DEFAULT_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Entity.CACHE_TYPE_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Entity.CACHE_SIZE_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Entity.SHARED_CACHE_PROPERTY, propertyChangeListener);
- this.caching.addPropertyChangeListener(Caching.FLUSH_CLEAR_CACHE_PROPERTY, propertyChangeListener);
-
- ListChangeListener entitiesChangeListener = this.buildEntitiesChangeListener();
- this.caching.addListChangeListener(Caching.ENTITIES_LIST, entitiesChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 7;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(CACHE_TYPE_DEFAULT_KEY, CACHE_TYPE_DEFAULT_TEST_VALUE);
- this.persistenceUnitSetProperty("misc.property.2", "value.2");
- this.persistenceUnitSetProperty(CACHE_SIZE_DEFAULT_KEY, CACHE_SIZE_DEFAULT_TEST_VALUE);
- this.persistenceUnitSetProperty(SHARED_CACHE_DEFAULT_KEY, SHARED_CACHE_DEFAULT_TEST_VALUE);
- this.persistenceUnitSetProperty("misc.property.3", "value.3");
- this.persistenceUnitSetProperty("misc.property.4", "value.4");
- this.persistenceUnitSetProperty(CACHE_SIZE_KEY, CACHE_SIZE_TEST_VALUE);
- this.persistenceUnitSetProperty(CACHE_TYPE_KEY, CACHE_TYPE_TEST_VALUE);
- this.persistenceUnitSetProperty(SHARED_CACHE_KEY, SHARED_CACHE_TEST_VALUE);
- this.persistenceUnitSetProperty(FLUSH_CLEAR_CACHE_KEY, FLUSH_CLEAR_CACHE_TEST_VALUE);
- return;
- }
-
- // ********** Listeners **********
- private ListChangeListener buildEntitiesChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- CachingAdapterTests.this.entityAdded(e);
- }
-
- public void itemsRemoved(ListRemoveEvent e) {
- CachingAdapterTests.this.entityRemoved(e);
- }
-
- public void itemsReplaced(ListReplaceEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsMoved(ListMoveEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listCleared(ListClearEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listChanged(ListChangeEvent e) {
- CachingAdapterTests.this.throwUnsupportedOperationException(e);
- }
- };
- }
-
- @Override
- protected void clearEvent() {
- super.clearEvent();
- this.entitiesEvent = null;
- }
-
- void entityAdded(ListAddEvent e) {
- this.entitiesEvent = e;
- }
-
- void entityRemoved(ListRemoveEvent e) {
- this.entitiesEvent = e;
- }
-
- // ********** entities list **********
- public void testEntitiesList() throws Exception {
- // add
- this.clearEvent();
- int originalNumberOfEntities = this.caching.entitiesSize();
-
- this.caching.addEntity(ENTITY_TEST_2);
- assertEquals("Entity not added", this.caching.entitiesSize(), originalNumberOfEntities + 1);
-
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getListName(), Caching.ENTITIES_LIST);
-
- // remove
- this.clearEvent();
- this.caching.removeEntity(ENTITY_TEST_2);
- assertEquals("Entity not removed", this.caching.entitiesSize(), originalNumberOfEntities);
-
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getListName(), Caching.ENTITIES_LIST);
- }
-
- // ********** CacheTypeDefault **********
- /**
- * Tests the update of CacheTypeDefault property by the Caching adapter when
- * the PU or the model changes.
- */
- public void testSetCacheTypeDefault() throws Exception {
- this.verifyModelInitialized(
- CACHE_TYPE_DEFAULT_KEY,
- CACHE_TYPE_DEFAULT_TEST_VALUE);
- this.verifySetProperty(
- CACHE_TYPE_DEFAULT_KEY,
- CACHE_TYPE_DEFAULT_TEST_VALUE,
- CACHE_TYPE_DEFAULT_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheTypeDefault() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_TYPE_DEFAULT_KEY,
- CACHE_TYPE_DEFAULT_TEST_VALUE,
- CACHE_TYPE_DEFAULT_TEST_VALUE_2);
- }
-
- // ********** CacheSizeDefault **********
- /**
- * Tests the update of CacheSizeDefault property by the Caching adapter when
- * the PU or the model changes.
- */
- public void testSetCacheSizeDefault() throws Exception {
- this.verifyModelInitialized(
- CACHE_SIZE_DEFAULT_KEY,
- CACHE_SIZE_DEFAULT_TEST_VALUE);
- this.verifySetProperty(
- CACHE_SIZE_DEFAULT_KEY,
- CACHE_SIZE_DEFAULT_TEST_VALUE,
- CACHE_SIZE_DEFAULT_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheSizeDefault() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_SIZE_DEFAULT_KEY,
- CACHE_SIZE_DEFAULT_TEST_VALUE,
- CACHE_SIZE_DEFAULT_TEST_VALUE_2);
- }
-
- // ********** SharedCacheDefault **********
- public void testSetSharedCacheDefault() throws Exception {
- this.verifyModelInitialized(
- SHARED_CACHE_DEFAULT_KEY,
- SHARED_CACHE_DEFAULT_TEST_VALUE);
- this.verifySetProperty(
- SHARED_CACHE_DEFAULT_KEY,
- SHARED_CACHE_DEFAULT_TEST_VALUE,
- SHARED_CACHE_DEFAULT_TEST_VALUE_2);
- }
-
- public void testAddRemoveSharedCacheDefault() throws Exception {
- this.verifyAddRemoveProperty(
- SHARED_CACHE_DEFAULT_KEY,
- SHARED_CACHE_DEFAULT_TEST_VALUE,
- SHARED_CACHE_DEFAULT_TEST_VALUE_2);
- }
-
- // ********** CacheType **********
- /**
- * Tests the update of CacheType property by the Caching adapter when the PU
- * or the model changes.
- */
- public void testSetCacheType() throws Exception {
- this.verifyModelInitialized(
- CACHE_TYPE_KEY,
- CACHE_TYPE_TEST_VALUE);
- this.verifySetCachingProperty(
- Entity.CACHE_TYPE_PROPERTY,
- CACHE_TYPE_KEY,
- CACHE_TYPE_TEST_VALUE,
- CACHE_TYPE_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheType() throws Exception {
- this.verifyAddRemoveCachingProperty(
- Entity.CACHE_TYPE_PROPERTY,
- CACHE_TYPE_KEY,
- CACHE_TYPE_TEST_VALUE,
- CACHE_TYPE_TEST_VALUE_2);
- }
-
- // ********** CacheSize **********
- /**
- * Tests the update of CacheSize property by the Caching adapter when the PU
- * or the model changes.
- */
- public void testSetCacheSize() throws Exception {
- this.verifyModelInitialized(
- CACHE_SIZE_KEY,
- CACHE_SIZE_TEST_VALUE);
- this.verifySetCachingProperty(
- Entity.CACHE_SIZE_PROPERTY,
- CACHE_SIZE_KEY,
- CACHE_SIZE_TEST_VALUE,
- CACHE_SIZE_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheSize() throws Exception {
- this.verifyAddRemoveCachingProperty(
- Entity.CACHE_SIZE_PROPERTY,
- CACHE_SIZE_KEY,
- CACHE_SIZE_TEST_VALUE,
- CACHE_SIZE_TEST_VALUE_2);
- }
-
- // ********** SharedCache **********
- /**
- * Tests the update of SharedCache property by the Caching adapter when the
- * PU or the model changes.
- */
- public void testSetSharedCache() throws Exception {
- this.verifyModelInitialized(
- SHARED_CACHE_KEY,
- SHARED_CACHE_TEST_VALUE);
- this.verifySetCachingProperty(
- Entity.SHARED_CACHE_PROPERTY,
- SHARED_CACHE_KEY,
- SHARED_CACHE_TEST_VALUE,
- SHARED_CACHE_TEST_VALUE_2);
- }
-
- public void testAddRemoveSharedCache() throws Exception {
- this.verifyAddRemoveCachingProperty(
- Entity.SHARED_CACHE_PROPERTY,
- SHARED_CACHE_KEY,
- SHARED_CACHE_TEST_VALUE,
- SHARED_CACHE_TEST_VALUE_2);
- }
-
- // ********** FlushClearCache tests **********
- public void testSetFlushClearCache() throws Exception {
- this.verifyModelInitialized(
- FLUSH_CLEAR_CACHE_KEY,
- FLUSH_CLEAR_CACHE_TEST_VALUE);
- this.verifySetProperty(
- FLUSH_CLEAR_CACHE_KEY,
- FLUSH_CLEAR_CACHE_TEST_VALUE,
- FLUSH_CLEAR_CACHE_TEST_VALUE_2);
- }
-
- public void testAddRemoveFlushClearCache() throws Exception {
- this.verifyAddRemoveProperty(
- FLUSH_CLEAR_CACHE_KEY,
- FLUSH_CLEAR_CACHE_TEST_VALUE,
- FLUSH_CLEAR_CACHE_TEST_VALUE_2);
- }
-
- // ****** convenience methods *******
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.caching;
- }
-
- protected void verifySetCachingProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Replace
- this.persistenceUnitSetProperty(key, testValue2);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue2);
-
- // Replace by setting model object
- this.clearEvent();
- this.setCachingProperty(propertyName, ENTITY_TEST, testValue1);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue1);
- }
-
- protected void verifyAddRemoveCachingProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.getPersistenceUnit().removeProperty(key);
- assertNull(this.getPersistenceUnit().getProperty(key));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, null);
-
- // Add original Property
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitSetProperty(key, testValue1);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue1);
-
- // Set to null
- this.persistenceUnitSetProperty(key, null);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, null);
-
- // Replace
- this.persistenceUnitSetProperty(key, testValue2);
- this.verifyPutCachingProperty(propertyName, ENTITY_TEST, testValue2);
- }
-
- protected void verifyPutCachingProperty(String propertyName, String entityName, Object expectedValue) throws Exception {
- this.verifyEvent(propertyName);
- this.verifyCachingEvent(propertyName, entityName, expectedValue);
- }
-
- protected void verifyCachingEvent(String propertyName, String entityName, Object expectedValue) throws Exception {
- // verify event value
- Entity entity = (Entity) this.propertyChangedEvent.getNewValue();
- if (propertyName.equals(Entity.CACHE_TYPE_PROPERTY)) {
- assertEquals(expectedValue, entity.getParent().getCacheTypeOf(entityName));
- assertEquals(expectedValue, this.caching.getCacheTypeOf(entityName));
- }
- else if (propertyName.equals(Entity.CACHE_SIZE_PROPERTY)) {
- assertEquals(expectedValue, entity.getParent().getCacheSizeOf(entityName));
- assertEquals(expectedValue, this.caching.getCacheSizeOf(entityName));
- }
- else if (propertyName.equals(Entity.SHARED_CACHE_PROPERTY)) {
- assertEquals(expectedValue, entity.getParent().getSharedCacheOf(entityName));
- assertEquals(expectedValue, this.caching.getSharedCacheOf(entityName));
- }
- else {
- this.throwMissingDefinition("verifyCachingEvent", propertyName);
- }
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Caching.CACHE_TYPE_DEFAULT_PROPERTY))
- this.caching.setCacheTypeDefault((CacheType) newValue);
- else if (propertyName.equals(Caching.CACHE_SIZE_DEFAULT_PROPERTY))
- this.caching.setCacheSizeDefault((Integer) newValue);
- else if (propertyName.equals(Caching.SHARED_CACHE_DEFAULT_PROPERTY))
- this.caching.setSharedCacheDefault((Boolean) newValue);
- else if (propertyName.equals(Caching.FLUSH_CLEAR_CACHE_PROPERTY))
- this.caching.setFlushClearCache((FlushClearCache) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- protected void setCachingProperty(String propertyName, String entityName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(Entity.CACHE_TYPE_PROPERTY))
- this.caching.setCacheTypeOf(entityName, (CacheType) newValue);
- else if (propertyName.equals(Entity.CACHE_SIZE_PROPERTY))
- this.caching.setCacheSizeOf(entityName, (Integer) newValue);
- else if (propertyName.equals(Entity.SHARED_CACHE_PROPERTY))
- this.caching.setSharedCacheOf(entityName, (Boolean) newValue);
- else
- this.throwMissingDefinition("setCachingProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Caching.CACHE_TYPE_DEFAULT_PROPERTY))
- modelValue = this.caching.getCacheTypeDefault();
- else if (propertyName.equals(Caching.CACHE_SIZE_DEFAULT_PROPERTY))
- modelValue = this.caching.getCacheSizeDefault();
- else if (propertyName.equals(Caching.SHARED_CACHE_DEFAULT_PROPERTY))
- modelValue = this.caching.getSharedCacheDefault();
- else if (propertyName.equals(Entity.CACHE_SIZE_PROPERTY))
- modelValue = this.caching.getCacheSizeOf(ENTITY_TEST);
- else if (propertyName.equals(Entity.CACHE_TYPE_PROPERTY))
- modelValue = this.caching.getCacheTypeOf(ENTITY_TEST);
- else if (propertyName.equals(Entity.SHARED_CACHE_PROPERTY))
- modelValue = this.caching.getSharedCacheOf(ENTITY_TEST);
- else if (propertyName.equals(Caching.FLUSH_CLEAR_CACHE_PROPERTY))
- modelValue = this.caching.getFlushClearCache();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java
deleted file mode 100644
index aad538e72a..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/CachingValueModelTests.java
+++ /dev/null
@@ -1,444 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.persistence.caching;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.CacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.Caching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.caching.Entity;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * CachingValueModelTests
- */
-@SuppressWarnings("nls")
-public class CachingValueModelTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Caching caching;
- private PropertyValueModel<Caching> cachingHolder;
-
- private WritablePropertyValueModel<CacheType> cacheTypeHolder;
- private PropertyChangeListener cacheTypeListener;
- private PropertyChangeEvent cacheTypeEvent;
-
- private WritablePropertyValueModel<Boolean> sharedCacheHolder;
- private PropertyChangeListener sharedCacheListener;
- private PropertyChangeEvent sharedCacheEvent;
-
- private WritablePropertyValueModel<CacheType> cacheTypeDefaultHolder;
- private PropertyChangeListener cacheTypeDefaultListener;
- private PropertyChangeEvent cacheTypeDefaultEvent;
-
- private WritablePropertyValueModel<Boolean> sharedCacheDefaultHolder;
- private PropertyChangeListener sharedCacheDefaultListener;
- private PropertyChangeEvent sharedCacheDefaultEvent;
-
- public static final String ENTITY_NAME_TEST_VALUE = "Employee";
- public static final CacheType CACHE_TYPE_TEST_VALUE = CacheType.hard_weak;
- public static final Boolean SHARED_CACHE_TEST_VALUE = Boolean.FALSE;
- public static final CacheType CACHE_TYPE_DEFAULT_TEST_VALUE = CacheType.weak;
- public static final Boolean SHARED_CACHE_DEFAULT_TEST_VALUE = Boolean.FALSE;
-
- public CachingValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.caching = this.subject.getCaching(); // Subject
- this.cachingHolder = new SimplePropertyValueModel<Caching>(this.caching);
-
- this.cacheTypeHolder = this.buildCacheTypeAA(this.cachingHolder);
- this.cacheTypeListener = this.buildCacheTypeChangeListener();
- this.cacheTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
- this.cacheTypeEvent = null;
-
- this.sharedCacheHolder = this.buildSharedCacheAA(this.cachingHolder);
- this.sharedCacheListener = this.buildSharedCacheChangeListener();
- this.sharedCacheHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
- this.sharedCacheEvent = null;
-
- this.cacheTypeDefaultHolder = this.buildCacheTypeDefaultAA(this.cachingHolder);
- this.cacheTypeDefaultListener = this.buildCacheTypeDefaultChangeListener();
- this.cacheTypeDefaultHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeDefaultListener);
- this.cacheTypeDefaultEvent = null;
-
- this.sharedCacheDefaultHolder = this.buildSharedCacheDefaultAA(this.cachingHolder);
- this.sharedCacheDefaultListener = this.buildSharedCacheDefaultChangeListener();
- this.sharedCacheDefaultHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheDefaultListener);
- this.sharedCacheDefaultEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectCaching = (AbstractModel) this.caching; // Subject
- PropertyAspectAdapter<Caching, CacheType> cacheTypeAA =
- (PropertyAspectAdapter<Caching, CacheType>) this.cacheTypeHolder;
- assertTrue(cacheTypeAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_PROPERTY));
-
- cacheTypeAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_PROPERTY));
- assertFalse(cacheTypeAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyAspectAdapter<Caching, Boolean> sharedCacheAA =
- (PropertyAspectAdapter<Caching, Boolean>) this.sharedCacheHolder;
- assertTrue(sharedCacheAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_PROPERTY));
-
- sharedCacheAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_PROPERTY));
- assertFalse(sharedCacheAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyAspectAdapter<Caching, CacheType> cacheTypeDefaultAA =
- (PropertyAspectAdapter<Caching, CacheType>) this.cacheTypeDefaultHolder;
- assertTrue(cacheTypeDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_DEFAULT_PROPERTY));
-
- cacheTypeDefaultAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeDefaultListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.CACHE_TYPE_DEFAULT_PROPERTY));
- assertFalse(cacheTypeDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- PropertyAspectAdapter<Caching, Boolean> sharedCacheDefaultAA =
- (PropertyAspectAdapter<Caching, Boolean>) this.sharedCacheDefaultHolder;
- assertTrue(sharedCacheDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_DEFAULT_PROPERTY));
-
- sharedCacheDefaultAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheDefaultListener);
- assertFalse(subjectCaching.hasAnyPropertyChangeListeners(Caching.SHARED_CACHE_DEFAULT_PROPERTY));
- assertFalse(sharedCacheDefaultAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitSetProperty(
- Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE,
- CACHE_TYPE_TEST_VALUE);
- this.persistenceUnitSetProperty(
- Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE,
- SHARED_CACHE_TEST_VALUE);
- this.persistenceUnitSetProperty(
- Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT,
- CACHE_TYPE_DEFAULT_TEST_VALUE);
- this.persistenceUnitSetProperty(
- Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT,
- SHARED_CACHE_DEFAULT_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.caching;
- }
-
- /** ****** CacheType ******* */
- private WritablePropertyValueModel<CacheType> buildCacheTypeAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, CacheType>(subjectHolder, Caching.CACHE_TYPE_PROPERTY) {
- @Override
- protected CacheType buildValue_() {
- return this.subject.getCacheTypeOf(ENTITY_NAME_TEST_VALUE);
- }
-
- @Override
- protected void setValue_(CacheType enumValue) {
- this.subject.setCacheTypeOf(ENTITY_NAME_TEST_VALUE, enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildCacheTypeChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.cacheTypeEvent = e;
- }
- };
- }
-
- /** ****** SharedCache ******* */
- private WritablePropertyValueModel<Boolean> buildSharedCacheAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, Boolean>(subjectHolder, Caching.SHARED_CACHE_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSharedCacheOf(ENTITY_NAME_TEST_VALUE);
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setSharedCacheOf(ENTITY_NAME_TEST_VALUE, enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildSharedCacheChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.sharedCacheEvent = e;
- }
- };
- }
-
- /** ****** CacheTypeDefault ******* */
- private WritablePropertyValueModel<CacheType> buildCacheTypeDefaultAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, CacheType>(subjectHolder, Caching.CACHE_TYPE_DEFAULT_PROPERTY) {
- @Override
- protected CacheType buildValue_() {
- return this.subject.getCacheTypeDefault();
- }
-
- @Override
- protected void setValue_(CacheType enumValue) {
- this.subject.setCacheTypeDefault(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildCacheTypeDefaultChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.cacheTypeDefaultEvent = e;
- }
- };
- }
-
- /** ****** SharedCacheDefault ******* */
- private WritablePropertyValueModel<Boolean> buildSharedCacheDefaultAA(PropertyValueModel<Caching> subjectHolder) {
- return new PropertyAspectAdapter<Caching, Boolean>(subjectHolder, Caching.SHARED_CACHE_DEFAULT_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSharedCacheDefault();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setSharedCacheDefault(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildSharedCacheDefaultChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingValueModelTests.this.sharedCacheDefaultEvent = e;
- }
- };
- }
-
- /** ****** Basic Entity's Properties Tests ******* */
-
- public void testClone() {
- Entity entity = this.buildEntity("TestEntity", CacheType.full, 100, true);
-
- this.verifyClone(entity, entity.clone());
- }
-
- public void testEquals() {
- Entity entity1 = this.buildEntity("TestEntityA", CacheType.full, 100, true);
- Entity entity2 = this.buildEntity("TestEntityB", CacheType.full, 100, true);
- assertEquals(entity1, entity2);
- Entity entity3 = this.buildEntity("TestEntityC", CacheType.full, 100, true);
- assertEquals(entity1, entity3);
- assertEquals(entity2, entity3);
- }
-
- public void testIsEmpty() {
- Entity entity = this.buildEntity("TestEntity");
- assertTrue(entity.isEmpty());
- this.caching.setCacheSizeOf(entity.getName(), 100);
- assertFalse(entity.isEmpty());
- }
-
- private void verifyClone(Entity original, Entity clone) {
- assertNotSame(original, clone);
- assertEquals(original, original);
- assertEquals(original, clone);
- }
-
- private Entity buildEntity(String name) {
- return this.caching.addEntity(name);
- }
-
- private Entity buildEntity(String name, CacheType cacheType, Integer size, Boolean isShared) {
- Entity entity = this.caching.addEntity(name);
- this.caching.setCacheTypeOf(entity.getName(), cacheType);
- this.caching.setCacheSizeOf(entity.getName(), size);
- this.caching.setSharedCacheOf(entity.getName(), isShared);
- return entity;
- }
-
- /** ****** Caching Tests ******* */
- public void testValue() {
- /** ****** CacheType - defaults for entity level caching are equal to the persistence unit settings ******* */
- this.verifyCacheTypeAAValue(CACHE_TYPE_TEST_VALUE);
- assertEquals(this.caching.getCacheTypeDefault(), this.caching.getDefaultCacheType());
- /** ****** SharedCache - defaults for entity level caching are equal to the persistence unit settings ******* */
- this.verifySharedCacheAAValue(SHARED_CACHE_TEST_VALUE);
- assertEquals(this.caching.getSharedCacheDefault(), this.caching.getDefaultSharedCache());
- /** ****** CacheTypeDefault ******* */
- this.verifyCacheTypeDefaultAAValue(CACHE_TYPE_DEFAULT_TEST_VALUE);
- assertEquals(Caching.DEFAULT_CACHE_TYPE_DEFAULT, this.caching.getDefaultCacheTypeDefault());
- /** ****** SharedCacheDefault ******* */
- this.verifySharedCacheDefaultAAValue(SHARED_CACHE_DEFAULT_TEST_VALUE);
- assertEquals(Caching.DEFAULT_SHARED_CACHE_DEFAULT, this.caching.getDefaultSharedCacheDefault());
- }
-
- public void testSetValue() throws Exception {
- /** ****** CacheType ******* */
- this.cacheTypeEvent = null;
- this.verifyHasListeners(this.cacheTypeHolder, PropertyValueModel.VALUE);
- CacheType newCacheType = CacheType.full;
- // Modify the property holder
- this.cacheTypeHolder.setValue(newCacheType);
- this.verifyCacheTypeAAValue(newCacheType);
- assertNotNull(this.cacheTypeEvent);
- /** ****** SharedCache ******* */
- this.sharedCacheEvent = null;
- this.verifyHasListeners(this.sharedCacheHolder, PropertyValueModel.VALUE);
- Boolean newSharedCache = !SHARED_CACHE_TEST_VALUE;
- // Modify the property holder
- this.sharedCacheHolder.setValue(newSharedCache);
- this.verifySharedCacheAAValue(newSharedCache);
- assertNotNull(this.sharedCacheEvent);
- /** ****** CacheTypeDefault ******* */
- this.cacheTypeDefaultEvent = null;
- this.verifyHasListeners(this.cacheTypeDefaultHolder, PropertyValueModel.VALUE);
- CacheType newCacheTypeDefault = CacheType.none;
- // Modify the property holder
- this.cacheTypeDefaultHolder.setValue(newCacheTypeDefault);
- this.verifyCacheTypeDefaultAAValue(newCacheTypeDefault);
- assertNotNull(this.cacheTypeDefaultEvent);
- /** ****** SharedCacheDefault ******* */
- this.sharedCacheDefaultEvent = null;
- this.verifyHasListeners(this.sharedCacheDefaultHolder, PropertyValueModel.VALUE);
- Boolean newSharedCacheDefault = !SHARED_CACHE_DEFAULT_TEST_VALUE;
- // Modify the property holder
- this.sharedCacheDefaultHolder.setValue(newSharedCacheDefault);
- this.verifySharedCacheDefaultAAValue(newSharedCacheDefault);
- assertNotNull(this.sharedCacheDefaultEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- /** ****** CacheType ******* */
- this.cacheTypeEvent = null;
- // Setting the property holder
- this.cacheTypeHolder.setValue(null);
- // testing Holder
- this.verifyCacheTypeAAValue(null);
- assertNotNull(this.cacheTypeEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE, notDeleted);
- /** ****** SharedCache ******* */
- this.sharedCacheEvent = null;
- // Setting the property holder
- this.sharedCacheHolder.setValue(null);
- // testing Holder
- this.verifySharedCacheAAValue(null);
- assertNotNull(this.sharedCacheEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE, notDeleted);
- /** ****** CacheTypeDefault ******* */
- this.cacheTypeDefaultEvent = null;
- // Setting the property holder
- this.cacheTypeDefaultHolder.setValue(null);
- // testing Holder
- this.verifyCacheTypeDefaultAAValue(null);
- assertNotNull(this.cacheTypeDefaultEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT, notDeleted);
- /** ****** SharedCacheDefault ******* */
- this.sharedCacheDefaultEvent = null;
- // Setting the property holder
- this.sharedCacheDefaultHolder.setValue(null);
- // testing Holder
- this.verifySharedCacheDefaultAAValue(null);
- assertNotNull(this.sharedCacheDefaultEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT, notDeleted);
- }
-
- /** ****** convenience methods ******* */
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyCacheTypeAAValue(CacheType testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getCacheTypeOf(ENTITY_NAME_TEST_VALUE),
- this.cacheTypeHolder,
- Caching.ECLIPSELINK_CACHE_TYPE + ENTITY_NAME_TEST_VALUE);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifySharedCacheAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getSharedCacheOf(ENTITY_NAME_TEST_VALUE),
- this.sharedCacheHolder,
- Caching.ECLIPSELINK_SHARED_CACHE + ENTITY_NAME_TEST_VALUE);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyCacheTypeDefaultAAValue(CacheType testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getCacheTypeDefault(),
- this.cacheTypeDefaultHolder,
- Caching.ECLIPSELINK_CACHE_TYPE_DEFAULT);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifySharedCacheDefaultAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.caching.getSharedCacheDefault(),
- this.sharedCacheDefaultHolder,
- Caching.ECLIPSELINK_CACHE_SHARED_DEFAULT);
- }
-
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/JptEclipseLinkPersistenceCachingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/JptEclipseLinkPersistenceCachingTests.java
deleted file mode 100644
index fd24717c89..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/caching/JptEclipseLinkPersistenceCachingTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.eclipselink.core.tests.internal.context.persistence.caching;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceCachingTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceCachingTests.class.getPackage().getName());
-
- suite.addTestSuite(CachingValueModelTests.class);
- suite.addTestSuite(CachingAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceCachingTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/EclipseLinkConnectionTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/EclipseLinkConnectionTests.java
deleted file mode 100644
index bf955c54ab..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/EclipseLinkConnectionTests.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.persistence.connection;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.connection.BatchWriting;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.connection.Connection;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.connection.ExclusiveConnectionMode;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * ConnectionAdapterTests
- */
-@SuppressWarnings("nls")
-public class EclipseLinkConnectionTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Connection connection;
-
- public static final PersistenceUnitTransactionType TRANSACTION_TYPE_TEST_VALUE = PersistenceUnitTransactionType.RESOURCE_LOCAL;
- public static final PersistenceUnitTransactionType TRANSACTION_TYPE_TEST_VALUE_2 = PersistenceUnitTransactionType.JTA;
-
- public static final String JTA_DATA_SOURCE_TEST_VALUE = "Test_JTA";
- public static final String JTA_DATA_SOURCE_TEST_VALUE_2 = "Test_JTA_2";
-
- public static final String NON_JTA_DATA_SOURCE_TEST_VALUE = "Test_Non_JTA";
- public static final String NON_JTA_DATA_SOURCE_TEST_VALUE_2 = "Test_Non_JTA_2";
-
- public static final String NATIVE_SQL_KEY = Connection.ECLIPSELINK_NATIVE_SQL;
- public static final Boolean NATIVE_SQL_TEST_VALUE = false;
- public static final Boolean NATIVE_SQL_TEST_VALUE_2 = ! NATIVE_SQL_TEST_VALUE;
-
- public static final String BATCH_WRITING_KEY = Connection.ECLIPSELINK_BATCH_WRITING;
- public static final BatchWriting BATCH_WRITING_TEST_VALUE = BatchWriting.oracle_jdbc;
- public static final BatchWriting BATCH_WRITING_TEST_VALUE_2 = BatchWriting.buffered;
-
- public static final String CACHE_STATEMENTS_KEY = Connection.ECLIPSELINK_CACHE_STATEMENTS;
- public static final Boolean CACHE_STATEMENTS_TEST_VALUE = false;
- public static final Boolean CACHE_STATEMENTS_TEST_VALUE_2 = ! CACHE_STATEMENTS_TEST_VALUE;
-
- public static final String CACHE_STATEMENTS_SIZE_KEY = Connection.ECLIPSELINK_CACHE_STATEMENTS_SIZE;
- public static final Integer CACHE_STATEMENTS_SIZE_TEST_VALUE = 100;
- public static final Integer CACHE_STATEMENTS_SIZE_TEST_VALUE_2 = 200;
-
- public static final String DRIVER_KEY = Connection.ECLIPSELINK_DRIVER;
- public static final String DRIVER_TEST_VALUE = "connection.driver";
- public static final String DRIVER_TEST_VALUE_2 = "connection.driver.2";
-
- public static final String URL_KEY = Connection.ECLIPSELINK_URL;
- public static final String URL_TEST_VALUE = "test";
- public static final String URL_TEST_VALUE_2 = "test_2";
-
- public static final String USER_KEY = Connection.ECLIPSELINK_USER;
- public static final String USER_TEST_VALUE = "test";
- public static final String USER_TEST_VALUE_2 = "test_2";
-
- public static final String PASSWORD_KEY = Connection.ECLIPSELINK_PASSWORD;
- public static final String PASSWORD_TEST_VALUE = "test";
- public static final String PASSWORD_TEST_VALUE_2 = "test_2";
-
- public static final String BIND_PARAMETERS_KEY = Connection.ECLIPSELINK_BIND_PARAMETERS;
- public static final Boolean BIND_PARAMETERS_TEST_VALUE = false;
- public static final Boolean BIND_PARAMETERS_TEST_VALUE_2 = ! BIND_PARAMETERS_TEST_VALUE;
-
- public static final String READ_CONNECTIONS_SHARED_KEY = Connection.ECLIPSELINK_READ_CONNECTIONS_SHARED;
- public static final Boolean READ_CONNECTIONS_SHARED_TEST_VALUE = false;
- public static final Boolean READ_CONNECTIONS_SHARED_TEST_VALUE_2 = ! READ_CONNECTIONS_SHARED_TEST_VALUE;
-
- public static final String READ_CONNECTIONS_MIN_KEY = Connection.ECLIPSELINK_READ_CONNECTIONS_MIN;
- public static final Integer READ_CONNECTIONS_MIN_TEST_VALUE = 100;
- public static final Integer READ_CONNECTIONS_MIN_TEST_VALUE_2 = 200;
-
- public static final String READ_CONNECTIONS_MAX_KEY = Connection.ECLIPSELINK_READ_CONNECTIONS_MAX;
- public static final Integer READ_CONNECTIONS_MAX_TEST_VALUE = 100;
- public static final Integer READ_CONNECTIONS_MAX_TEST_VALUE_2 = 200;
-
- public static final String WRITE_CONNECTIONS_MIN_KEY = Connection.ECLIPSELINK_WRITE_CONNECTIONS_MIN;
- public static final Integer WRITE_CONNECTIONS_MIN_TEST_VALUE = 100;
- public static final Integer WRITE_CONNECTIONS_MIN_TEST_VALUE_2 = 200;
-
- public static final String WRITE_CONNECTIONS_MAX_KEY = Connection.ECLIPSELINK_WRITE_CONNECTIONS_MAX;
- public static final Integer WRITE_CONNECTIONS_MAX_TEST_VALUE = 100;
- public static final Integer WRITE_CONNECTIONS_MAX_TEST_VALUE_2 = 200;
-
- public static final String EXCLUSIVE_CONNECTION_MODE_KEY = Connection.ECLIPSELINK_EXCLUSIVE_CONNECTION_MODE;
- public static final ExclusiveConnectionMode EXCLUSIVE_CONNECTION_MODE_TEST_VALUE = ExclusiveConnectionMode.always;
- public static final ExclusiveConnectionMode EXCLUSIVE_CONNECTION_MODE_TEST_VALUE_2 = ExclusiveConnectionMode.isolated;
-
- public static final String LAZY_CONNECTION_KEY = Connection.ECLIPSELINK_LAZY_CONNECTION;
- public static final Boolean LAZY_CONNECTION_TEST_VALUE = false;
- public static final Boolean LAZY_CONNECTION_TEST_VALUE_2 = ! LAZY_CONNECTION_TEST_VALUE;
-
- // ********** constructors **********
- public EclipseLinkConnectionTests(String name) {
- super(name);
- }
-
- // ********** behavior **********
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.connection = this.subject.getConnection();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.connection.addPropertyChangeListener(Connection.NATIVE_SQL_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.BATCH_WRITING_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.CACHE_STATEMENTS_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.CACHE_STATEMENTS_SIZE_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.DRIVER_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.URL_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.USER_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.PASSWORD_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.BIND_PARAMETERS_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.READ_CONNECTIONS_SHARED_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.READ_CONNECTIONS_MIN_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.READ_CONNECTIONS_MAX_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.WRITE_CONNECTIONS_MIN_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.WRITE_CONNECTIONS_MAX_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.EXCLUSIVE_CONNECTION_MODE_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.LAZY_CONNECTION_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 16; // EclipseLink properties
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- // Initializes EclipseLink properties
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(NATIVE_SQL_KEY, NATIVE_SQL_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(BATCH_WRITING_KEY, BATCH_WRITING_TEST_VALUE);
- this.persistenceUnitSetProperty(CACHE_STATEMENTS_KEY, CACHE_STATEMENTS_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(CACHE_STATEMENTS_SIZE_KEY, CACHE_STATEMENTS_SIZE_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(DRIVER_KEY, DRIVER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(URL_KEY, URL_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(USER_KEY, USER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(PASSWORD_KEY, PASSWORD_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(BIND_PARAMETERS_KEY, BIND_PARAMETERS_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.2", "value.2");
- this.persistenceUnitSetProperty("misc.property.3", "value.3");
- this.persistenceUnitSetProperty(READ_CONNECTIONS_SHARED_KEY, READ_CONNECTIONS_SHARED_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(READ_CONNECTIONS_MIN_KEY, READ_CONNECTIONS_MIN_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(READ_CONNECTIONS_MAX_KEY, READ_CONNECTIONS_MAX_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WRITE_CONNECTIONS_MIN_KEY, WRITE_CONNECTIONS_MIN_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WRITE_CONNECTIONS_MAX_KEY, WRITE_CONNECTIONS_MAX_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.4", "value.4");
- this.persistenceUnitSetProperty(EXCLUSIVE_CONNECTION_MODE_KEY, EXCLUSIVE_CONNECTION_MODE_TEST_VALUE);
- this.persistenceUnitSetProperty(LAZY_CONNECTION_KEY, LAZY_CONNECTION_TEST_VALUE.toString());
-
- // Initializes PU elements
- this.getPersistenceUnit().setSpecifiedTransactionType(TRANSACTION_TYPE_TEST_VALUE);
- this.getPersistenceUnit().setJtaDataSource(JTA_DATA_SOURCE_TEST_VALUE);
- this.getPersistenceUnit().setNonJtaDataSource(NON_JTA_DATA_SOURCE_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.connection;
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Connection.NATIVE_SQL_PROPERTY))
- this.connection.setNativeSql((Boolean) newValue);
- else if (propertyName.equals(Connection.BATCH_WRITING_PROPERTY))
- this.connection.setBatchWriting((BatchWriting) newValue);
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_PROPERTY))
- this.connection.setCacheStatements((Boolean) newValue);
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_SIZE_PROPERTY))
- this.connection.setCacheStatementsSize((Integer) newValue);
- else if (propertyName.equals(Connection.DRIVER_PROPERTY))
- this.connection.setDriver((String) newValue);
- else if (propertyName.equals(Connection.URL_PROPERTY))
- this.connection.setUrl((String) newValue);
- else if (propertyName.equals(Connection.USER_PROPERTY))
- this.connection.setUser((String) newValue);
- else if (propertyName.equals(Connection.PASSWORD_PROPERTY))
- this.connection.setPassword((String) newValue);
- else if (propertyName.equals(Connection.BIND_PARAMETERS_PROPERTY))
- this.connection.setBindParameters((Boolean) newValue);
- else if (propertyName.equals(Connection.READ_CONNECTIONS_SHARED_PROPERTY))
- this.connection.setReadConnectionsShared((Boolean) newValue);
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MIN_PROPERTY))
- this.connection.setReadConnectionsMin((Integer) newValue);
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MAX_PROPERTY))
- this.connection.setReadConnectionsMax((Integer) newValue);
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MIN_PROPERTY))
- this.connection.setWriteConnectionsMin((Integer) newValue);
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MAX_PROPERTY))
- this.connection.setWriteConnectionsMax((Integer) newValue);
- else if (propertyName.equals(Connection.EXCLUSIVE_CONNECTION_MODE_PROPERTY))
- this.connection.setExclusiveConnectionMode((ExclusiveConnectionMode) newValue);
- else if (propertyName.equals(Connection.LAZY_CONNECTION_PROPERTY))
- this.connection.setLazyConnection((Boolean) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Connection.NATIVE_SQL_PROPERTY))
- modelValue = this.connection.getNativeSql();
- else if (propertyName.equals(Connection.BATCH_WRITING_PROPERTY))
- modelValue = this.connection.getBatchWriting();
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_PROPERTY))
- modelValue = this.connection.getCacheStatements();
- else if (propertyName.equals(Connection.CACHE_STATEMENTS_SIZE_PROPERTY))
- modelValue = this.connection.getCacheStatementsSize();
- else if (propertyName.equals(Connection.DRIVER_PROPERTY))
- modelValue = this.connection.getDriver();
- else if (propertyName.equals(Connection.URL_PROPERTY))
- modelValue = this.connection.getUrl();
- else if (propertyName.equals(Connection.USER_PROPERTY))
- modelValue = this.connection.getUser();
- else if (propertyName.equals(Connection.PASSWORD_PROPERTY))
- modelValue = this.connection.getPassword();
- else if (propertyName.equals(Connection.BIND_PARAMETERS_PROPERTY))
- modelValue = this.connection.getBindParameters();
- else if (propertyName.equals(Connection.READ_CONNECTIONS_SHARED_PROPERTY))
- modelValue = this.connection.getReadConnectionsShared();
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MIN_PROPERTY))
- modelValue = this.connection.getReadConnectionsMin();
- else if (propertyName.equals(Connection.READ_CONNECTIONS_MAX_PROPERTY))
- modelValue = this.connection.getReadConnectionsMax();
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MIN_PROPERTY))
- modelValue = this.connection.getWriteConnectionsMin();
- else if (propertyName.equals(Connection.WRITE_CONNECTIONS_MAX_PROPERTY))
- modelValue = this.connection.getWriteConnectionsMax();
- else if (propertyName.equals(Connection.EXCLUSIVE_CONNECTION_MODE_PROPERTY))
- modelValue = this.connection.getExclusiveConnectionMode();
- else if (propertyName.equals(Connection.LAZY_CONNECTION_PROPERTY))
- modelValue = this.connection.getLazyConnection();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- // ********** NativeSql tests **********
- public void testSetNativeSql() throws Exception {
- this.verifyModelInitialized(
- NATIVE_SQL_KEY,
- NATIVE_SQL_TEST_VALUE);
- this.verifySetProperty(
- NATIVE_SQL_KEY,
- NATIVE_SQL_TEST_VALUE,
- NATIVE_SQL_TEST_VALUE_2);
- }
-
- public void testAddRemoveNativeSql() throws Exception {
- this.verifyAddRemoveProperty(
- NATIVE_SQL_KEY,
- NATIVE_SQL_TEST_VALUE,
- NATIVE_SQL_TEST_VALUE_2);
- }
-
- // ********** BatchWriting tests **********
- public void testSetBatchWriting() throws Exception {
- this.verifyModelInitialized(
- BATCH_WRITING_KEY,
- BATCH_WRITING_TEST_VALUE);
- this.verifySetProperty(
- BATCH_WRITING_KEY,
- BATCH_WRITING_TEST_VALUE,
- BATCH_WRITING_TEST_VALUE_2);
- }
-
- public void testAddRemoveBatchWriting() throws Exception {
- this.verifyAddRemoveProperty(
- BATCH_WRITING_KEY,
- BATCH_WRITING_TEST_VALUE,
- BATCH_WRITING_TEST_VALUE_2);
- }
-
- // ********** CacheStatements tests **********
- public void testSetCacheStatements() throws Exception {
- this.verifyModelInitialized(
- CACHE_STATEMENTS_KEY,
- CACHE_STATEMENTS_TEST_VALUE);
- this.verifySetProperty(
- CACHE_STATEMENTS_KEY,
- CACHE_STATEMENTS_TEST_VALUE,
- CACHE_STATEMENTS_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheStatements() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_STATEMENTS_KEY,
- CACHE_STATEMENTS_TEST_VALUE,
- CACHE_STATEMENTS_TEST_VALUE_2);
- }
-
- // ********** CacheStatementsSize tests **********
- public void testSetCacheStatementsSize() throws Exception {
- this.verifyModelInitialized(
- CACHE_STATEMENTS_SIZE_KEY,
- CACHE_STATEMENTS_SIZE_TEST_VALUE);
- this.verifySetProperty(
- CACHE_STATEMENTS_SIZE_KEY,
- CACHE_STATEMENTS_SIZE_TEST_VALUE,
- CACHE_STATEMENTS_SIZE_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheStatementsSize() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_STATEMENTS_SIZE_KEY,
- CACHE_STATEMENTS_SIZE_TEST_VALUE,
- CACHE_STATEMENTS_SIZE_TEST_VALUE_2);
- }
-
- // ********** Driver tests **********
- public void testSetDriver() throws Exception {
- this.verifyModelInitialized(
- DRIVER_KEY,
- DRIVER_TEST_VALUE);
- this.verifySetProperty(
- DRIVER_KEY,
- DRIVER_TEST_VALUE,
- DRIVER_TEST_VALUE_2);
- }
-
- public void testAddRemoveDriver() throws Exception {
- this.verifyAddRemoveProperty(
- DRIVER_KEY,
- DRIVER_TEST_VALUE,
- DRIVER_TEST_VALUE_2);
- }
-
- // ********** Url tests **********
- public void testSetUrl() throws Exception {
- this.verifyModelInitialized(
- URL_KEY,
- URL_TEST_VALUE);
- this.verifySetProperty(
- URL_KEY,
- URL_TEST_VALUE,
- URL_TEST_VALUE_2);
- }
-
- public void testAddRemoveUrl() throws Exception {
- this.verifyAddRemoveProperty(
- URL_KEY,
- URL_TEST_VALUE,
- URL_TEST_VALUE_2);
- }
-
- // ********** User tests **********
- public void testSetUser() throws Exception {
- this.verifyModelInitialized(
- USER_KEY,
- USER_TEST_VALUE);
- this.verifySetProperty(
- USER_KEY,
- USER_TEST_VALUE,
- USER_TEST_VALUE_2);
- }
-
- public void testAddRemoveUser() throws Exception {
- this.verifyAddRemoveProperty(
- USER_KEY,
- USER_TEST_VALUE,
- USER_TEST_VALUE_2);
- }
-
- // ********** Password tests **********
- public void testSetPassword() throws Exception {
- this.verifyModelInitialized(
- PASSWORD_KEY,
- PASSWORD_TEST_VALUE);
- this.verifySetProperty(
- PASSWORD_KEY,
- PASSWORD_TEST_VALUE,
- PASSWORD_TEST_VALUE_2);
- }
-
- public void testAddRemovePassword() throws Exception {
- this.verifyAddRemoveProperty(
- PASSWORD_KEY,
- PASSWORD_TEST_VALUE,
- PASSWORD_TEST_VALUE_2);
- }
-
- // ********** BindParameters tests **********
- public void testSetBindParameters() throws Exception {
- this.verifyModelInitialized(
- BIND_PARAMETERS_KEY,
- BIND_PARAMETERS_TEST_VALUE);
- this.verifySetProperty(
- BIND_PARAMETERS_KEY,
- BIND_PARAMETERS_TEST_VALUE,
- BIND_PARAMETERS_TEST_VALUE_2);
- }
-
- public void testAddRemoveBindParameters() throws Exception {
- this.verifyAddRemoveProperty(
- BIND_PARAMETERS_KEY,
- BIND_PARAMETERS_TEST_VALUE,
- BIND_PARAMETERS_TEST_VALUE_2);
- }
-
- // ********** ReadConnectionsShared tests **********
- public void testSetReadConnectionsShared() throws Exception {
- this.verifyModelInitialized(
- READ_CONNECTIONS_SHARED_KEY,
- READ_CONNECTIONS_SHARED_TEST_VALUE);
- this.verifySetProperty(
- READ_CONNECTIONS_SHARED_KEY,
- READ_CONNECTIONS_SHARED_TEST_VALUE,
- READ_CONNECTIONS_SHARED_TEST_VALUE_2);
- }
-
- public void testAddRemoveReadConnectionsShared() throws Exception {
- this.verifyAddRemoveProperty(
- READ_CONNECTIONS_SHARED_KEY,
- READ_CONNECTIONS_SHARED_TEST_VALUE,
- READ_CONNECTIONS_SHARED_TEST_VALUE_2);
- }
-
- // ********** ReadConnectionsMin tests **********
- public void testSetReadConnectionsMin() throws Exception {
- this.verifyModelInitialized(
- READ_CONNECTIONS_MIN_KEY,
- READ_CONNECTIONS_MIN_TEST_VALUE);
- this.verifySetProperty(
- READ_CONNECTIONS_MIN_KEY,
- READ_CONNECTIONS_MIN_TEST_VALUE,
- READ_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- public void testAddRemoveReadConnectionsMin() throws Exception {
- this.verifyAddRemoveProperty(
- READ_CONNECTIONS_MIN_KEY,
- READ_CONNECTIONS_MIN_TEST_VALUE,
- READ_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- // ********** ReadConnectionsMax tests **********
- public void testSetReadConnectionsMax() throws Exception {
- this.verifyModelInitialized(
- READ_CONNECTIONS_MAX_KEY,
- READ_CONNECTIONS_MAX_TEST_VALUE);
- this.verifySetProperty(
- READ_CONNECTIONS_MAX_KEY,
- READ_CONNECTIONS_MAX_TEST_VALUE,
- READ_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- public void testAddRemoveReadConnectionsMax() throws Exception {
- this.verifyAddRemoveProperty(
- READ_CONNECTIONS_MAX_KEY,
- READ_CONNECTIONS_MAX_TEST_VALUE,
- READ_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- // ********** WriteConnectionsMin tests **********
- public void testSetWriteConnectionsMin() throws Exception {
- this.verifyModelInitialized(
- WRITE_CONNECTIONS_MIN_KEY,
- WRITE_CONNECTIONS_MIN_TEST_VALUE);
- this.verifySetProperty(
- WRITE_CONNECTIONS_MIN_KEY,
- WRITE_CONNECTIONS_MIN_TEST_VALUE,
- WRITE_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- public void testAddRemoveWriteConnectionsMin() throws Exception {
- this.verifyAddRemoveProperty(
- WRITE_CONNECTIONS_MIN_KEY,
- WRITE_CONNECTIONS_MIN_TEST_VALUE,
- WRITE_CONNECTIONS_MIN_TEST_VALUE_2);
- }
-
- // ********** WriteConnectionsMax tests **********
- public void testSetWriteConnectionsMax() throws Exception {
- this.verifyModelInitialized(
- WRITE_CONNECTIONS_MAX_KEY,
- WRITE_CONNECTIONS_MAX_TEST_VALUE);
- this.verifySetProperty(
- WRITE_CONNECTIONS_MAX_KEY,
- WRITE_CONNECTIONS_MAX_TEST_VALUE,
- WRITE_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- public void testAddRemoveWriteConnectionsMax() throws Exception {
- this.verifyAddRemoveProperty(
- WRITE_CONNECTIONS_MAX_KEY,
- WRITE_CONNECTIONS_MAX_TEST_VALUE,
- WRITE_CONNECTIONS_MAX_TEST_VALUE_2);
- }
-
- // ********** ExclusiveConnectionMode tests **********
- public void testSetExclusiveConnectionMode() throws Exception {
- this.verifyModelInitialized(
- EXCLUSIVE_CONNECTION_MODE_KEY,
- EXCLUSIVE_CONNECTION_MODE_TEST_VALUE);
- this.verifySetProperty(
- EXCLUSIVE_CONNECTION_MODE_KEY,
- EXCLUSIVE_CONNECTION_MODE_TEST_VALUE,
- EXCLUSIVE_CONNECTION_MODE_TEST_VALUE_2);
- }
-
- public void testAddRemoveExclusiveConnectionMode() throws Exception {
- this.verifyAddRemoveProperty(
- EXCLUSIVE_CONNECTION_MODE_KEY,
- EXCLUSIVE_CONNECTION_MODE_TEST_VALUE,
- EXCLUSIVE_CONNECTION_MODE_TEST_VALUE_2);
- }
-
- // ********** LazyConnection tests **********
- public void testSetLazyConnection() throws Exception {
- this.verifyModelInitialized(
- LAZY_CONNECTION_KEY,
- LAZY_CONNECTION_TEST_VALUE);
- this.verifySetProperty(
- LAZY_CONNECTION_KEY,
- LAZY_CONNECTION_TEST_VALUE,
- LAZY_CONNECTION_TEST_VALUE_2);
- }
-
- public void testAddRemoveLazyConnection() throws Exception {
- this.verifyAddRemoveProperty(
- LAZY_CONNECTION_KEY,
- LAZY_CONNECTION_TEST_VALUE,
- LAZY_CONNECTION_TEST_VALUE_2);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/JptEclipseLinkPersistenceConnectionTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/JptEclipseLinkPersistenceConnectionTests.java
deleted file mode 100644
index 84a595bfb1..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/connection/JptEclipseLinkPersistenceConnectionTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.persistence.connection;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceConnectionTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceConnectionTests.class.getPackage().getName());
-
-// suite.addTestSuite(ConnectionValueModelTests.class);
- suite.addTestSuite(EclipseLinkConnectionTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceConnectionTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java
deleted file mode 100644
index 4fefb11f86..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/CustomizationValueModelTests.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.persistence.customization;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Customization;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Entity;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * CustomizationValueModelTests
- */
-@SuppressWarnings("nls")
-public class CustomizationValueModelTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Customization customization;
-
- private WritablePropertyValueModel<Boolean> throwExceptionsHolder;
- private PropertyChangeListener throwExceptionsListener;
- private PropertyChangeEvent throwExceptionsEvent;
-
- public static final String ENTITY_NAME_TEST_VALUE = "Employee";
- public static final Boolean THROW_EXCEPTIONS_TEST_VALUE = Boolean.FALSE;
- public static final String CUSTOMIZER_TEST_VALUE = "acme.sessions.Customizer";
-
- public CustomizationValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.customization = this.subject.getCustomization(); // Subject
- PropertyValueModel<Customization> customizationHolder = new SimplePropertyValueModel<Customization>(this.customization);
-
- this.throwExceptionsHolder = this.buildThrowExceptionsAA(customizationHolder);
- this.throwExceptionsListener = this.buildThrowExceptionsChangeListener();
- this.throwExceptionsHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.throwExceptionsListener);
- this.throwExceptionsEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectCustomization = (AbstractModel) this.customization; // Subject
-
- PropertyAspectAdapter<Customization, Boolean> throwExceptionsAA =
- (PropertyAspectAdapter<Customization, Boolean>) this.throwExceptionsHolder;
- assertTrue(throwExceptionsAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectCustomization.hasAnyPropertyChangeListeners(Customization.THROW_EXCEPTIONS_PROPERTY));
-
- throwExceptionsAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.throwExceptionsListener);
- assertFalse(subjectCustomization.hasAnyPropertyChangeListeners(Customization.THROW_EXCEPTIONS_PROPERTY));
- assertFalse(throwExceptionsAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitSetProperty(
- Customization.ECLIPSELINK_THROW_EXCEPTIONS,
- THROW_EXCEPTIONS_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.customization;
- }
-
- // ****** ThrowExceptions *******
- private WritablePropertyValueModel<Boolean> buildThrowExceptionsAA(PropertyValueModel<Customization> subjectHolder) {
- return new PropertyAspectAdapter<Customization, Boolean>(subjectHolder, Customization.THROW_EXCEPTIONS_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getThrowExceptions();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setThrowExceptions(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildThrowExceptionsChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CustomizationValueModelTests.this.throwExceptionsEvent = e;
- }
- };
- }
-
- /** ****** Basic Entity's Properties Tests ******* */
-
- public void testClone() {
- Entity entity = this.buildEntity("TestEntity", CUSTOMIZER_TEST_VALUE);
-
- this.verifyClone(entity, entity.clone());
- }
-
- public void testEquals() {
- Entity entity1 = this.buildEntity("TestEntityA", CUSTOMIZER_TEST_VALUE);
- Entity entity2 = this.buildEntity("TestEntityB", CUSTOMIZER_TEST_VALUE);
- assertEquals(entity1, entity2);
- Entity entity3 = this.buildEntity("TestEntityC", CUSTOMIZER_TEST_VALUE);
- assertEquals(entity1, entity3);
- assertEquals(entity2, entity3);
- }
-
- public void testIsEmpty() {
- Entity entity = this.buildEntity("TestEntity");
- assertTrue(entity.isEmpty());
- this.customization.setDescriptorCustomizerOf(entity.getName(), CUSTOMIZER_TEST_VALUE);
- assertFalse(entity.isEmpty());
- }
-
- private void verifyClone(Entity original, Entity clone) {
- assertNotSame(original, clone);
- assertEquals(original, original);
- assertEquals(original, clone);
- }
-
- private Entity buildEntity(String name) {
- return this.customization.addEntity(name);
- }
-
- private Entity buildEntity(String name, String aClassName) {
- Entity entity = this.customization.addEntity(name);
- this.customization.setDescriptorCustomizerOf(entity.getName(), aClassName);
- return entity;
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** ThrowExceptions *******
- this.verifyThrowExceptionsAAValue(THROW_EXCEPTIONS_TEST_VALUE);
- assertEquals(Customization.DEFAULT_THROW_EXCEPTIONS, this.customization.getDefaultThrowExceptions());
- }
-
- public void testSetValue() throws Exception {
- // ****** ThrowExceptions *******
- this.throwExceptionsEvent = null;
- this.verifyHasListeners(this.throwExceptionsHolder, PropertyValueModel.VALUE);
- Boolean newThrowExceptions = !THROW_EXCEPTIONS_TEST_VALUE;
- // Modify the property holder
- this.throwExceptionsHolder.setValue(newThrowExceptions);
- this.verifyThrowExceptionsAAValue(newThrowExceptions);
- assertNotNull(this.throwExceptionsEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** ThrowExceptions *******
- this.throwExceptionsEvent = null;
- // Setting the property holder
- this.throwExceptionsHolder.setValue(null);
- // testing Holder
- this.verifyThrowExceptionsAAValue(null);
- assertNotNull(this.throwExceptionsEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Customization.ECLIPSELINK_THROW_EXCEPTIONS, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyThrowExceptionsAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.customization.getThrowExceptions(),
- this.throwExceptionsHolder,
- Customization.ECLIPSELINK_THROW_EXCEPTIONS);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/EclipseLinkCustomizationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/EclipseLinkCustomizationTests.java
deleted file mode 100644
index 76904218c8..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/EclipseLinkCustomizationTests.java
+++ /dev/null
@@ -1,761 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 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.eclipselink.core.tests.internal.context.persistence.customization;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Customization;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Entity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Profiler;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.customization.Weaving;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.persistence.customization.EclipseLinkCustomization;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * Tests the update of model objects by the Customization adapter when the
- * PersistenceUnit changes.
- */
-@SuppressWarnings("nls")
-public class EclipseLinkCustomizationTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Customization customization;
- private ListEvent entitiesEvent;
- private ListEvent sessionCustomizersEvent;
-
- public static final String ENTITY_TEST = "Employee";
- public static final String ENTITY_TEST_2 = "Address";
-
- public static final String THROW_EXCEPTIONS_KEY = Customization.ECLIPSELINK_THROW_EXCEPTIONS;
- public static final Boolean THROW_EXCEPTIONS_TEST_VALUE = false;
- public static final Boolean THROW_EXCEPTIONS_TEST_VALUE_2 = ! THROW_EXCEPTIONS_TEST_VALUE;
-
- public static final String WEAVING_LAZY_KEY = Customization.ECLIPSELINK_WEAVING_LAZY;
- public static final Boolean WEAVING_LAZY_TEST_VALUE = false;
- public static final Boolean WEAVING_LAZY_TEST_VALUE_2 = ! WEAVING_LAZY_TEST_VALUE;
-
- public static final String WEAVING_CHANGE_TRACKING_KEY = Customization.ECLIPSELINK_WEAVING_CHANGE_TRACKING;
- public static final Boolean WEAVING_CHANGE_TRACKING_TEST_VALUE = false;
- public static final Boolean WEAVING_CHANGE_TRACKING_TEST_VALUE_2 = ! WEAVING_CHANGE_TRACKING_TEST_VALUE;
-
- public static final String WEAVING_FETCH_GROUPS_KEY = Customization.ECLIPSELINK_WEAVING_FETCH_GROUPS;
- public static final Boolean WEAVING_FETCH_GROUPS_TEST_VALUE = false;
- public static final Boolean WEAVING_FETCH_GROUPS_TEST_VALUE_2 = ! WEAVING_FETCH_GROUPS_TEST_VALUE;
-
- public static final String WEAVING_INTERNAL_KEY = Customization.ECLIPSELINK_WEAVING_INTERNAL;
- public static final Boolean WEAVING_INTERNAL_TEST_VALUE = false;
- public static final Boolean WEAVING_INTERNAL_TEST_VALUE_2 = ! WEAVING_INTERNAL_TEST_VALUE;
-
- public static final String WEAVING_EAGER_KEY = Customization.ECLIPSELINK_WEAVING_EAGER;
- public static final Boolean WEAVING_EAGER_TEST_VALUE = true;
- public static final Boolean WEAVING_EAGER_TEST_VALUE_2 = ! WEAVING_EAGER_TEST_VALUE;
-
- public static final String VALIDATION_ONLY_KEY = Customization.ECLIPSELINK_VALIDATION_ONLY;
- public static final Boolean VALIDATION_ONLY_TEST_VALUE = false;
- public static final Boolean VALIDATION_ONLY_TEST_VALUE_2 = ! VALIDATION_ONLY_TEST_VALUE;
-
- public static final String VALIDATE_SCHEMA_KEY = Customization.ECLIPSELINK_VALIDATE_SCHEMA;
- public static final Boolean VALIDATE_SCHEMA_TEST_VALUE = true;
- public static final Boolean VALIDATE_SCHEMA_TEST_VALUE_2 = ! VALIDATE_SCHEMA_TEST_VALUE;
-
- private static final String SESSION_CUSTOMIZER_KEY = Customization.ECLIPSELINK_SESSION_CUSTOMIZER;
- private static final String SESSION_CUSTOMIZER_TEST_VALUE = "java.lang.String";
- private static final String SESSION_CUSTOMIZER_TEST_VALUE_2 = "java.lang.Boolean";
-
- public static final String WEAVING_KEY = Customization.ECLIPSELINK_WEAVING;
- public static final Weaving WEAVING_TEST_VALUE = Weaving.false_;
- public static final Weaving WEAVING_TEST_VALUE_2 = Weaving.static_;
-
- public static final String CUSTOMIZER_KEY = Customization.ECLIPSELINK_DESCRIPTOR_CUSTOMIZER + ENTITY_TEST;
- public static final String CUSTOMIZER_TEST_VALUE = "acme.sessions.DescriptorCustomizer";
- public static final String CUSTOMIZER_TEST_VALUE_2 = "acme.sessions.Customizer";
-
- private static final String PROFILER_KEY = Customization.ECLIPSELINK_PROFILER;
- private static final Profiler PROFILER_TEST_VALUE = Profiler.query_monitor;
- private static final String PROFILER_TEST_VALUE_2 = "custom.profiler.test";
-
- public static final String EXCEPTION_HANDLER_KEY = Customization.ECLIPSELINK_EXCEPTION_HANDLER;
- public static final String EXCEPTION_HANDLER_TEST_VALUE = "acme.CustomSessionEventListener";
- public static final String EXCEPTION_HANDLER_TEST_VALUE_2 = "oracle.sessions.CustomSessionEventListener";
-
- // ********** constructors **********
- public EclipseLinkCustomizationTests(String name) {
- super(name);
- }
-
- // ********** behavior **********
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.customization = this.subject.getCustomization();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.customization.addPropertyChangeListener(Customization.THROW_EXCEPTIONS_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_LAZY_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_CHANGE_TRACKING_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_FETCH_GROUPS_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_INTERNAL_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_EAGER_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.WEAVING_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.VALIDATION_ONLY_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.VALIDATE_SCHEMA_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.SESSION_CUSTOMIZER_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.PROFILER_PROPERTY, propertyChangeListener);
- this.customization.addPropertyChangeListener(Customization.EXCEPTION_HANDLER_PROPERTY, propertyChangeListener);
-
- ListChangeListener sessionCustomizersChangeListener = this.buildSessionCustomizersChangeListener();
- this.customization.addListChangeListener(Customization.SESSION_CUSTOMIZER_LIST, sessionCustomizersChangeListener);
-
- ListChangeListener entitiesChangeListener = this.buildEntitiesChangeListener();
- this.customization.addListChangeListener(Customization.ENTITIES_LIST, entitiesChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 13;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(THROW_EXCEPTIONS_KEY, THROW_EXCEPTIONS_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WEAVING_LAZY_KEY, WEAVING_LAZY_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WEAVING_CHANGE_TRACKING_KEY, WEAVING_CHANGE_TRACKING_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WEAVING_FETCH_GROUPS_KEY, WEAVING_FETCH_GROUPS_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WEAVING_INTERNAL_KEY, WEAVING_INTERNAL_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WEAVING_EAGER_KEY, WEAVING_EAGER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(VALIDATION_ONLY_KEY, VALIDATION_ONLY_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(VALIDATE_SCHEMA_KEY, VALIDATE_SCHEMA_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.2", "value.2");
- this.persistenceUnitSetProperty(SESSION_CUSTOMIZER_KEY, SESSION_CUSTOMIZER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(WEAVING_KEY, WEAVING_TEST_VALUE);
- this.persistenceUnitSetProperty("misc.property.3", "value.3");
- this.persistenceUnitSetProperty("misc.property.4", "value.4");
- this.persistenceUnitSetProperty(CUSTOMIZER_KEY, CUSTOMIZER_TEST_VALUE);
- this.persistenceUnitSetProperty(PROFILER_KEY, PROFILER_TEST_VALUE);
- this.persistenceUnitSetProperty(EXCEPTION_HANDLER_KEY, EXCEPTION_HANDLER_TEST_VALUE);
- return;
- }
-
- // ********** Listeners **********
- private ListChangeListener buildEntitiesChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- EclipseLinkCustomizationTests.this.entityAdded(e);
- }
-
- public void itemsRemoved(ListRemoveEvent e) {
- EclipseLinkCustomizationTests.this.entityRemoved(e);
- }
-
- public void itemsReplaced(ListReplaceEvent e) {
- EclipseLinkCustomizationTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsMoved(ListMoveEvent e) {
- EclipseLinkCustomizationTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listCleared(ListClearEvent e) {
- EclipseLinkCustomizationTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listChanged(ListChangeEvent e) {
- EclipseLinkCustomizationTests.this.throwUnsupportedOperationException(e);
- }
- };
- }
-
- private ListChangeListener buildSessionCustomizersChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- EclipseLinkCustomizationTests.this.sessionCustomizerAdded(e);
- }
-
- public void itemsRemoved(ListRemoveEvent e) {
- EclipseLinkCustomizationTests.this.sessionCustomizerRemoved(e);
- }
-
- public void itemsReplaced(ListReplaceEvent e) {
- EclipseLinkCustomizationTests.this.sessionCustomizerReplaced(e);
- }
-
- public void itemsMoved(ListMoveEvent e) {
- EclipseLinkCustomizationTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listCleared(ListClearEvent e) {
- EclipseLinkCustomizationTests.this.sessionCustomizerListCleared(e);
- }
-
- public void listChanged(ListChangeEvent e) {
- EclipseLinkCustomizationTests.this.throwUnsupportedOperationException(e);
- }
- };
- }
-
- @Override
- protected void clearEvent() {
- super.clearEvent();
- this.entitiesEvent = null;
- this.sessionCustomizersEvent = null;
- }
-
- void entityAdded(ListAddEvent e) {
- this.entitiesEvent = e;
- }
-
- void entityRemoved(ListRemoveEvent e) {
- this.entitiesEvent = e;
- }
-
- void sessionCustomizerAdded(ListAddEvent e) {
- this.sessionCustomizersEvent = e;
- }
-
- void sessionCustomizerRemoved(ListRemoveEvent e) {
- this.sessionCustomizersEvent = e;
- }
-
- void sessionCustomizerReplaced(ListReplaceEvent e) {
- this.sessionCustomizersEvent = e;
- }
-
- void sessionCustomizerListCleared(ListClearEvent e) {
- this.sessionCustomizersEvent = e;
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Customization.THROW_EXCEPTIONS_PROPERTY))
- this.customization.setThrowExceptions((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_LAZY_PROPERTY))
- this.customization.setWeavingLazy((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_CHANGE_TRACKING_PROPERTY))
- this.customization.setWeavingChangeTracking((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_FETCH_GROUPS_PROPERTY))
- this.customization.setWeavingFetchGroups((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_INTERNAL_PROPERTY))
- this.customization.setWeavingInternal((Boolean) newValue);
- else if (propertyName.equals(Customization.WEAVING_EAGER_PROPERTY))
- this.customization.setWeavingEager((Boolean) newValue);
- else if (propertyName.equals(Customization.VALIDATION_ONLY_PROPERTY))
- this.customization.setValidationOnly((Boolean) newValue);
- else if (propertyName.equals(Customization.VALIDATE_SCHEMA_PROPERTY))
- this.customization.setValidateSchema((Boolean) newValue);
- else if (propertyName.equals(Customization.EXCEPTION_HANDLER_PROPERTY))
- this.customization.setExceptionHandler((String) newValue);
- else if (propertyName.equals(Customization.SESSION_CUSTOMIZER_PROPERTY))
- this.customization.addSessionCustomizer((String) newValue);
- else if (propertyName.equals(Customization.WEAVING_PROPERTY))
- this.customization.setWeaving((Weaving) newValue);
- else if (propertyName.equals(Customization.PROFILER_PROPERTY)) {
- if (newValue.getClass().isEnum())
- this.customization.setProfiler((Profiler) newValue);
- else
- this.customization.setProfiler((String) newValue);
- }
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Customization.THROW_EXCEPTIONS_PROPERTY))
- modelValue = this.customization.getThrowExceptions();
- else if (propertyName.equals(Customization.WEAVING_PROPERTY))
- modelValue = this.customization.getWeaving();
- else if (propertyName.equals(Customization.WEAVING_LAZY_PROPERTY))
- modelValue = this.customization.getWeavingLazy();
- else if (propertyName.equals(Customization.WEAVING_CHANGE_TRACKING_PROPERTY))
- modelValue = this.customization.getWeavingChangeTracking();
- else if (propertyName.equals(Customization.WEAVING_FETCH_GROUPS_PROPERTY))
- modelValue = this.customization.getWeavingFetchGroups();
- else if (propertyName.equals(Customization.WEAVING_INTERNAL_PROPERTY))
- modelValue = this.customization.getWeavingInternal();
- else if (propertyName.equals(Customization.WEAVING_EAGER_PROPERTY))
- modelValue = this.customization.getWeavingEager();
- else if (propertyName.equals(Customization.VALIDATION_ONLY_PROPERTY))
- modelValue = this.customization.getValidationOnly();
- else if (propertyName.equals(Customization.VALIDATE_SCHEMA_PROPERTY))
- modelValue = this.customization.getValidateSchema();
- else if (propertyName.equals(Customization.EXCEPTION_HANDLER_PROPERTY))
- modelValue = this.customization.getExceptionHandler();
- else if (propertyName.equals(Customization.PROFILER_PROPERTY))
- modelValue = this.customization.getProfiler();
- else if (propertyName.equals(Customization.SESSION_CUSTOMIZER_PROPERTY)) {
- ListIterator<String> iterator = this.customization.sessionCustomizers();
- if(iterator.hasNext()) {
- modelValue = iterator.next();
- }
- }
- else if (propertyName.equals(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY))
- modelValue = this.customization.getDescriptorCustomizerOf(ENTITY_TEST);
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void verifyPutProperty(String propertyName, Object expectedValue) throws Exception {
- Object expectedValue_ = expectedValue;
- if (propertyName.equals(Customization.PROFILER_PROPERTY)) {
-
- expectedValue_ = (expectedValue != null && expectedValue.getClass().isEnum()) ?
- this.getPropertyStringValueOf(PROFILER_TEST_VALUE) : // model is storing EclipseLinkStringValue
- expectedValue;
- }
- super.verifyPutProperty(propertyName, expectedValue_);
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.customization;
- }
-
- // ********** entities list **********
- public void testEntitiesList() throws Exception {
- // add
- this.clearEvent();
- this.customization.addEntity(ENTITY_TEST_2);
-
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getListName(), Customization.ENTITIES_LIST);
-
- // remove
- this.clearEvent();
- this.customization.removeEntity(ENTITY_TEST_2);
-
- // verify event received
- assertNotNull("No Event Fired.", this.entitiesEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.entitiesEvent.getListName(), Customization.ENTITIES_LIST);
- }
-
- // ********** sessionCustomizers list **********
- public void testSessionCustomizersList() throws Exception {
- // add
- this.clearEvent();
- String className = this.customization.addSessionCustomizer(SESSION_CUSTOMIZER_TEST_VALUE_2);
-
- // verify event received
- assertNotNull("No Event Fired.", this.sessionCustomizersEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.sessionCustomizersEvent.getListName(), Customization.SESSION_CUSTOMIZER_LIST);
-
- // remove
- this.clearEvent();
-
- this.customization.removeSessionCustomizer(className);
- // verify event received
- assertNotNull("No Event Fired.", this.sessionCustomizersEvent);
- // verify event for the expected property
- assertEquals("Wrong Event.", this.sessionCustomizersEvent.getListName(), Customization.SESSION_CUSTOMIZER_LIST);
- }
-
- // ********** ThrowExceptions tests **********
- public void testSetThrowExceptions() throws Exception {
- this.verifyModelInitialized(
- THROW_EXCEPTIONS_KEY,
- THROW_EXCEPTIONS_TEST_VALUE);
- this.verifySetProperty(
- THROW_EXCEPTIONS_KEY,
- THROW_EXCEPTIONS_TEST_VALUE,
- THROW_EXCEPTIONS_TEST_VALUE_2);
- }
-
- public void testAddRemoveThrowExceptions() throws Exception {
- this.verifyAddRemoveProperty(
- THROW_EXCEPTIONS_KEY,
- THROW_EXCEPTIONS_TEST_VALUE,
- THROW_EXCEPTIONS_TEST_VALUE_2);
- }
-
- // ********** WeavingLazy tests **********
- public void testSetWeavingLazy() throws Exception {
- this.verifyModelInitialized(
- WEAVING_LAZY_KEY,
- WEAVING_LAZY_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_LAZY_KEY,
- WEAVING_LAZY_TEST_VALUE,
- WEAVING_LAZY_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingLazy() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_LAZY_KEY,
- WEAVING_LAZY_TEST_VALUE,
- WEAVING_LAZY_TEST_VALUE_2);
- }
-
- // ********** WeavingChangeTracking tests **********
- public void testSetWeavingChangeTracking() throws Exception {
- this.verifyModelInitialized(
- WEAVING_CHANGE_TRACKING_KEY,
- WEAVING_CHANGE_TRACKING_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_CHANGE_TRACKING_KEY,
- WEAVING_CHANGE_TRACKING_TEST_VALUE,
- WEAVING_CHANGE_TRACKING_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingChangeTracking() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_CHANGE_TRACKING_KEY,
- WEAVING_CHANGE_TRACKING_TEST_VALUE,
- WEAVING_CHANGE_TRACKING_TEST_VALUE_2);
- }
-
- // ********** WeavingFetchGroups tests **********
- public void testSetWeavingFetchGroups() throws Exception {
- this.verifyModelInitialized(
- WEAVING_FETCH_GROUPS_KEY,
- WEAVING_FETCH_GROUPS_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_FETCH_GROUPS_KEY,
- WEAVING_FETCH_GROUPS_TEST_VALUE,
- WEAVING_FETCH_GROUPS_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingFetchGroups() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_FETCH_GROUPS_KEY,
- WEAVING_FETCH_GROUPS_TEST_VALUE,
- WEAVING_FETCH_GROUPS_TEST_VALUE_2);
- }
-
- // ********** WeavingInternal tests **********
- public void testSetWeavingInternal() throws Exception {
- this.verifyModelInitialized(
- WEAVING_INTERNAL_KEY,
- WEAVING_INTERNAL_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_INTERNAL_KEY,
- WEAVING_INTERNAL_TEST_VALUE,
- WEAVING_INTERNAL_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingInternal() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_INTERNAL_KEY,
- WEAVING_INTERNAL_TEST_VALUE,
- WEAVING_INTERNAL_TEST_VALUE_2);
- }
-
- // ********** WeavingEager tests **********
- public void testSetWeavingEager() throws Exception {
- this.verifyModelInitialized(
- WEAVING_EAGER_KEY,
- WEAVING_EAGER_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_EAGER_KEY,
- WEAVING_EAGER_TEST_VALUE,
- WEAVING_EAGER_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeavingEager() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_EAGER_KEY,
- WEAVING_EAGER_TEST_VALUE,
- WEAVING_EAGER_TEST_VALUE_2);
- }
-
- // ********** SessionCustomizer tests **********
- public void testSetSessionCustomizer() throws Exception {
- this.verifyModelInitialized(
- SESSION_CUSTOMIZER_KEY,
- SESSION_CUSTOMIZER_TEST_VALUE);
- this.verifySetSessionCustomizationProperty(
- Customization.SESSION_CUSTOMIZER_PROPERTY,
- SESSION_CUSTOMIZER_KEY,
- SESSION_CUSTOMIZER_TEST_VALUE,
- SESSION_CUSTOMIZER_TEST_VALUE_2);
- }
-
- public void testAddRemoveSessionCustomizer() throws Exception {
- this.verifyAddRemoveSessionCustomizationProperty(
- Customization.SESSION_CUSTOMIZER_PROPERTY,
- SESSION_CUSTOMIZER_KEY,
- SESSION_CUSTOMIZER_TEST_VALUE,
- SESSION_CUSTOMIZER_TEST_VALUE_2);
- }
-
- // ********** Weaving tests **********
- /**
- * Tests the update of Weaving property by the Customization adapter when
- * the PU or the model changes.
- */
- public void testSetWeaving() throws Exception {
- this.verifyModelInitialized(
- WEAVING_KEY,
- WEAVING_TEST_VALUE);
- this.verifySetProperty(
- WEAVING_KEY,
- WEAVING_TEST_VALUE,
- WEAVING_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeaving() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVING_KEY,
- WEAVING_TEST_VALUE,
- WEAVING_TEST_VALUE_2);
- }
-
- // ********** ValidationOnly tests **********
- public void testSetValidationOnly() throws Exception {
- this.verifyModelInitialized(
- VALIDATION_ONLY_KEY,
- VALIDATION_ONLY_TEST_VALUE);
- this.verifySetProperty(
- VALIDATION_ONLY_KEY,
- VALIDATION_ONLY_TEST_VALUE,
- VALIDATION_ONLY_TEST_VALUE_2);
- }
-
- public void testAddRemoveValidationOnly() throws Exception {
- this.verifyAddRemoveProperty(
- VALIDATION_ONLY_KEY,
- VALIDATION_ONLY_TEST_VALUE,
- VALIDATION_ONLY_TEST_VALUE_2);
- }
-
- // ********** ValidateSchema tests **********
- public void testSetValidateSchema() throws Exception {
- this.verifyModelInitialized(
- VALIDATE_SCHEMA_KEY,
- VALIDATE_SCHEMA_TEST_VALUE);
- this.verifySetProperty(
- VALIDATE_SCHEMA_KEY,
- VALIDATE_SCHEMA_TEST_VALUE,
- VALIDATE_SCHEMA_TEST_VALUE_2);
- }
-
- public void testAddRemoveValidateSchema() throws Exception {
- this.verifyAddRemoveProperty(
- VALIDATE_SCHEMA_KEY,
- VALIDATE_SCHEMA_TEST_VALUE,
- VALIDATE_SCHEMA_TEST_VALUE_2);
- }
-
- // ********** ExceptionHandler tests **********
- public void testSetExceptionHandler() throws Exception {
- this.verifyModelInitialized(
- EXCEPTION_HANDLER_KEY,
- EXCEPTION_HANDLER_TEST_VALUE);
- this.verifySetProperty(
- EXCEPTION_HANDLER_KEY,
- EXCEPTION_HANDLER_TEST_VALUE,
- EXCEPTION_HANDLER_TEST_VALUE_2);
- }
-
- public void testAddRemoveExceptionHandler() throws Exception {
- this.verifyAddRemoveProperty(
- EXCEPTION_HANDLER_KEY,
- EXCEPTION_HANDLER_TEST_VALUE,
- EXCEPTION_HANDLER_TEST_VALUE_2);
- }
-
- // ********** Customization class **********
- /**
- * Tests the update of Customization property by the Customization adapter when the
- * PU or the model changes.
- */
- public void testSetCustomization() throws Exception {
- this.verifyModelInitialized(
- CUSTOMIZER_KEY,
- CUSTOMIZER_TEST_VALUE);
- this.verifySetCustomizationProperty(
- Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY,
- CUSTOMIZER_KEY,
- CUSTOMIZER_TEST_VALUE,
- CUSTOMIZER_TEST_VALUE_2);
- }
-
- public void testAddRemoveCustomization() throws Exception {
- this.verifyAddRemoveCustomizationProperty(
- Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY,
- CUSTOMIZER_KEY,
- CUSTOMIZER_TEST_VALUE,
- CUSTOMIZER_TEST_VALUE_2);
- }
-
- // ********** Profiler tests **********
- public void testSetProfiler() throws Exception {
- this.verifyModelInitialized(
- PROFILER_KEY,
- this.getPropertyStringValueOf(PROFILER_TEST_VALUE)); // model is storing EclipseLinkStringValue
- // verify set enum value
- this.verifySetProperty(
- PROFILER_KEY,
- PROFILER_TEST_VALUE,
- PROFILER_TEST_VALUE_2);
- // verify set custom and literal value
- this.verifySetProfiler(
- PROFILER_KEY,
- PROFILER_TEST_VALUE,
- PROFILER_TEST_VALUE_2);
- }
-
- public void testAddRemoveProfiler() throws Exception {
- this.verifyAddRemoveProperty(
- PROFILER_KEY,
- PROFILER_TEST_VALUE,
- PROFILER_TEST_VALUE_2);
- }
-
- /**
- * Verifies setting custom profiler and literals.
- */
- protected void verifySetProfiler(String elKey, Object testValue1, Object testValue2) throws Exception {
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey);
- String propertyName = this.getModel().propertyIdOf(property);
- // test set custom profiler.
- this.clearEvent();
- this.setProperty(propertyName, testValue2);
- this.verifyPutProperty(propertyName, testValue2);
-
- // test set (Profiler) null
- this.clearEvent();
- this.customization.setProfiler((Profiler) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
-
- // test set enum literal
- this.clearEvent();
- this.setProperty(propertyName, testValue1.toString());
- assertNotNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, this.getPropertyStringValueOf(testValue1));
-
- // test set (String) null
- this.clearEvent();
- this.customization.setProfiler((String) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
- }
-
-
-
- // ****** convenience methods *******
-
- // ********** verify SessionCustomizer property **********
- protected void verifySetSessionCustomizationProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Replace
- this.persistenceUnitSetProperty(key, testValue2, true);
- this.propertiesTotal++;
- this.verifyPutSessionCustomizerProperty(propertyName, testValue1);
- }
-
- @SuppressWarnings("unused")
- protected void verifyAddRemoveSessionCustomizationProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.getPersistenceUnit().removeProperty(key, (String) testValue1);
- assertFalse(this.customization.sessionCustomizerExists(key));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
-
- // Add original Property
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitSetProperty(key, testValue1, true);
- this.verifyPutSessionCustomizerProperty(propertyName, testValue1);
- }
-
- protected void verifyPutSessionCustomizerProperty(String propertyName, Object expectedValue) throws Exception {
- // verify event received
- assertNotNull("No Event Fired.", this.sessionCustomizersEvent);
- this.verifySessionCustomizerEvent(propertyName, expectedValue);
- }
-
- @SuppressWarnings("unused")
- protected void verifySessionCustomizerEvent(String propertyName, Object expectedValue) throws Exception {
- // verify event value
- EclipseLinkCustomization customization = (EclipseLinkCustomization) this.sessionCustomizersEvent.getSource();
- assertTrue(customization.sessionCustomizerExists((String) expectedValue));
- return;
- }
-
- // ********** verify entity property **********
- protected void verifySetCustomizationProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Replace
- this.persistenceUnitSetProperty(key, testValue2);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue2);
-
- // Replace by setting model object
- this.clearEvent();
- this.setCustomizationProperty(propertyName, ENTITY_TEST, testValue1);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue1);
- }
-
- protected void verifyAddRemoveCustomizationProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.getPersistenceUnit().removeProperty(key);
- assertNull(this.getPersistenceUnit().getProperty(key));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, null);
-
- // Add original Property
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitSetProperty(key, testValue1);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue1);
-
- // Replace
- this.persistenceUnitSetProperty(key, testValue2);
- this.verifyPutCustomizationProperty(propertyName, ENTITY_TEST, testValue2);
- }
-
- protected void verifyPutCustomizationProperty(String propertyName, String entityName, Object expectedValue) throws Exception {
- this.verifyEvent(propertyName);
- this.verifyCustomizationEvent(propertyName, entityName, expectedValue);
- }
-
- protected void verifyCustomizationEvent(String propertyName, String entityName, Object expectedValue) throws Exception {
- // verify event value
- Entity entity = (Entity) this.propertyChangedEvent.getNewValue();
- if (propertyName.equals(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY)) {
- assertEquals(expectedValue, entity.getParent().getDescriptorCustomizerOf(entityName));
- assertEquals(expectedValue, this.customization.getDescriptorCustomizerOf(entityName));
- }
- else {
- this.throwMissingDefinition("verifyCustomizationEvent", propertyName);
- }
- }
-
- protected void setCustomizationProperty(String propertyName, String entityName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(Entity.DESCRIPTOR_CUSTOMIZER_PROPERTY))
- this.customization.setDescriptorCustomizerOf(entityName, (String) newValue);
- else
- this.throwMissingDefinition("setCustomizationProperty", propertyName);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/JptEclipseLinkPersistenceCustomizationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/JptEclipseLinkPersistenceCustomizationTests.java
deleted file mode 100644
index 48445e28a6..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/customization/JptEclipseLinkPersistenceCustomizationTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.persistence.customization;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceCustomizationTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceCustomizationTests.class.getPackage().getName());
-
- suite.addTestSuite(CustomizationValueModelTests.class);
- suite.addTestSuite(EclipseLinkCustomizationTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceCustomizationTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesAdapterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesAdapterTests.java
deleted file mode 100644
index 7d8f4f5bd3..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesAdapterTests.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.persistence.general;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.general.GeneralProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * GeneralAdapterTests
- */
-@SuppressWarnings("nls")
-public class GeneralPropertiesAdapterTests extends EclipseLinkPersistenceUnitTestCase
-{
- private GeneralProperties generalProperties;
-
- public static final String EXCLUDE_ECLIPSELINK_ORM_KEY = GeneralProperties.ECLIPSELINK_EXCLUDE_ECLIPSELINK_ORM;
- public static final Boolean EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE = false;
- public static final Boolean EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE_2 = ! EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE;
-
-
- public GeneralPropertiesAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.generalProperties = this.subject.getGeneralProperties();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.generalProperties.addPropertyChangeListener(GeneralProperties.EXCLUDE_ECLIPSELINK_ORM_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 1;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 2; // misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(EXCLUDE_ECLIPSELINK_ORM_KEY, EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.2", "value.2");
-
- return;
- }
-
-
- // ********** ExcludeEclipselinkOrm tests **********
- public void testSetExcludeEclipselinkOrm() throws Exception {
- this.verifyModelInitialized(
- EXCLUDE_ECLIPSELINK_ORM_KEY,
- EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE);
- this.verifySetProperty(
- EXCLUDE_ECLIPSELINK_ORM_KEY,
- EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE,
- EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE_2);
- }
-
- public void testAddRemoveExcludeEclipselinkOrm() throws Exception {
- this.verifyAddRemoveProperty(
- EXCLUDE_ECLIPSELINK_ORM_KEY,
- EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE,
- EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE_2);
- }
-
-
-
- // ********** get/set property **********
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(GeneralProperties.EXCLUDE_ECLIPSELINK_ORM_PROPERTY))
- modelValue = this.generalProperties.getExcludeEclipselinkOrm();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(GeneralProperties.EXCLUDE_ECLIPSELINK_ORM_PROPERTY))
- this.generalProperties.setExcludeEclipselinkOrm((Boolean) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.generalProperties;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesValueModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesValueModelTests.java
deleted file mode 100644
index 4551315689..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/GeneralPropertiesValueModelTests.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.persistence.general;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.general.GeneralProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * GeneralPropertyValueModelTests
- */
-@SuppressWarnings("nls")
-public class GeneralPropertiesValueModelTests extends EclipseLinkPersistenceUnitTestCase
-{
- private GeneralProperties generalProperty;
-
- private WritablePropertyValueModel<Boolean> excludeEclipselinkOrmHolder;
- private PropertyChangeListener excludeEclipselinkOrmListener;
- private PropertyChangeEvent excludeEclipselinkOrmEvent;
-
- public static final Boolean EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE = Boolean.FALSE;
-
- public GeneralPropertiesValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.generalProperty = this.subject.getGeneralProperties(); // Subject
- PropertyValueModel<GeneralProperties> generalPropertyHolder = new SimplePropertyValueModel<GeneralProperties>(this.generalProperty);
-
- this.excludeEclipselinkOrmHolder = this.buildExcludeEclipselinkOrmAA(generalPropertyHolder);
- this.excludeEclipselinkOrmListener = this.buildExcludeEclipselinkOrmChangeListener();
- this.excludeEclipselinkOrmHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.excludeEclipselinkOrmListener);
- this.excludeEclipselinkOrmEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectGeneralProperty = (AbstractModel) this.generalProperty; // Subject
-
- PropertyAspectAdapter<GeneralProperties, Boolean> excludeEclipselinkOrmAA =
- (PropertyAspectAdapter<GeneralProperties, Boolean>) this.excludeEclipselinkOrmHolder;
- assertTrue(excludeEclipselinkOrmAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectGeneralProperty.hasAnyPropertyChangeListeners(GeneralProperties.EXCLUDE_ECLIPSELINK_ORM_PROPERTY));
-
- excludeEclipselinkOrmAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.excludeEclipselinkOrmListener);
- assertFalse(subjectGeneralProperty.hasAnyPropertyChangeListeners(GeneralProperties.EXCLUDE_ECLIPSELINK_ORM_PROPERTY));
- assertFalse(excludeEclipselinkOrmAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitSetProperty(
- GeneralProperties.ECLIPSELINK_EXCLUDE_ECLIPSELINK_ORM,
- EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.generalProperty;
- }
-
- // ****** ExcludeEclipselinkOrm *******
- private WritablePropertyValueModel<Boolean> buildExcludeEclipselinkOrmAA(PropertyValueModel<GeneralProperties> subjectHolder) {
- return new PropertyAspectAdapter<GeneralProperties, Boolean>(subjectHolder, GeneralProperties.EXCLUDE_ECLIPSELINK_ORM_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getExcludeEclipselinkOrm();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setExcludeEclipselinkOrm(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildExcludeEclipselinkOrmChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- GeneralPropertiesValueModelTests.this.excludeEclipselinkOrmEvent = e;
- }
- };
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** ExcludeEclipselinkOrm *******
- this.verifyExcludeEclipselinkOrmAAValue(EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE);
- assertEquals(GeneralProperties.DEFAULT_EXCLUDE_ECLIPSELINK_ORM, this.generalProperty.getDefaultExcludeEclipselinkOrm());
- }
-
- public void testSetValue() throws Exception {
- // ****** ExcludeEclipselinkOrm *******
- this.excludeEclipselinkOrmEvent = null;
- this.verifyHasListeners(this.excludeEclipselinkOrmHolder, PropertyValueModel.VALUE);
- Boolean newExcludeEclipselinkOrm = !EXCLUDE_ECLIPSELINK_ORM_TEST_VALUE;
- // Modify the property holder
- this.excludeEclipselinkOrmHolder.setValue(newExcludeEclipselinkOrm);
- this.verifyExcludeEclipselinkOrmAAValue(newExcludeEclipselinkOrm);
- assertNotNull(this.excludeEclipselinkOrmEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** ExcludeEclipselinkOrm *******
- this.excludeEclipselinkOrmEvent = null;
- // Setting the property holder
- this.excludeEclipselinkOrmHolder.setValue(null);
- // testing Holder
- this.verifyExcludeEclipselinkOrmAAValue(null);
- assertNotNull(this.excludeEclipselinkOrmEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(GeneralProperties.ECLIPSELINK_EXCLUDE_ECLIPSELINK_ORM, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyExcludeEclipselinkOrmAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.generalProperty.getExcludeEclipselinkOrm(),
- this.excludeEclipselinkOrmHolder,
- GeneralProperties.ECLIPSELINK_EXCLUDE_ECLIPSELINK_ORM);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/JptEclipseLinkPersistenceGeneralTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/JptEclipseLinkPersistenceGeneralTests.java
deleted file mode 100644
index 1c0be55124..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/general/JptEclipseLinkPersistenceGeneralTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.eclipselink.core.tests.internal.context.persistence.general;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceGeneralTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceGeneralTests.class.getPackage().getName());
-
- suite.addTestSuite(GeneralPropertiesValueModelTests.class);
- suite.addTestSuite(GeneralPropertiesAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceGeneralTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/JptEclipseLinkPersistenceLoggingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/JptEclipseLinkPersistenceLoggingTests.java
deleted file mode 100644
index 30d275491f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/JptEclipseLinkPersistenceLoggingTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.eclipselink.core.tests.internal.context.persistence.logging;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceLoggingTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceLoggingTests.class.getPackage().getName());
-
- suite.addTestSuite(LoggingValueModelTests.class);
- suite.addTestSuite(LoggingAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceLoggingTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java
deleted file mode 100644
index 4a10869b36..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingAdapterTests.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.persistence.logging;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.logging.Logger;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.logging.Logging;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.logging.LoggingLevel;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * Tests the update of model objects by the Logging adapter when the
- * PersistenceUnit changes.
- */
-@SuppressWarnings("nls")
-public class LoggingAdapterTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Logging logging;
-
- public static final String LEVEL_KEY = Logging.ECLIPSELINK_LEVEL;
- public static final LoggingLevel LEVEL_TEST_VALUE = LoggingLevel.fine;
- public static final LoggingLevel LEVEL_TEST_VALUE_2 = LoggingLevel.finest;
-
- public static final String TIMESTAMP_KEY = Logging.ECLIPSELINK_TIMESTAMP;
- public static final Boolean TIMESTAMP_TEST_VALUE = false;
- public static final Boolean TIMESTAMP_TEST_VALUE_2 = ! TIMESTAMP_TEST_VALUE;
-
- public static final String THREAD_KEY = Logging.ECLIPSELINK_THREAD;
- public static final Boolean THREAD_TEST_VALUE = false;
- public static final Boolean THREAD_TEST_VALUE_2 = ! THREAD_TEST_VALUE;
-
- public static final String SESSION_KEY = Logging.ECLIPSELINK_SESSION;
- public static final Boolean SESSION_TEST_VALUE = false;
- public static final Boolean SESSION_TEST_VALUE_2 = ! SESSION_TEST_VALUE;
-
- public static final String EXCEPTIONS_KEY = Logging.ECLIPSELINK_EXCEPTIONS;
- public static final Boolean EXCEPTIONS_TEST_VALUE = false;
- public static final Boolean EXCEPTIONS_TEST_VALUE_2 = ! EXCEPTIONS_TEST_VALUE;
-
- private static final String LOG_FILE_LOCATION_KEY = Logging.ECLIPSELINK_LOG_FILE_LOCATION;
- private static final String LOG_FILE_LOCATION_TEST_VALUE = "C:/temp";
- private static final String LOG_FILE_LOCATION_TEST_VALUE_2 = "C:/tmp";
-
- private static final String LOGGER_KEY = Logging.ECLIPSELINK_LOGGER;
- private static final Logger LOGGER_TEST_VALUE = Logger.java_logger;
- private static final String LOGGER_TEST_VALUE_2 = "custom.logger.test";
-
- public LoggingAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.logging = this.subject.getLogging();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.logging.addPropertyChangeListener(Logging.LEVEL_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.TIMESTAMP_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.THREAD_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.SESSION_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.EXCEPTIONS_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.LOG_FILE_LOCATION_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging.LOGGER_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 7;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(TIMESTAMP_KEY, TIMESTAMP_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.2", "value.2");
- this.persistenceUnitSetProperty(LEVEL_KEY, LEVEL_TEST_VALUE);
- this.persistenceUnitSetProperty("misc.property.3", "value.3");
- this.persistenceUnitSetProperty(THREAD_KEY, THREAD_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(SESSION_KEY, SESSION_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(EXCEPTIONS_KEY, EXCEPTIONS_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.4", "value.4");
- this.persistenceUnitSetProperty(LOG_FILE_LOCATION_KEY, LOG_FILE_LOCATION_TEST_VALUE);
- this.persistenceUnitSetProperty(LOGGER_KEY, LOGGER_TEST_VALUE);
- return;
- }
-
- // ********** Level tests **********
- public void testSetLevel() throws Exception {
- this.verifyModelInitialized(
- LEVEL_KEY,
- LEVEL_TEST_VALUE);
- this.verifySetProperty(
- LEVEL_KEY,
- LEVEL_TEST_VALUE,
- LEVEL_TEST_VALUE_2);
- }
-
- public void testAddRemoveLevel() throws Exception {
- this.verifyAddRemoveProperty(
- LEVEL_KEY,
- LEVEL_TEST_VALUE,
- LEVEL_TEST_VALUE_2);
- }
-
- // ********** Timestamp tests **********
- public void testSetTimestamp() throws Exception {
- this.verifyModelInitialized(
- TIMESTAMP_KEY,
- TIMESTAMP_TEST_VALUE);
- this.verifySetProperty(
- TIMESTAMP_KEY,
- TIMESTAMP_TEST_VALUE,
- TIMESTAMP_TEST_VALUE_2);
- }
-
- public void testAddRemoveTimestamp() throws Exception {
- this.verifyAddRemoveProperty(
- TIMESTAMP_KEY,
- TIMESTAMP_TEST_VALUE,
- TIMESTAMP_TEST_VALUE_2);
- }
-
- // ********** Thread tests **********
- public void testSetThread() throws Exception {
- this.verifyModelInitialized(
- THREAD_KEY,
- THREAD_TEST_VALUE);
- this.verifySetProperty(
- THREAD_KEY,
- THREAD_TEST_VALUE,
- THREAD_TEST_VALUE_2);
- }
-
- public void testAddRemoveThread() throws Exception {
- this.verifyAddRemoveProperty(
- THREAD_KEY,
- THREAD_TEST_VALUE,
- THREAD_TEST_VALUE_2);
- }
-
- // ********** Session tests **********
- public void testSetSession() throws Exception {
- this.verifyModelInitialized(
- SESSION_KEY,
- SESSION_TEST_VALUE);
- this.verifySetProperty(
- SESSION_KEY,
- SESSION_TEST_VALUE,
- SESSION_TEST_VALUE_2);
- }
-
- public void testAddRemoveSession() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_KEY,
- SESSION_TEST_VALUE,
- SESSION_TEST_VALUE_2);
- }
-
- // ********** Exceptions tests **********
- public void testSetExceptions() throws Exception {
- this.verifyModelInitialized(
- EXCEPTIONS_KEY,
- EXCEPTIONS_TEST_VALUE);
- this.verifySetProperty(
- EXCEPTIONS_KEY,
- EXCEPTIONS_TEST_VALUE,
- EXCEPTIONS_TEST_VALUE_2);
- }
-
- public void testAddRemoveExceptions() throws Exception {
- this.verifyAddRemoveProperty(
- EXCEPTIONS_KEY,
- EXCEPTIONS_TEST_VALUE,
- EXCEPTIONS_TEST_VALUE_2);
- }
-
- // ********** LogFileLocation **********
- public void testSetLogFileLocation() throws Exception {
- this.verifyModelInitialized(
- LOG_FILE_LOCATION_KEY,
- LOG_FILE_LOCATION_TEST_VALUE);
- this.verifySetProperty(
- LOG_FILE_LOCATION_KEY,
- LOG_FILE_LOCATION_TEST_VALUE,
- LOG_FILE_LOCATION_TEST_VALUE_2);
- }
-
- public void testAddRemoveLogFileLocation() throws Exception {
- this.verifyAddRemoveProperty(
- LOG_FILE_LOCATION_KEY,
- LOG_FILE_LOCATION_TEST_VALUE,
- LOG_FILE_LOCATION_TEST_VALUE_2);
- }
-
- public void testSetEmptyFileLocation() throws Exception {
- String puKey = LOG_FILE_LOCATION_KEY;
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(puKey);
- String propertyName = this.getModel().propertyIdOf(property);
-
- // Set FileLocation to "" & verify that the property is deleted
- this.verifyPuHasProperty(puKey, "persistenceUnit.properties doesn't contains: ");
- this.setProperty(propertyName, "");
-
- this.verifyPuHasNotProperty(puKey, "Property was not deleted");
- this.verifyPutProperty(propertyName, null);
- assertNull(this.getPersistenceUnit().getProperty(puKey));
- }
-
- // ********** Logger tests **********
- public void testSetLogger() throws Exception {
- this.verifyModelInitialized(
- LOGGER_KEY,
- this.getPropertyStringValueOf(LOGGER_TEST_VALUE)); // model is storing EclipseLinkStringValue
- // verify set enum value
- this.verifySetProperty(
- LOGGER_KEY,
- LOGGER_TEST_VALUE,
- LOGGER_TEST_VALUE_2);
- // verify set custom and literal value
- this.verifySetLogger(
- LOGGER_KEY,
- LOGGER_TEST_VALUE,
- LOGGER_TEST_VALUE_2);
- }
-
- public void testAddRemoveLogger() throws Exception {
- this.verifyAddRemoveProperty(
- LOGGER_KEY,
- LOGGER_TEST_VALUE,
- LOGGER_TEST_VALUE_2);
- }
-
- /**
- * Verifies setting custom logger and literals.
- */
- protected void verifySetLogger(String elKey, Object testValue1, Object testValue2) throws Exception {
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey);
- String propertyName = this.getModel().propertyIdOf(property);
- // test set custom logger.
- this.clearEvent();
- this.setProperty(propertyName, testValue2);
- this.verifyPutProperty(propertyName, testValue2);
-
- // test set (Logger) null
- this.clearEvent();
- this.logging.setLogger((Logger) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
-
- // test set enum literal
- this.clearEvent();
- this.setProperty(propertyName, testValue1.toString());
- assertNotNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, this.getPropertyStringValueOf(testValue1));
-
- // test set (String) null
- this.clearEvent();
- this.logging.setLogger((String) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Logging.LEVEL_PROPERTY))
- this.logging.setLevel((LoggingLevel) newValue);
- else if (propertyName.equals(Logging.TIMESTAMP_PROPERTY))
- this.logging.setTimestamp((Boolean) newValue);
- else if (propertyName.equals(Logging.THREAD_PROPERTY))
- this.logging.setThread((Boolean) newValue);
- else if (propertyName.equals(Logging.SESSION_PROPERTY))
- this.logging.setSession((Boolean) newValue);
- else if (propertyName.equals(Logging.EXCEPTIONS_PROPERTY))
- this.logging.setExceptions((Boolean) newValue);
- else if (propertyName.equals(Logging.LOG_FILE_LOCATION_PROPERTY))
- this.logging.setLogFileLocation((String) newValue);
- else if (propertyName.equals(Logging.LOGGER_PROPERTY)) {
- if (newValue.getClass().isEnum())
- this.logging.setLogger((Logger) newValue);
- else
- this.logging.setLogger((String) newValue);
- }
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Logging.LEVEL_PROPERTY))
- modelValue = this.logging.getLevel();
- else if (propertyName.equals(Logging.TIMESTAMP_PROPERTY))
- modelValue = this.logging.getTimestamp();
- else if (propertyName.equals(Logging.THREAD_PROPERTY))
- modelValue = this.logging.getThread();
- else if (propertyName.equals(Logging.SESSION_PROPERTY))
- modelValue = this.logging.getSession();
- else if (propertyName.equals(Logging.EXCEPTIONS_PROPERTY))
- modelValue = this.logging.getExceptions();
- else if (propertyName.equals(Logging.LOG_FILE_LOCATION_PROPERTY))
- modelValue = this.logging.getLogFileLocation();
- else if (propertyName.equals(Logging.LOGGER_PROPERTY))
- modelValue = this.logging.getLogger();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void verifyPutProperty(String propertyName, Object expectedValue) throws Exception {
- Object expectedValue_ = expectedValue;
- if (propertyName.equals(Logging.LOGGER_PROPERTY)) {
-
- expectedValue_ = (expectedValue != null && expectedValue.getClass().isEnum()) ?
- this.getPropertyStringValueOf(LOGGER_TEST_VALUE) : // model is storing EclipseLinkStringValue
- expectedValue;
- }
- super.verifyPutProperty(propertyName, expectedValue_);
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.logging;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingValueModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingValueModelTests.java
deleted file mode 100644
index cf1076f1bb..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/logging/LoggingValueModelTests.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.persistence.logging;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.logging.Logging;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * LoggingValueModelTests
- */
-@SuppressWarnings("nls")
-public class LoggingValueModelTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Logging logging;
-
- private WritablePropertyValueModel<Boolean> timestampHolder;
- private PropertyChangeListener timestampListener;
- private PropertyChangeEvent timestampEvent;
-
- public static final Boolean TIMESTAMP_TEST_VALUE = Boolean.FALSE;
-
- public LoggingValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.logging = this.subject.getLogging(); // Subject
- PropertyValueModel<Logging> loggingHolder = new SimplePropertyValueModel<Logging>(this.logging);
-
- this.timestampHolder = this.buildTimestampAA(loggingHolder);
- this.timestampListener = this.buildTimestampChangeListener();
- this.timestampHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.timestampListener);
- this.timestampEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectLogging = (AbstractModel) this.logging; // Subject
-
- PropertyAspectAdapter<Logging, Boolean> timestampAA =
- (PropertyAspectAdapter<Logging, Boolean>) this.timestampHolder;
- assertTrue(timestampAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectLogging.hasAnyPropertyChangeListeners(Logging.TIMESTAMP_PROPERTY));
-
- timestampAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.timestampListener);
- assertFalse(subjectLogging.hasAnyPropertyChangeListeners(Logging.TIMESTAMP_PROPERTY));
- assertFalse(timestampAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitSetProperty(
- Logging.ECLIPSELINK_TIMESTAMP,
- TIMESTAMP_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.logging;
- }
-
- // ****** Timestamp *******
- private WritablePropertyValueModel<Boolean> buildTimestampAA(PropertyValueModel<Logging> subjectHolder) {
- return new PropertyAspectAdapter<Logging, Boolean>(subjectHolder, Logging.TIMESTAMP_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getTimestamp();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setTimestamp(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildTimestampChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- LoggingValueModelTests.this.timestampEvent = e;
- }
- };
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** Timestamp *******
- this.verifyTimestampAAValue(TIMESTAMP_TEST_VALUE);
- assertEquals(Logging.DEFAULT_TIMESTAMP, this.logging.getDefaultTimestamp());
- }
-
- public void testSetValue() throws Exception {
- // ****** Timestamp *******
- this.timestampEvent = null;
- this.verifyHasListeners(this.timestampHolder, PropertyValueModel.VALUE);
- Boolean newTimestamp = !TIMESTAMP_TEST_VALUE;
- // Modify the property holder
- this.timestampHolder.setValue(newTimestamp);
- this.verifyTimestampAAValue(newTimestamp);
- assertNotNull(this.timestampEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** Timestamp *******
- this.timestampEvent = null;
- // Setting the property holder
- this.timestampHolder.setValue(null);
- // testing Holder
- this.verifyTimestampAAValue(null);
- assertNotNull(this.timestampEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Logging.ECLIPSELINK_TIMESTAMP, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyTimestampAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.logging.getTimestamp(),
- this.timestampHolder,
- Logging.ECLIPSELINK_TIMESTAMP);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/JptEclipseLinkPersistenceOptionsTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/JptEclipseLinkPersistenceOptionsTests.java
deleted file mode 100644
index 102a23f641..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/JptEclipseLinkPersistenceOptionsTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.eclipselink.core.tests.internal.context.persistence.options;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceOptionsTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceOptionsTests.class.getPackage().getName());
-
- suite.addTestSuite(OptionsValueModelTests.class);
- suite.addTestSuite(OptionsAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceOptionsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java
deleted file mode 100644
index 4fd722d6fd..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsAdapterTests.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.persistence.options;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.options.Options;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.options.TargetDatabase;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.options.TargetServer;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * Tests the update of model objects by the Option adapter when the
- * PersistenceUnit changes.
- */
-@SuppressWarnings("nls")
-public class OptionsAdapterTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Options options;
-
- private static final String SESSION_NAME_KEY = Options.ECLIPSELINK_SESSION_NAME;
- private static final String SESSION_NAME_TEST_VALUE = "session-name.test";
- private static final String SESSION_NAME_TEST_VALUE_2 = "session-name-2.test";
-
- private static final String SESSIONS_XML_KEY = Options.ECLIPSELINK_SESSIONS_XML;
- private static final String SESSIONS_XML_TEST_VALUE = "sessions-xml.test";
- private static final String SESSIONS_XML_TEST_VALUE_2 = "sessions-xml-2.test";
-
- public static final String TARGET_DATABASE_KEY = Options.ECLIPSELINK_TARGET_DATABASE;
- public static final TargetDatabase TARGET_DATABASE_TEST_VALUE = TargetDatabase.cloudscape;
- public static final String TARGET_DATABASE_TEST_VALUE_2 = "custom.targetDatabase.test";
-
- private static final String TARGET_SERVER_KEY = Options.ECLIPSELINK_TARGET_SERVER;
- private static final TargetServer TARGET_SERVER_TEST_VALUE = TargetServer.weblogic_9;
- private static final String TARGET_SERVER_TEST_VALUE_2 = "custom.targetServer.test";
-
- public static final String INCLUDE_DESCRIPTOR_QUERIES_KEY = Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES;
- public static final Boolean INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE = false;
- public static final Boolean INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE_2 = ! INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE;
-
- public static final String SESSION_EVENT_LISTENER_KEY = Options.ECLIPSELINK_SESSION_EVENT_LISTENER;
- public static final String SESSION_EVENT_LISTENER_TEST_VALUE = "acme.CustomSessionEventListener";
- public static final String SESSION_EVENT_LISTENER_TEST_VALUE_2 = "oracle.sessions.CustomSessionEventListener";
-
- public static final String TEMPORAL_MUTABLE_KEY = Options.ECLIPSELINK_TEMPORAL_MUTABLE;
- public static final Boolean TEMPORAL_MUTABLE_TEST_VALUE = true;
- public static final Boolean TEMPORAL_MUTABLE_TEST_VALUE_2 = ! TEMPORAL_MUTABLE_TEST_VALUE;
-
- public OptionsAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.options = this.subject.getOptions();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.options.addPropertyChangeListener(Options.SESSION_NAME_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.SESSIONS_XML_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.TARGET_DATABASE_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.TARGET_SERVER_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.SESSION_EVENT_LISTENER_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(
- Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options.TEMPORAL_MUTABLE_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 7;
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty(SESSION_NAME_KEY, SESSION_NAME_TEST_VALUE);
- this.persistenceUnitSetProperty(SESSIONS_XML_KEY, SESSIONS_XML_TEST_VALUE);
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(INCLUDE_DESCRIPTOR_QUERIES_KEY, INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.2", "value.2");
- this.persistenceUnitSetProperty("misc.property.3", "value.3");
- this.persistenceUnitSetProperty(TARGET_DATABASE_KEY, TARGET_DATABASE_TEST_VALUE);
- this.persistenceUnitSetProperty(TARGET_SERVER_KEY, TARGET_SERVER_TEST_VALUE);
- this.persistenceUnitSetProperty(SESSION_EVENT_LISTENER_KEY, SESSION_EVENT_LISTENER_TEST_VALUE);
- this.persistenceUnitSetProperty("misc.property.4", "value.4");
- this.persistenceUnitSetProperty(TEMPORAL_MUTABLE_KEY, TEMPORAL_MUTABLE_TEST_VALUE.toString());
- return;
- }
-
- // ********** Listeners **********
-
- // ********** SessionName tests **********
- public void testSetSessionName() throws Exception {
- this.verifyModelInitialized(
- SESSION_NAME_KEY,
- SESSION_NAME_TEST_VALUE);
- this.verifySetProperty(
- SESSION_NAME_KEY,
- SESSION_NAME_TEST_VALUE,
- SESSION_NAME_TEST_VALUE_2);
- }
-
- public void testAddRemoveSessionName() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_NAME_KEY,
- SESSION_NAME_TEST_VALUE,
- SESSION_NAME_TEST_VALUE_2);
- }
-
- // ********** SessionsXml tests **********
- public void testSetSessionsXml() throws Exception {
- this.verifyModelInitialized(
- SESSIONS_XML_KEY,
- SESSIONS_XML_TEST_VALUE);
- this.verifySetProperty(
- SESSIONS_XML_KEY,
- SESSIONS_XML_TEST_VALUE,
- SESSIONS_XML_TEST_VALUE_2);
- }
-
- public void testAddRemoveSessionsXml() throws Exception {
- this.verifyAddRemoveProperty(
- SESSIONS_XML_KEY,
- SESSIONS_XML_TEST_VALUE,
- SESSIONS_XML_TEST_VALUE_2);
- }
-
- // ********** IncludeDescriptorQueries tests **********
- public void testSetIncludeDescriptorQueries() throws Exception {
- this.verifyModelInitialized(
- INCLUDE_DESCRIPTOR_QUERIES_KEY,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE);
- this.verifySetProperty(
- INCLUDE_DESCRIPTOR_QUERIES_KEY,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE_2);
- }
-
- public void testAddRemoveIncludeDescriptorQueries() throws Exception {
- this.verifyAddRemoveProperty(
- INCLUDE_DESCRIPTOR_QUERIES_KEY,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE_2);
- }
-
- // ********** TargetDatabase tests **********
- public void testSetTargetDatabase() throws Exception {
- this.verifyModelInitialized(
- TARGET_DATABASE_KEY,
- this.getPropertyStringValueOf(TARGET_DATABASE_TEST_VALUE)); // model is storing EclipseLinkStringValue
- this.verifySetProperty(
- TARGET_DATABASE_KEY,
- TARGET_DATABASE_TEST_VALUE,
- TARGET_DATABASE_TEST_VALUE_2);
- // verify set custom and literal value
- this.verifySetTargetDatabase(
- TARGET_DATABASE_KEY,
- TARGET_DATABASE_TEST_VALUE,
- TARGET_DATABASE_TEST_VALUE_2);
- }
-
- public void testAddRemoveTargetDatabase() throws Exception {
- this.verifyAddRemoveProperty(
- TARGET_DATABASE_KEY,
- TARGET_DATABASE_TEST_VALUE,
- TARGET_DATABASE_TEST_VALUE_2);
- }
-
- /**
- * Verifies setting custom targetDatabase and literals.
- */
- protected void verifySetTargetDatabase(String elKey, Object testValue1, Object testValue2) throws Exception {
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey);
- String propertyName = this.getModel().propertyIdOf(property);
- // test set custom targetDatabase.
- this.clearEvent();
- this.setProperty(propertyName, testValue2);
- this.verifyPutProperty(propertyName, testValue2);
-
- // test set (TargetDatabase) null
- this.clearEvent();
- this.options.setTargetDatabase((TargetDatabase) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
-
- // test set enum literal
- this.clearEvent();
- this.setProperty(propertyName, testValue1.toString());
- assertNotNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, this.getPropertyStringValueOf(testValue1));
-
- // test set (String) null
- this.clearEvent();
- this.options.setTargetDatabase((String) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
- }
-
- // ********** TargetServer tests **********
- public void testSetTargetServer() throws Exception {
- this.verifyModelInitialized(
- TARGET_SERVER_KEY,
- this.getPropertyStringValueOf(TARGET_SERVER_TEST_VALUE)); // model is storing EclipseLinkStringValue
- // verify set enum value
- this.verifySetProperty(
- TARGET_SERVER_KEY,
- TARGET_SERVER_TEST_VALUE,
- TARGET_SERVER_TEST_VALUE_2);
- // verify set custom and literal value
- this.verifySetTargetServer(
- TARGET_SERVER_KEY,
- TARGET_SERVER_TEST_VALUE,
- TARGET_SERVER_TEST_VALUE_2);
- }
-
- public void testAddRemoveTargetServer() throws Exception {
- this.verifyAddRemoveProperty(
- TARGET_SERVER_KEY,
- TARGET_SERVER_TEST_VALUE,
- TARGET_SERVER_TEST_VALUE_2);
- }
-
- /**
- * Verifies setting custom targetServer and literals.
- */
- protected void verifySetTargetServer(String elKey, Object testValue1, Object testValue2) throws Exception {
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(elKey);
- String propertyName = this.getModel().propertyIdOf(property);
- // test set custom targetServer.
- this.clearEvent();
- this.setProperty(propertyName, testValue2);
- this.verifyPutProperty(propertyName, testValue2);
-
- // test set (TargetServer) null
- this.clearEvent();
- this.options.setTargetServer((TargetServer) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
-
- // test set enum literal
- this.clearEvent();
- this.setProperty(propertyName, testValue1.toString());
- assertNotNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, this.getPropertyStringValueOf(testValue1));
-
- // test set (String) null
- this.clearEvent();
- this.options.setTargetServer((String) null);
- assertNull(this.getPersistenceUnit().getProperty(elKey));
- this.verifyPutProperty(propertyName, null);
- }
-
- // ********** EventListener tests **********
- public void testSetEventListener() throws Exception {
- this.verifyModelInitialized(
- SESSION_EVENT_LISTENER_KEY,
- SESSION_EVENT_LISTENER_TEST_VALUE);
- this.verifySetProperty(
- SESSION_EVENT_LISTENER_KEY,
- SESSION_EVENT_LISTENER_TEST_VALUE,
- SESSION_EVENT_LISTENER_TEST_VALUE_2);
- }
-
- public void testAddRemoveEventListener() throws Exception {
- this.verifyAddRemoveProperty(
- SESSION_EVENT_LISTENER_KEY,
- SESSION_EVENT_LISTENER_TEST_VALUE,
- SESSION_EVENT_LISTENER_TEST_VALUE_2);
- }
-
- // ********** TemporalMutable tests **********
- public void testSetTemporalMutable() throws Exception {
- this.verifyModelInitialized(
- TEMPORAL_MUTABLE_KEY,
- TEMPORAL_MUTABLE_TEST_VALUE);
- this.verifySetProperty(
- TEMPORAL_MUTABLE_KEY,
- TEMPORAL_MUTABLE_TEST_VALUE,
- TEMPORAL_MUTABLE_TEST_VALUE_2);
- }
-
- public void testAddRemoveTemporalMutable() throws Exception {
- this.verifyAddRemoveProperty(
- TEMPORAL_MUTABLE_KEY,
- TEMPORAL_MUTABLE_TEST_VALUE,
- TEMPORAL_MUTABLE_TEST_VALUE_2);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Options.SESSION_NAME_PROPERTY))
- this.options.setSessionName((String) newValue);
- else if (propertyName.equals(Options.SESSIONS_XML_PROPERTY))
- this.options.setSessionsXml((String) newValue);
- else if (propertyName.equals(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY))
- this.options.setIncludeDescriptorQueries((Boolean) newValue);
- else if (propertyName.equals(Options.TARGET_DATABASE_PROPERTY))
- this.setTargetDatabaseProperty(newValue);
- else if (propertyName.equals(Options.TARGET_SERVER_PROPERTY))
- this.setTargetServerProperty(newValue);
- else if (propertyName.equals(Options.SESSION_EVENT_LISTENER_PROPERTY))
- this.options.setEventListener((String) newValue);
- else if (propertyName.equals(Options.TEMPORAL_MUTABLE_PROPERTY))
- this.options.setTemporalMutable((Boolean) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- private void setTargetDatabaseProperty(Object newValue) {
- if (newValue.getClass().isEnum())
- this.options.setTargetDatabase((TargetDatabase) newValue);
- else
- this.options.setTargetDatabase((String) newValue);
- }
-
- private void setTargetServerProperty(Object newValue) {
- if (newValue.getClass().isEnum())
- this.options.setTargetServer((TargetServer) newValue);
- else
- this.options.setTargetServer((String) newValue);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Options.SESSION_NAME_PROPERTY))
- modelValue = this.options.getSessionName();
- else if (propertyName.equals(Options.SESSIONS_XML_PROPERTY))
- modelValue = this.options.getSessionsXml();
- else if (propertyName.equals(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY))
- modelValue = this.options.getIncludeDescriptorQueries();
- else if (propertyName.equals(Options.TARGET_DATABASE_PROPERTY))
- modelValue = this.options.getTargetDatabase();
- else if (propertyName.equals(Options.TARGET_SERVER_PROPERTY))
- modelValue = this.options.getTargetServer();
- else if (propertyName.equals(Options.SESSION_EVENT_LISTENER_PROPERTY))
- modelValue = this.options.getEventListener();
- else if (propertyName.equals(Options.TEMPORAL_MUTABLE_PROPERTY))
- modelValue = this.options.getTemporalMutable();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void verifyPutProperty(String propertyName, Object expectedValue) throws Exception {
- Object expectedValue_ = expectedValue;
- if (propertyName.equals(Options.TARGET_DATABASE_PROPERTY) ||
- propertyName.equals(Options.TARGET_SERVER_PROPERTY)) {
-
- expectedValue_ = this.convertToEclipseLinkStringValue(expectedValue);
- }
-
- super.verifyPutProperty(propertyName, expectedValue_);
- }
-
- private String convertToEclipseLinkStringValue(Object expectedValue) {
- return (String) ((expectedValue != null && expectedValue.getClass().isEnum()) ?
- this.getPropertyStringValueOf(expectedValue) : // model is storing EclipseLinkStringValue
- expectedValue); // already a EclipseLinkStringValue
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.options;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsValueModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsValueModelTests.java
deleted file mode 100644
index 8ba58a029b..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/options/OptionsValueModelTests.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.persistence.options;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.options.Options;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * OptionsValueModelTests
- */
-public class OptionsValueModelTests extends EclipseLinkPersistenceUnitTestCase
-{
- private Options options;
-
- private WritablePropertyValueModel<Boolean> includeDescriptorQueriesHolder;
- private PropertyChangeListener includeDescriptorQueriesListener;
- private PropertyChangeEvent includeDescriptorQueriesEvent;
-
- public static final Boolean INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE = Boolean.FALSE;
-
- public OptionsValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.options = this.subject.getOptions(); // Subject
- PropertyValueModel<Options> optionsHolder = new SimplePropertyValueModel<Options>(this.options);
-
- this.includeDescriptorQueriesHolder = this.buildIncludeDescriptorQueriesAA(optionsHolder);
- this.includeDescriptorQueriesListener = this.buildIncludeDescriptorQueriesChangeListener();
- this.includeDescriptorQueriesHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.includeDescriptorQueriesListener);
- this.includeDescriptorQueriesEvent = null;
- }
-
- public void testHasListeners() {
- AbstractModel subjectOptions = (AbstractModel) this.options; // Subject
-
- PropertyAspectAdapter<Options, Boolean> includeDescriptorQueriesAA =
- (PropertyAspectAdapter<Options, Boolean>) this.includeDescriptorQueriesHolder;
- assertTrue(includeDescriptorQueriesAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(subjectOptions.hasAnyPropertyChangeListeners(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY));
-
- includeDescriptorQueriesAA.removePropertyChangeListener(PropertyValueModel.VALUE, this.includeDescriptorQueriesListener);
- assertFalse(subjectOptions.hasAnyPropertyChangeListeners(Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY));
- assertFalse(includeDescriptorQueriesAA.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitSetProperty(
- Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES,
- INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.options;
- }
-
- // ****** IncludeDescriptorQueries *******
- private WritablePropertyValueModel<Boolean> buildIncludeDescriptorQueriesAA(PropertyValueModel<Options> subjectHolder) {
- return new PropertyAspectAdapter<Options, Boolean>(subjectHolder, Options.SESSION_INCLUDE_DESCRIPTOR_QUERIES_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getIncludeDescriptorQueries();
- }
-
- @Override
- protected void setValue_(Boolean enumValue) {
- this.subject.setIncludeDescriptorQueries(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildIncludeDescriptorQueriesChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- OptionsValueModelTests.this.includeDescriptorQueriesEvent = e;
- }
- };
- }
-
- // ****** Tests *******
- public void testValue() {
- // ****** IncludeDescriptorQueries *******
- this.verifyIncludeDescriptorQueriesAAValue(INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE);
- assertEquals(Options.DEFAULT_SESSION_INCLUDE_DESCRIPTOR_QUERIES, this.options.getDefaultIncludeDescriptorQueries());
- }
-
- public void testSetValue() throws Exception {
- // ****** IncludeDescriptorQueries *******
- this.includeDescriptorQueriesEvent = null;
- this.verifyHasListeners(this.includeDescriptorQueriesHolder, PropertyValueModel.VALUE);
- Boolean newIncludeDescriptorQueries = !INCLUDE_DESCRIPTOR_QUERIES_TEST_VALUE;
- // Modify the property holder
- this.includeDescriptorQueriesHolder.setValue(newIncludeDescriptorQueries);
- this.verifyIncludeDescriptorQueriesAAValue(newIncludeDescriptorQueries);
- assertNotNull(this.includeDescriptorQueriesEvent);
- }
-
- public void testSetNullValue() {
- String notDeleted = "Property not deleted";
- // ****** IncludeDescriptorQueries *******
- this.includeDescriptorQueriesEvent = null;
- // Setting the property holder
- this.includeDescriptorQueriesHolder.setValue(null);
- // testing Holder
- this.verifyIncludeDescriptorQueriesAAValue(null);
- assertNotNull(this.includeDescriptorQueriesEvent);
- // testing PU properties
- this.verifyPuHasNotProperty(Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES, notDeleted);
- }
-
- // ****** convenience methods *******
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyIncludeDescriptorQueriesAAValue(Boolean testValue) {
- this.verifyAAValue(
- testValue,
- this.options.getIncludeDescriptorQueries(),
- this.includeDescriptorQueriesHolder,
- Options.ECLIPSELINK_SESSION_INCLUDE_DESCRIPTOR_QUERIES);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/JptEclipseLinkPersistenceSchemaGenerationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/JptEclipseLinkPersistenceSchemaGenerationTests.java
deleted file mode 100644
index 2f7e74595a..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/JptEclipseLinkPersistenceSchemaGenerationTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.eclipselink.core.tests.internal.context.persistence.schema.generation;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLinkPersistenceSchemaGenerationTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkPersistenceSchemaGenerationTests.class.getPackage().getName());
-
- suite.addTestSuite(SchemaGenerationValueModelTests.class);
- suite.addTestSuite(SchemaGenerationBasicAdapterTests.class);
- suite.addTestSuite(SchemaGenerationAdapterTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkPersistenceSchemaGenerationTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationAdapterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationAdapterTests.java
deleted file mode 100644
index 18e265ce7c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationAdapterTests.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.eclipselink.core.tests.internal.context.persistence.schema.generation;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * Tests the update of OutputMode model object by the SchemaGeneration adapter
- * when the PersistenceUnit changes.
- */
-@SuppressWarnings("nls")
-public class SchemaGenerationAdapterTests extends EclipseLinkPersistenceUnitTestCase
-{
- private SchemaGeneration schemaGeneration;
-
- public static final String DDL_GENERATION_TYPE_KEY = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE;
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE = DdlGenerationType.drop_and_create_tables;
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE_2 = DdlGenerationType.none;
-
- public static final String OUTPUT_MODE_KEY = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE = OutputMode.sql_script;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE_2 = OutputMode.database;
-
- private static final String CREATE_FILE_NAME_KEY = SchemaGeneration.ECLIPSELINK_CREATE_FILE_NAME;
- private static final String CREATE_FILE_NAME_TEST_VALUE = "create-file-name.test";
- private static final String CREATE_FILE_NAME_TEST_VALUE_2 = "create-file-name-2.test";
-
- private static final String DROP_FILE_NAME_KEY = SchemaGeneration.ECLIPSELINK_DROP_FILE_NAME;
- private static final String DROP_FILE_NAME_TEST_VALUE = "drop-file-name.test";
- private static final String DROP_FILE_NAME_TEST_VALUE_2 = "drop-file-name-2.test";
-
- private static final String APPLICATION_LOCATION_KEY = SchemaGeneration.ECLIPSELINK_APPLICATION_LOCATION;
- private static final String APPLICATION_LOCATION_TEST_VALUE = "C:/temp";
- private static final String APPLICATION_LOCATION_TEST_VALUE_2 = "C:/tmp";
-
- public SchemaGenerationAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.schemaGeneration = this.subject.getSchemaGeneration();
-
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.OUTPUT_MODE_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.CREATE_FILE_NAME_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.DROP_FILE_NAME_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.APPLICATION_LOCATION_PROPERTY, propertyChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- @Override
- protected void populatePu() {
- this.propertiesTotal = 9;
- this.modelPropertiesSizeOriginal = 5;
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty("property.0", "value.0");
- this.persistenceUnitSetProperty(OUTPUT_MODE_KEY, this.getPropertyStringValueOf(OUTPUT_MODE_TEST_VALUE));
- this.persistenceUnitSetProperty("property.2", "value.2");
- this.persistenceUnitSetProperty("property.3", "value.3");
- this.persistenceUnitSetProperty("property.4", "value.4");
- this.persistenceUnitSetProperty(DDL_GENERATION_TYPE_KEY, this.getPropertyStringValueOf(DDL_GENERATION_TYPE_TEST_VALUE));
- this.persistenceUnitSetProperty(CREATE_FILE_NAME_KEY, CREATE_FILE_NAME_TEST_VALUE);
- this.persistenceUnitSetProperty(DROP_FILE_NAME_KEY, DROP_FILE_NAME_TEST_VALUE);
- this.persistenceUnitSetProperty(APPLICATION_LOCATION_KEY, APPLICATION_LOCATION_TEST_VALUE);
- return;
- }
-
- // ********** CreateFileName **********
- /**
- * Tests the update of CreateFileName property by the SchemaGeneration
- * adapter when the PU or the model changes.
- */
- public void testSetCreateFileName() throws Exception {
- this.verifyModelInitialized(
- CREATE_FILE_NAME_KEY,
- CREATE_FILE_NAME_TEST_VALUE);
- this.verifySetProperty(
- CREATE_FILE_NAME_KEY,
- CREATE_FILE_NAME_TEST_VALUE,
- CREATE_FILE_NAME_TEST_VALUE_2);
- }
-
- public void testAddRemoveCreateFileName() throws Exception {
- this.verifyAddRemoveProperty(
- CREATE_FILE_NAME_KEY,
- CREATE_FILE_NAME_TEST_VALUE,
- CREATE_FILE_NAME_TEST_VALUE_2);
- }
-
- // ********** DropFileName **********
- /**
- * Tests the update of DropFileName property by the SchemaGeneration adapter
- * when the PU or the model changes.
- */
- public void testSetDropFileName() throws Exception {
- this.verifyModelInitialized(
- DROP_FILE_NAME_KEY,
- DROP_FILE_NAME_TEST_VALUE);
- this.verifySetProperty(
- DROP_FILE_NAME_KEY,
- DROP_FILE_NAME_TEST_VALUE,
- DROP_FILE_NAME_TEST_VALUE_2);
- }
-
- public void testAddRemoveDropFileName() throws Exception {
- this.verifyAddRemoveProperty(
- DROP_FILE_NAME_KEY,
- DROP_FILE_NAME_TEST_VALUE,
- DROP_FILE_NAME_TEST_VALUE_2);
- }
-
- // ********** ApplicationLocation **********
- /**
- * Tests the update of ApplicationLocation property by the SchemaGeneration
- * adapter when the PU or the model changes.
- */
- public void testSetApplicationLocation() throws Exception {
- this.verifyModelInitialized(
- APPLICATION_LOCATION_KEY,
- APPLICATION_LOCATION_TEST_VALUE);
- this.verifySetProperty(
- APPLICATION_LOCATION_KEY,
- APPLICATION_LOCATION_TEST_VALUE,
- APPLICATION_LOCATION_TEST_VALUE_2);
- }
-
- public void testAddRemoveApplicationLocation() throws Exception {
- this.verifyAddRemoveProperty(
- APPLICATION_LOCATION_KEY,
- APPLICATION_LOCATION_TEST_VALUE,
- APPLICATION_LOCATION_TEST_VALUE_2);
- }
-
- public void testSetEmptyApplicationLocation() throws Exception {
- String puKey = APPLICATION_LOCATION_KEY;
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(puKey);
- String propertyName = this.getModel().propertyIdOf(property);
-
- // Set ApplicationLocation to "" & verify that the property is deleted
- this.verifyPuHasProperty(puKey, "persistenceUnit.properties doesn't contains: ");
- this.setProperty(propertyName, "");
-
- this.verifyPuHasNotProperty(puKey, "Property was not deleted");
- this.verifyPutProperty(propertyName, null);
- assertNull(this.getPersistenceUnit().getProperty(puKey));
- }
-
- // ********** OutputMode **********
- /**
- * Tests the update of OutputMode property by the SchemaGeneration adapter
- * when the PU or the model changes.
- */
- public void testSetOutputMode() throws Exception {
- this.verifyModelInitialized(
- OUTPUT_MODE_KEY,
- OUTPUT_MODE_TEST_VALUE);
- this.verifySetProperty(
- OUTPUT_MODE_KEY,
- OUTPUT_MODE_TEST_VALUE,
- OUTPUT_MODE_TEST_VALUE_2);
- }
-
- public void testAddRemoveOutputMode() throws Exception {
- this.verifyAddRemoveProperty(
- OUTPUT_MODE_KEY,
- OUTPUT_MODE_TEST_VALUE,
- OUTPUT_MODE_TEST_VALUE_2);
- }
-
- // ********** DdlGenerationType **********
- /**
- * Tests the update of DdlGenerationType property by the SchemaGeneration
- * adapter when the PU or the model changes.
- */
- public void testSetDdlGenerationType() throws Exception {
- this.verifyModelInitialized(
- DDL_GENERATION_TYPE_KEY,
- DDL_GENERATION_TYPE_TEST_VALUE);
- this.verifySetProperty(
- DDL_GENERATION_TYPE_KEY,
- DDL_GENERATION_TYPE_TEST_VALUE,
- DDL_GENERATION_TYPE_TEST_VALUE_2);
- }
-
- public void testAddRemoveDdlGenerationType() throws Exception {
- this.verifyAddRemoveProperty(
- DDL_GENERATION_TYPE_KEY,
- DDL_GENERATION_TYPE_TEST_VALUE,
- DDL_GENERATION_TYPE_TEST_VALUE_2);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws NoSuchFieldException {
- if (propertyName.equals(SchemaGeneration.OUTPUT_MODE_PROPERTY))
- this.schemaGeneration.setOutputMode((OutputMode) newValue);
- // else if( propertyName.equals( Caching.CACHE_SIZE_PROPERTY))
- // TODO
- else if (propertyName.equals(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY))
- this.schemaGeneration.setDdlGenerationType((DdlGenerationType) newValue);
- else if (propertyName.equals(SchemaGeneration.APPLICATION_LOCATION_PROPERTY))
- this.schemaGeneration.setApplicationLocation((String) newValue);
- else if (propertyName.equals(SchemaGeneration.CREATE_FILE_NAME_PROPERTY))
- this.schemaGeneration.setCreateFileName((String) newValue);
- else if (propertyName.equals(SchemaGeneration.DROP_FILE_NAME_PROPERTY))
- this.schemaGeneration.setDropFileName((String) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(SchemaGeneration.OUTPUT_MODE_PROPERTY))
- modelValue = this.schemaGeneration.getOutputMode();
- else if (propertyName.equals(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY))
- modelValue = this.schemaGeneration.getDdlGenerationType();
- else if (propertyName.equals(SchemaGeneration.APPLICATION_LOCATION_PROPERTY))
- modelValue = this.schemaGeneration.getApplicationLocation();
- else if (propertyName.equals(SchemaGeneration.CREATE_FILE_NAME_PROPERTY))
- modelValue = this.schemaGeneration.getCreateFileName();
- else if (propertyName.equals(SchemaGeneration.DROP_FILE_NAME_PROPERTY))
- modelValue = this.schemaGeneration.getDropFileName();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.schemaGeneration;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationBasicAdapterTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationBasicAdapterTests.java
deleted file mode 100644
index fb0565e815..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationBasicAdapterTests.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.eclipselink.core.tests.internal.context.persistence.schema.generation;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * Tests the update of OutputMode model object by the SchemaGeneration adapter
- * when the PersistenceUnit changes.
- */
-@SuppressWarnings("nls")
-public class SchemaGenerationBasicAdapterTests extends EclipseLinkPersistenceUnitTestCase
-{
- private SchemaGeneration schemaGeneration;
-
- public static final String outputModeKey = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE;
- public static final String ddlGenTypeKey = SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE;
-
- public static final OutputMode OUTPUT_MODE_TEST_VALUE = OutputMode.sql_script;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE_2 = OutputMode.database;
-
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE = DdlGenerationType.drop_and_create_tables;
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE_2 = DdlGenerationType.none;
-
- public SchemaGenerationBasicAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- this.schemaGeneration = this.subject.getSchemaGeneration();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.OUTPUT_MODE_PROPERTY, propertyChangeListener);
- this.schemaGeneration.addPropertyChangeListener(SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY, propertyChangeListener);
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- @Override
- protected void populatePu() {
- this.propertiesTotal = 6;
- this.modelPropertiesSizeOriginal = 2;
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- this.persistenceUnitSetProperty("property.0", "value.0");
- this.persistenceUnitSetProperty(outputModeKey, this.getPropertyStringValueOf(OUTPUT_MODE_TEST_VALUE));
- this.persistenceUnitSetProperty("property.2", "value.2");
- this.persistenceUnitSetProperty("property.3", "value.3");
- this.persistenceUnitSetProperty("property.4", "value.4");
- this.persistenceUnitSetProperty(ddlGenTypeKey, this.getPropertyStringValueOf(DDL_GENERATION_TYPE_TEST_VALUE));
- return;
- }
-
- /** ****** test methods ******* */
-
- /**
- * Tests the update of OutputMode property by the SchemaGeneration adapter
- * when the PU changes.
- */
- public void testOutputModeUpdate() throws Exception {
- ListValueModel<PersistenceUnit.Property> propertiesAdapter = this.buildPropertiesAdapter(this.subjectHolder);
- ListValueModel<PersistenceUnit.Property> propertyListAdapter = new ItemPropertyListValueModelAdapter<PersistenceUnit.Property>(propertiesAdapter, PersistenceUnit.Property.VALUE_PROPERTY);
-
- this.verifyHasListeners(this.schemaGeneration, SchemaGeneration.OUTPUT_MODE_PROPERTY);
-
- // Basic
- assertTrue(schemaGeneration.itemIsProperty(this.getPersistenceUnit().getProperty(outputModeKey)));
- assertEquals(OUTPUT_MODE_TEST_VALUE, this.schemaGeneration.getOutputMode());
-
- // Replace
- this.persistenceUnitSetProperty(outputModeKey, OUTPUT_MODE_TEST_VALUE_2);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE_2, this.schemaGeneration.getOutputMode());
-
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.getPersistenceUnit().removeProperty(outputModeKey);
- assertNull(this.getPersistenceUnit().getProperty(outputModeKey));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
- assertNotNull(this.propertyChangedEvent);
- assertNull(this.propertyChangedEvent.getNewValue());
-
- // Add original OutputMode
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitSetProperty(outputModeKey, OUTPUT_MODE_TEST_VALUE);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE, this.schemaGeneration.getOutputMode());
-
- // Replace again
- this.persistenceUnitSetProperty(outputModeKey, OUTPUT_MODE_TEST_VALUE_2);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE_2, this.schemaGeneration.getOutputMode());
-
- // Replace by setting model object
- this.clearEvent();
- this.schemaGeneration.setOutputMode(OUTPUT_MODE_TEST_VALUE);
- this.verifyPutEvent(SchemaGeneration.OUTPUT_MODE_PROPERTY, OUTPUT_MODE_TEST_VALUE, this.schemaGeneration.getOutputMode());
- }
-
- // ****** convenience methods *******
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.schemaGeneration;
- }
-
- private ListValueModel<PersistenceUnit.Property> buildPropertiesAdapter(PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder) {
- return new ListAspectAdapter<EclipseLinkPersistenceUnit, PersistenceUnit.Property>(subjectHolder, PersistenceUnit.PROPERTIES_LIST) {
- @Override
- protected ListIterator<PersistenceUnit.Property> listIterator_() {
- return this.subject.properties();
- }
-
- @Override
- protected int size_() {
- return this.subject.propertiesSize();
- }
- };
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationValueModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationValueModelTests.java
deleted file mode 100644
index 2cda6aec46..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/schema/generation/SchemaGenerationValueModelTests.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.context.persistence.schema.generation;
-
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.DdlGenerationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.OutputMode;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.schema.generation.SchemaGeneration;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.persistence.EclipseLinkPersistenceUnitTestCase;
-
-/**
- * SchemaGenerationValueModelTests
- *
- * Tests the PropertyValueModel of SchemaGeneration model and the update of the
- * PersistenceUnit.
- */
-public class SchemaGenerationValueModelTests extends EclipseLinkPersistenceUnitTestCase
-{
- private SchemaGeneration schemaGen;
- private PropertyValueModel<SchemaGeneration> schemaGenHolder;
-
- private WritablePropertyValueModel<DdlGenerationType> ddlGenerationTypeHolder;
- private PropertyChangeEvent ddlGenerationTypeEvent;
-
- private WritablePropertyValueModel<OutputMode> outputModeHolder;
- private PropertyChangeEvent outputModeEvent;
-
- public static final DdlGenerationType DDL_GENERATION_TYPE_TEST_VALUE = DdlGenerationType.drop_and_create_tables;
- public static final OutputMode OUTPUT_MODE_TEST_VALUE = OutputMode.sql_script;
-
- public SchemaGenerationValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.schemaGen = this.subject.getSchemaGeneration(); // Subject
- this.schemaGenHolder = new SimplePropertyValueModel<SchemaGeneration>(this.schemaGen);
-
- this.ddlGenerationTypeHolder = this.buildDdlGenerationTypeAA(this.schemaGenHolder);
- PropertyChangeListener ddlGenerationTypeListener = this.buildDdlGenerationTypeChangeListener();
- this.ddlGenerationTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, ddlGenerationTypeListener);
- this.ddlGenerationTypeEvent = null;
-
- this.outputModeHolder = this.buildOutputModeAA(this.schemaGenHolder);
- PropertyChangeListener outputModeListener = this.buildOutputModeChangeListener();
- this.outputModeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, outputModeListener);
- this.outputModeEvent = null;
- }
-
- /**
- * Initializes directly the PU properties before testing. Cannot use
- * Property Holder to initialize because it is not created yet
- */
- @Override
- protected void populatePu() {
- this.persistenceUnitSetProperty(
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
- DDL_GENERATION_TYPE_TEST_VALUE);
- this.persistenceUnitSetProperty(
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE,
- OUTPUT_MODE_TEST_VALUE);
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.schemaGen;
- }
-
- /** ****** DdlGenerationType ******* */
- private WritablePropertyValueModel<DdlGenerationType> buildDdlGenerationTypeAA(PropertyValueModel<SchemaGeneration> subjectHolder) {
- return new PropertyAspectAdapter<SchemaGeneration, DdlGenerationType>(subjectHolder, SchemaGeneration.DDL_GENERATION_TYPE_PROPERTY) {
- @Override
- protected DdlGenerationType buildValue_() {
- return this.subject.getDdlGenerationType();
- }
-
- @Override
- protected void setValue_(DdlGenerationType enumValue) {
- this.subject.setDdlGenerationType(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildDdlGenerationTypeChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- SchemaGenerationValueModelTests.this.ddlGenerationTypeEvent = e;
- }
- };
- }
-
- /** ****** OutputMode ******* */
- private WritablePropertyValueModel<OutputMode> buildOutputModeAA(PropertyValueModel<SchemaGeneration> subjectHolder) {
- return new PropertyAspectAdapter<SchemaGeneration, OutputMode>(subjectHolder, SchemaGeneration.OUTPUT_MODE_PROPERTY) {
- @Override
- protected OutputMode buildValue_() {
- return this.subject.getOutputMode();
- }
-
- @Override
- protected void setValue_(OutputMode enumValue) {
- this.subject.setOutputMode(enumValue);
- }
- };
- }
-
- private PropertyChangeListener buildOutputModeChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- SchemaGenerationValueModelTests.this.outputModeEvent = e;
- }
- };
- }
-
- public void testValue() {
- /** ****** DdlGenerationType ******* */
- this.verifyDdlGenerationTypeAAValue(DDL_GENERATION_TYPE_TEST_VALUE);
- assertEquals(
- SchemaGeneration.DEFAULT_SCHEMA_GENERATION_DDL_GENERATION_TYPE,
- this.schemaGen.getDefaultDdlGenerationType());
- /** ****** OutputMode ******* */
- this.verifyOutputModeAAValue(OUTPUT_MODE_TEST_VALUE);
- assertEquals(
- SchemaGeneration.DEFAULT_SCHEMA_GENERATION_OUTPUT_MODE,
- this.schemaGen.getDefaultOutputMode());
- }
-
- public void testSetValue() throws Exception {
- /** ****** DdlGenerationType ******* */
- this.ddlGenerationTypeEvent = null;
- this.verifyHasListeners(this.ddlGenerationTypeHolder, PropertyValueModel.VALUE);
- DdlGenerationType newDdlGenerationType = DdlGenerationType.create_tables;
- // Modify the persistenceUnit directly
- this.subject.setProperty(
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE,
- this.getPropertyStringValueOf(newDdlGenerationType),
- false);
- this.verifyDdlGenerationTypeAAValue(newDdlGenerationType);
- assertNotNull(this.ddlGenerationTypeEvent);
-
- /** ****** OutputMode ******* */
- this.outputModeEvent = null;
- this.verifyHasListeners(this.outputModeHolder, PropertyValueModel.VALUE);
- OutputMode newOutputMode = OutputMode.database;
- // Modify the property holder
- this.outputModeHolder.setValue(newOutputMode);
- this.verifyOutputModeAAValue(newOutputMode);
- assertNotNull(this.outputModeEvent);
- }
-
- public void testSetNullValue() {
- /** ****** DdlGenerationType ******* */
- this.ddlGenerationTypeEvent = null;
- // Setting the persistenceUnit directly
- this.subject.setProperty(SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE, null, false);
- this.ddlGenerationTypeHolder.setValue(null);
- // testing Holder
- this.verifyDdlGenerationTypeAAValue(null);
- assertNotNull(this.ddlGenerationTypeEvent);
- // testing PU properties
- PersistenceUnit.Property property = this.getPersistenceUnit().getProperty(SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE);
- assertNull(property);
-
- /** ****** OutputMode ******* */
- this.outputModeEvent = null;
- // Setting the property holder
- this.outputModeHolder.setValue(null);
- // testing Holder
- this.verifyOutputModeAAValue(null);
- assertNotNull(this.outputModeEvent);
- // testing PU properties
- property = this.getPersistenceUnit().getProperty(SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE);
- assertNull(property);
- }
-
- /** ****** convenience methods ******* */
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyDdlGenerationTypeAAValue(DdlGenerationType testValue) {
- this.verifyAAValue(
- testValue,
- this.schemaGen.getDdlGenerationType(),
- this.ddlGenerationTypeHolder,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_TYPE);
- }
-
- /**
- * Performs three value tests:<br>
- * 1. subject value<br>
- * 2. aspect adapter value<br>
- * 3. persistenceUnit property value<br>
- */
- protected void verifyOutputModeAAValue(OutputMode testValue) {
- this.verifyAAValue(
- testValue,
- this.schemaGen.getOutputMode(),
- this.outputModeHolder,
- SchemaGeneration.ECLIPSELINK_DDL_GENERATION_OUTPUT_MODE);
- }
-
- // ********** get/set property **********
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/JptJpaEclipselinkCoreResourceModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/JptJpaEclipselinkCoreResourceModelTests.java
deleted file mode 100644
index dea557ce8f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/JptJpaEclipselinkCoreResourceModelTests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.resource;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.JptJpaEclipseLinkCoreTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.resource.java.JptEclipseLinkCoreJavaResourceModelTests;
-
-/**
- * Required Java system property:
- * -Dorg.eclipse.jpt.jpa.jar=<jpa.jar path>
- * -Dorg.eclipse.jpt.eclipselink.jar=<eclipselink.jar path>
- */
-public class JptJpaEclipselinkCoreResourceModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptJpaEclipselinkCoreResourceModelTests.class.getName());
- if(JptJpaEclipseLinkCoreTests.requiredJarsExists()) {
- suite.addTest(JptEclipseLinkCoreJavaResourceModelTests.suite());
- }
- else {
- suite.addTest(TestSuite.warning(JptJpaEclipseLinkCoreTests.buildMissingJarErrorMessage()));
- }
- return suite;
- }
-
- private JptJpaEclipselinkCoreResourceModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CacheTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CacheTests.java
deleted file mode 100644
index ebea9fe78f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CacheTests.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheCoordinationType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.CacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCacheAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTimeOfDayAnnotation;
-
-@SuppressWarnings("nls")
-public class CacheTests extends EclipseLinkJavaResourceModelTestCase {
-
- public CacheTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestCache() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.CACHE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithCacheType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.CACHE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(type = CacheType.SOFT)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithSize() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(size = 50)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithExpiry() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiry = 50)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithExpiryTimeOfDay() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.TIME_OF_DAY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiryTimeOfDay = @TimeOfDay)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithShared() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(shared=true)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithAlwaysRefresh() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(alwaysRefresh=true)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithRefreshOnlyIfNewer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(refreshOnlyIfNewer=true)");
- }
- });
- }
-
- private ICompilationUnit createTestCacheWithDisableHits() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(disableHits=true)");
- }
- });
- }
-
- private ICompilationUnit createTestExistenceCheckingWithCoordinationType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.CACHE_COORDINATION_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(coordinationType = CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS)");
- }
- });
- }
-
- public void testCache() throws Exception {
- ICompilationUnit cu = this.createTestCache();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertNotNull(cache);
- }
-
- public void testGetType() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithCacheType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(CacheType.SOFT, cache.getType());
- }
-
- public void testSetType() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithCacheType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(CacheType.SOFT, cache.getType());
-
- cache.setType(CacheType.WEAK);
- assertEquals(CacheType.WEAK, cache.getType());
-
- assertSourceContains("@Cache(type = WEAK)", cu);
-
- cache.setType(null);
- assertNull(cache.getType());
-
- assertSourceDoesNotContain("(type = WEAK)", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
- public void testGetSize() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithSize();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(50), cache.getSize());
- }
-
- public void testSetSize() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithSize();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(50), cache.getSize());
-
- cache.setSize(Integer.valueOf(80));
- assertEquals(Integer.valueOf(80), cache.getSize());
-
- assertSourceContains("@Cache(size = 80)", cu);
-
- cache.setSize(null);
- assertNull(cache.getSize());
-
- assertSourceDoesNotContain("(size = 80)", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
- public void testGetShared() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithShared();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getShared());
- }
-
- public void testSetShared() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithShared();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getShared());
-
- cache.setShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cache.getShared());
-
- assertSourceContains("@Cache(shared=false)", cu);
- }
-
- public void testSetSharedNull() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithShared();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getShared());
-
- cache.setShared(null);
-
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
- public void testGetExpiry() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithExpiry();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(50), cache.getExpiry());
- }
-
- public void testSetExpiry() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithExpiry();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Integer.valueOf(50), cache.getExpiry());
-
- cache.setExpiry(Integer.valueOf(80));
- assertEquals(Integer.valueOf(80), cache.getExpiry());
-
- assertSourceContains("@Cache(expiry = 80)", cu);
-
- cache.setExpiry(null);
- assertNull(cache.getExpiry());
-
- assertSourceDoesNotContain("(expiry = 80)", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
- public void testGetExpiryTimeOfDay() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithExpiryTimeOfDay();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertNotNull(timeOfDay);
- }
-
- public void testAddExpiryTimeOfDay() throws Exception {
- ICompilationUnit cu = this.createTestCache();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- cache.addExpiryTimeOfDay();
-
- assertNotNull(cache.getExpiryTimeOfDay());
-
- assertSourceContains("@Cache(expiryTimeOfDay = @TimeOfDay)", cu);
- }
-
- public void testRemoveExpiryTimeOfDay() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithExpiryTimeOfDay();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- assertNotNull(cache.getExpiryTimeOfDay());
-
- cache.removeExpiryTimeOfDay();
- assertNull(cache.getExpiryTimeOfDay());
- assertSourceDoesNotContain("@Cache(expiryTimeOfDay = @TimeOfDay)", cu);
- }
-
- public void testGetAlwaysRefresh() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithAlwaysRefresh();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getAlwaysRefresh());
- }
-
- public void testSetAlwaysRefresh() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithAlwaysRefresh();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getAlwaysRefresh());
-
- cache.setAlwaysRefresh(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cache.getAlwaysRefresh());
-
- assertSourceContains("@Cache(alwaysRefresh=false)", cu);
- }
-
- public void testSetAlwaysRefreshNull() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithAlwaysRefresh();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getAlwaysRefresh());
-
- cache.setAlwaysRefresh(null);
- cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertNull(cache.getAlwaysRefresh());
-
- assertSourceContains("@Cache", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
- public void testGetRefreshOnlyIfNewer() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithRefreshOnlyIfNewer();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getRefreshOnlyIfNewer());
- }
-
- public void testSetRefreshOnlyIfNewer() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithRefreshOnlyIfNewer();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getRefreshOnlyIfNewer());
-
- cache.setRefreshOnlyIfNewer(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cache.getRefreshOnlyIfNewer());
-
- assertSourceContains("@Cache(refreshOnlyIfNewer=false)", cu);
- }
-
- public void testSetRefreshOnlyIfNewerNull() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithRefreshOnlyIfNewer();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getRefreshOnlyIfNewer());
-
- cache.setRefreshOnlyIfNewer(null);
- cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertNull(cache.getRefreshOnlyIfNewer());
- assertSourceContains("@Cache", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
- public void testGetDisableHits() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithDisableHits();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getDisableHits());
- }
-
- public void testSetDisableHits() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithDisableHits();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getDisableHits());
-
- cache.setDisableHits(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cache.getDisableHits());
-
- assertSourceContains("@Cache(disableHits=false)", cu);
- }
-
- public void testSetDisableHitsNull() throws Exception {
- ICompilationUnit cu = this.createTestCacheWithDisableHits();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(Boolean.TRUE, cache.getDisableHits());
-
- cache.setDisableHits(null);
- cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertNull(cache.getDisableHits());
- assertSourceContains("@Cache", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-
-
- public void testGetCoordinationType() throws Exception {
- ICompilationUnit cu = this.createTestExistenceCheckingWithCoordinationType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, cache.getCoordinationType());
- }
-
- public void testSetCoordinationType() throws Exception {
- ICompilationUnit cu = this.createTestExistenceCheckingWithCoordinationType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- assertEquals(CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, cache.getCoordinationType());
-
- cache.setCoordinationType(CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
- assertEquals(CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, cache.getCoordinationType());
-
- assertSourceContains("@Cache(coordinationType = SEND_NEW_OBJECTS_WITH_CHANGES)", cu);
-
- cache.setCoordinationType(null);
- assertNull(cache.getCoordinationType());
-
- assertSourceDoesNotContain("(coordinationType = SEND_NEW_OBJECTS_WITH_CHANGES)", cu);
- assertSourceDoesNotContain("@Cache(", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ChangeTrackingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ChangeTrackingTests.java
deleted file mode 100644
index 6a829418bd..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ChangeTrackingTests.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
-
-@SuppressWarnings("nls")
-public class ChangeTrackingTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ChangeTrackingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CHANGE_TRACKING, EclipseLink.CHANGE_TRACKING_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@ChangeTracking");
- }
- });
- }
-
- private ICompilationUnit createTestChangeTrackingWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CHANGE_TRACKING, EclipseLink.CHANGE_TRACKING_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@ChangeTracking(ChangeTrackingType.DEFERRED)");
- }
- });
- }
-
- public void testChangeTracking() throws Exception {
- ICompilationUnit cu = this.createTestChangeTracking();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkChangeTrackingAnnotation existenceChecking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLink.CHANGE_TRACKING);
- assertNotNull(existenceChecking);
- }
-
- public void testGetValue() throws Exception {
- ICompilationUnit cu = this.createTestChangeTrackingWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkChangeTrackingAnnotation existenceChecking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLink.CHANGE_TRACKING);
- assertEquals(ChangeTrackingType.DEFERRED, existenceChecking.getValue());
- }
-
- public void testSetValue() throws Exception {
- ICompilationUnit cu = this.createTestChangeTrackingWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkChangeTrackingAnnotation existenceChecking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLink.CHANGE_TRACKING);
- assertEquals(ChangeTrackingType.DEFERRED, existenceChecking.getValue());
-
- existenceChecking.setValue(ChangeTrackingType.ATTRIBUTE);
- assertEquals(ChangeTrackingType.ATTRIBUTE, existenceChecking.getValue());
-
- assertSourceContains("@ChangeTracking(ATTRIBUTE)", cu);
-
- existenceChecking.setValue(null);
- assertNull(existenceChecking.getValue());
-
- assertSourceDoesNotContain("(ATTRIBUTE)", cu);
- assertSourceContains("@ChangeTracking", cu);
- assertSourceDoesNotContain("@ChangeTracking(", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConversionValueAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConversionValueAnnotationTests.java
deleted file mode 100644
index fd34a0d7b6..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConversionValueAnnotationTests.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
-
-@SuppressWarnings("nls")
-public class ConversionValueAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ConversionValueAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestObjectTypeConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter");
- }
- });
- }
-
- private ICompilationUnit createTestObjectTypeConverterWithConversionValues() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER, EclipseLink.CONVERSION_VALUE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter(conversionValues = {@ConversionValue(dataValue = \"F\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})");
- }
- });
- }
-
-
- public void testGetDataValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("F", converter.conversionValueAt(0).getDataValue());
- }
-
- public void testSetDataValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("F", converter.conversionValueAt(0).getDataValue());
-
- converter.conversionValueAt(0).setDataValue("FOO");
- assertEquals("FOO", converter.conversionValueAt(0).getDataValue());
-
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(dataValue = \"FOO\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})", cu);
- }
-
- public void testSetDataValueNull() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals(0, converter.conversionValuesSize());
-
- converter.addConversionValue(0).setDataValue("FOO");
- assertSourceContains("@ObjectTypeConverter(conversionValues = @ConversionValue(dataValue = \"FOO\"))", cu);
-
- converter.conversionValueAt(0).setDataValue(null);
- assertSourceContains("@ObjectTypeConverter(conversionValues = @ConversionValue)", cu);
- assertEquals(1, converter.conversionValuesSize());
- }
-
- public void testGetObjectValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Female", converter.conversionValueAt(0).getObjectValue());
- }
-
- public void testSetObjectValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Female", converter.conversionValueAt(0).getObjectValue());
-
- converter.conversionValueAt(0).setObjectValue("FOO");
- assertEquals("FOO", converter.conversionValueAt(0).getObjectValue());
-
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(dataValue = \"F\", objectValue = \"FOO\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})", cu);
- }
-
- public void testSetObjectValueNull() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals(0, converter.conversionValuesSize());
-
- converter.addConversionValue(0).setObjectValue("FOO");
- assertSourceContains("@ObjectTypeConverter(conversionValues = @ConversionValue(objectValue = \"FOO\"))", cu);
-
- converter.conversionValueAt(0).setObjectValue(null);
- assertSourceContains("@ObjectTypeConverter(conversionValues = @ConversionValue)", cu);
- assertEquals(1, converter.conversionValuesSize());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConvertAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConvertAnnotationTests.java
deleted file mode 100644
index 4cdc3e72d3..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConvertAnnotationTests.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
-
-@SuppressWarnings("nls")
-public class ConvertAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ConvertAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestConvert() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CONVERT);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert");
- }
- });
- }
-
- private ICompilationUnit createTestConverterWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CONVERT);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Convert(value=\"myConverter\")");
- }
- });
- }
-
- public void testConvertAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestConvert();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.CONVERT));
-
- attributeResource.removeAnnotation(EclipseLink.CONVERT);
- assertNull(attributeResource.getAnnotation(EclipseLink.CONVERT));
-
- attributeResource.addAnnotation(EclipseLink.CONVERT);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.CONVERT));
- }
-
- public void testGetValue() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERT);
- assertEquals("myConverter", convert.getValue());
- }
-
- public void testSetValue() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERT);
- assertEquals("myConverter", convert.getValue());
-
- convert.setValue("Bar");
- assertEquals("Bar", convert.getValue());
-
- assertSourceContains("@Convert(value=\"Bar\")", cu);
- }
-
- public void testSetValueNull() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConvertAnnotation convert = (EclipseLinkConvertAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERT);
- assertEquals("myConverter", convert.getValue());
-
- convert.setValue(null);
- assertNull(convert.getValue());
-
- assertSourceContains("@Convert", cu);
- assertSourceDoesNotContain("value", cu);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConverterAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConverterAnnotationTests.java
deleted file mode 100644
index 20b5a84766..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ConverterAnnotationTests.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConverterAnnotation;
-
-@SuppressWarnings("nls")
-public class ConverterAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ConverterAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Converter");
- }
- });
- }
-
- private ICompilationUnit createTestConverterWithConverterClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Converter(converterClass=Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestConverterWithName() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Converter(name=\"bar\")");
- }
- });
- }
-
- public void testConverterAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.CONVERTER));
-
- attributeResource.removeAnnotation(EclipseLink.CONVERTER);
- assertNull(attributeResource.getAnnotation(EclipseLink.CONVERTER));
-
- attributeResource.addAnnotation(EclipseLink.CONVERTER);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.CONVERTER));
- }
-
- public void testGetConverterClass() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithConverterClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConverterAnnotation converter = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERTER);
- assertEquals("Foo", converter.getConverterClass());
- }
-
- public void testSetConverterClass() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithConverterClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConverterAnnotation converter = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERTER);
- assertEquals("Foo", converter.getConverterClass());
-
- converter.setConverterClass("Bar");
- assertEquals("Bar", converter.getConverterClass());
-
- assertSourceContains("@Converter(converterClass=Bar.class)", cu);
- }
-
- public void testSetConverterClassNull() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithConverterClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConverterAnnotation converter = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERTER);
- assertEquals("Foo", converter.getConverterClass());
-
- converter.setConverterClass(null);
- assertNull(converter.getConverterClass());
-
- assertSourceContains("@Converter", cu);
- assertSourceDoesNotContain("converterClass", cu);
- }
-
- public void testGetName() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConverterAnnotation converter = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERTER);
- assertEquals("bar", converter.getName());
- }
-
- public void testSetName() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConverterAnnotation converter = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName("foo");
- assertEquals("foo", converter.getName());
-
- assertSourceContains("@Converter(name=\"foo\")", cu);
- }
-
- public void testSetNameNull() throws Exception {
- ICompilationUnit cu = this.createTestConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkConverterAnnotation converter = (EclipseLinkConverterAnnotation) attributeResource.getAnnotation(EclipseLink.CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName(null);
- assertNull(converter.getName());
-
- assertSourceContains("@Converter", cu);
- assertSourceDoesNotContain("name=", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CustomizerAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CustomizerAnnotationTests.java
deleted file mode 100644
index 00fe7cda5e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/CustomizerAnnotationTests.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
-
-@SuppressWarnings("nls")
-public class CustomizerAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public CustomizerAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestCustomizer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Customizer");
- }
- });
- }
-
- private ICompilationUnit createTestCustomizerWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Customizer(Foo.class)");
- }
- });
- }
-
- public void testCustomizerAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestCustomizer();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- assertNotNull(typeResource.getAnnotation(EclipseLink.CUSTOMIZER));
-
- typeResource.removeAnnotation(EclipseLink.CUSTOMIZER);
- assertNull(typeResource.getAnnotation(EclipseLink.CUSTOMIZER));
-
- typeResource.addAnnotation(EclipseLink.CUSTOMIZER);
- assertNotNull(typeResource.getAnnotation(EclipseLink.CUSTOMIZER));
- }
-
- public void testGetConverterClass() throws Exception {
- ICompilationUnit cu = this.createTestCustomizerWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCustomizerAnnotation converter = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLink.CUSTOMIZER);
- assertEquals("Foo", converter.getValue());
- }
-
- public void testSetConverterClass() throws Exception {
- ICompilationUnit cu = this.createTestCustomizerWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCustomizerAnnotation converter = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLink.CUSTOMIZER);
- assertEquals("Foo", converter.getValue());
-
- converter.setValue("Bar");
- assertEquals("Bar", converter.getValue());
-
- assertSourceContains("@Customizer(Bar.class)", cu);
- }
-
- public void testSetConverterClassNull() throws Exception {
- ICompilationUnit cu = this.createTestCustomizerWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCustomizerAnnotation converter = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLink.CUSTOMIZER);
- assertEquals("Foo", converter.getValue());
-
- converter.setValue(null);
- assertNull(converter.getValue());
-
- assertSourceContains("@Customizer", cu);
- assertSourceDoesNotContain("Foo.class", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkJavaResourceModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkJavaResourceModelTestCase.java
deleted file mode 100644
index 3eaee19888..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkJavaResourceModelTestCase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import org.eclipse.jpt.jpa.core.JpaAnnotationProvider;
-import org.eclipse.jpt.jpa.core.internal.GenericJpaAnnotationDefinitionProvider;
-import org.eclipse.jpt.jpa.core.internal.GenericJpaAnnotationProvider;
-import org.eclipse.jpt.jpa.core.tests.internal.resource.java.JpaJavaResourceModelTestCase;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaAnnotationDefinitionProvider;
-
-public class EclipseLinkJavaResourceModelTestCase extends JpaJavaResourceModelTestCase
-{
-
- public static final String ECLIPSELINK_ANNOTATIONS_PACKAGE_NAME = "org.eclipse.persistence.annotations"; //$NON-NLS-1$
-
- public EclipseLinkJavaResourceModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected JpaAnnotationProvider buildAnnotationProvider() {
- return new GenericJpaAnnotationProvider(
- GenericJpaAnnotationDefinitionProvider.instance(),
- EclipseLinkJpaAnnotationDefinitionProvider.instance());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkPrimaryKeyAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkPrimaryKeyAnnotationTests.java
deleted file mode 100644
index 23b26e2338..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/EclipseLinkPrimaryKeyAnnotationTests.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-
-public class EclipseLinkPrimaryKeyAnnotationTests
- extends EclipseLinkJavaResourceModelTestCase
-{
- public EclipseLinkPrimaryKeyAnnotationTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTestTypeWithPrimaryKeyAnnotation() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.PRIMARY_KEY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@PrimaryKey");
- }
- });
- }
-
-
- public void testAddRemoveAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestTypeWithPrimaryKeyAnnotation();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- assertNotNull(typeResource.getAnnotation(EclipseLink.PRIMARY_KEY));
-
- typeResource.removeAnnotation(EclipseLink.PRIMARY_KEY);
- assertNull(typeResource.getAnnotation(EclipseLink.PRIMARY_KEY));
-
- typeResource.addAnnotation(EclipseLink.PRIMARY_KEY);
- assertNotNull(typeResource.getAnnotation(EclipseLink.PRIMARY_KEY));
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ExistenceCheckingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ExistenceCheckingTests.java
deleted file mode 100644
index 8bd27532a1..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ExistenceCheckingTests.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkExistenceCheckingAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.ExistenceType;
-
-@SuppressWarnings("nls")
-public class ExistenceCheckingTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ExistenceCheckingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestExistenceChecking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.EXISTENCE_CHECKING, EclipseLink.EXISTENCE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@ExistenceChecking");
- }
- });
- }
-
- private ICompilationUnit createTestExistenceCheckingWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.EXISTENCE_CHECKING, EclipseLink.EXISTENCE_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@ExistenceChecking(ExistenceType.ASSUME_EXISTENCE)");
- }
- });
- }
-
- public void testExistenceChecking() throws Exception {
- ICompilationUnit cu = this.createTestExistenceChecking();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkExistenceCheckingAnnotation existenceChecking = (EclipseLinkExistenceCheckingAnnotation) typeResource.getAnnotation(EclipseLink.EXISTENCE_CHECKING);
- assertNotNull(existenceChecking);
- }
-
- public void testGetValue() throws Exception {
- ICompilationUnit cu = this.createTestExistenceCheckingWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkExistenceCheckingAnnotation existenceChecking = (EclipseLinkExistenceCheckingAnnotation) typeResource.getAnnotation(EclipseLink.EXISTENCE_CHECKING);
- assertEquals(ExistenceType.ASSUME_EXISTENCE, existenceChecking.getValue());
- }
-
- public void testSetValue() throws Exception {
- ICompilationUnit cu = this.createTestExistenceCheckingWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkExistenceCheckingAnnotation existenceChecking = (EclipseLinkExistenceCheckingAnnotation) typeResource.getAnnotation(EclipseLink.EXISTENCE_CHECKING);
- assertEquals(ExistenceType.ASSUME_EXISTENCE, existenceChecking.getValue());
-
- existenceChecking.setValue(ExistenceType.ASSUME_NON_EXISTENCE);
- assertEquals(ExistenceType.ASSUME_NON_EXISTENCE, existenceChecking.getValue());
-
- assertSourceContains("@ExistenceChecking(ASSUME_NON_EXISTENCE)", cu);
-
- existenceChecking.setValue(null);
- assertNull(existenceChecking.getValue());
-
- assertSourceDoesNotContain("(ASSUME_NON_EXISTENCE)", cu);
- assertSourceContains("@ExistenceChecking", cu);
- assertSourceDoesNotContain("@ExistenceChecking(", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JoinFetchTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JoinFetchTests.java
deleted file mode 100644
index 87d058783a..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JoinFetchTests.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType;
-
-@SuppressWarnings("nls")
-public class JoinFetchTests extends EclipseLinkJavaResourceModelTestCase {
-
- public JoinFetchTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestJoinFetch() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinFetch");
- }
- });
- }
-
- private ICompilationUnit createTestJoinFetchWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@JoinFetch(JoinFetchType.OUTER)");
- }
- });
- }
-
- public void testJoinFetch() throws Exception {
- ICompilationUnit cu = this.createTestJoinFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkJoinFetchAnnotation joinFetch = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLink.JOIN_FETCH);
- assertNotNull(joinFetch);
- }
-
- public void testGetValue() throws Exception {
- ICompilationUnit cu = this.createTestJoinFetchWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkJoinFetchAnnotation joinFetch = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLink.JOIN_FETCH);
- assertEquals(JoinFetchType.OUTER, joinFetch.getValue());
- }
-
- public void testSetValue() throws Exception {
- ICompilationUnit cu = this.createTestJoinFetchWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkJoinFetchAnnotation joinFetch = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLink.JOIN_FETCH);
- assertEquals(JoinFetchType.OUTER, joinFetch.getValue());
-
- joinFetch.setValue(JoinFetchType.INNER);
- assertEquals(JoinFetchType.INNER, joinFetch.getValue());
-
- assertSourceContains("@JoinFetch(INNER)", cu);
-
- joinFetch.setValue(null);
- assertNull(joinFetch.getValue());
-
- assertSourceDoesNotContain("(INNER)", cu);
- assertSourceContains("@JoinFetch", cu);
- assertSourceDoesNotContain("@JoinFetch(", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JptEclipseLinkCoreJavaResourceModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JptEclipseLinkCoreJavaResourceModelTests.java
deleted file mode 100644
index 31ddef39c5..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/JptEclipseLinkCoreJavaResourceModelTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.eclipselink.core.tests.internal.resource.java;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptEclipseLinkCoreJavaResourceModelTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLinkCoreJavaResourceModelTests.class.getName());
- suite.addTestSuite(CacheTests.class);
- suite.addTestSuite(ChangeTrackingTests.class);
- suite.addTestSuite(ConversionValueAnnotationTests.class);
- suite.addTestSuite(ConvertAnnotationTests.class);
- suite.addTestSuite(ConverterAnnotationTests.class);
- suite.addTestSuite(CustomizerAnnotationTests.class);
- suite.addTestSuite(ExistenceCheckingTests.class);
- suite.addTestSuite(JoinFetchTests.class);
- suite.addTestSuite(MutableAnnotationTests.class);
- suite.addTestSuite(ObjectTypeConverterAnnotationTests.class);
- suite.addTestSuite(EclipseLinkPrimaryKeyAnnotationTests.class);
- suite.addTestSuite(PrivateOwnedTests.class);
- suite.addTestSuite(ReadOnlyTests.class);
- suite.addTestSuite(ReadTransformerAnnotationTests.class);
- suite.addTestSuite(StructConverterAnnotationTests.class);
- suite.addTestSuite(TimeOfDayTests.class);
- suite.addTestSuite(TransformationAnnotationTests.class);
- suite.addTestSuite(TypeConverterAnnotationTests.class);
- suite.addTestSuite(WriteTransformerAnnotationTests.class);
-
- return suite;
- }
-
- private JptEclipseLinkCoreJavaResourceModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/MutableAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/MutableAnnotationTests.java
deleted file mode 100644
index 27f1bf0058..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/MutableAnnotationTests.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkMutableAnnotation;
-
-@SuppressWarnings("nls")
-public class MutableAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public MutableAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestMutable() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.MUTABLE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Mutable");
- }
- });
- }
-
- private ICompilationUnit createTestMutableWithValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.MUTABLE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Mutable(value=true)");
- }
- });
- }
-
-
-
- public void testMutableAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestMutable();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.MUTABLE));
-
- attributeResource.removeAnnotation(EclipseLink.MUTABLE);
- assertNull(attributeResource.getAnnotation(EclipseLink.MUTABLE));
-
- attributeResource.addAnnotation(EclipseLink.MUTABLE);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.MUTABLE));
- }
-
- public void testGetValue() throws Exception {
- ICompilationUnit cu = this.createTestMutableWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLink.MUTABLE);
- assertEquals(Boolean.TRUE, mutableAnnotation.getValue());
- }
-
- public void testSetValue() throws Exception {
- ICompilationUnit cu = this.createTestMutableWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLink.MUTABLE);
- assertEquals(Boolean.TRUE, mutableAnnotation.getValue());
-
- mutableAnnotation.setValue(Boolean.FALSE);
- assertEquals(Boolean.FALSE, mutableAnnotation.getValue());
-
- assertSourceContains("@Mutable(value=false)", cu);
-
- mutableAnnotation.setValue(null);
- mutableAnnotation.setValue(Boolean.FALSE);
- assertSourceContains("@Mutable(false)", cu);
- }
-
- public void testSetValueNull() throws Exception {
- ICompilationUnit cu = this.createTestMutableWithValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkMutableAnnotation mutableAnnotation = (EclipseLinkMutableAnnotation) attributeResource.getAnnotation(EclipseLink.MUTABLE);
- assertEquals(Boolean.TRUE, mutableAnnotation.getValue());
-
- mutableAnnotation.setValue(null);
- assertNull(mutableAnnotation.getValue());
-
- assertSourceContains("@Mutable", cu);
- assertSourceDoesNotContain("value", cu);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ObjectTypeConverterAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ObjectTypeConverterAnnotationTests.java
deleted file mode 100644
index 4ce638b24e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ObjectTypeConverterAnnotationTests.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkConversionValueAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkObjectTypeConverterAnnotation;
-
-@SuppressWarnings("nls")
-public class ObjectTypeConverterAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ObjectTypeConverterAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestObjectTypeConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter");
- }
- });
- }
-
- private ICompilationUnit createTestObjectTypeConverterWithDataType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter(dataType=Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestObjectTypeConverterWithObjectType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter(objectType=Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestObjectTypeConverterWithName() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter(name = \"bar\")");
- }
- });
- }
-
- private ICompilationUnit createTestObjectTypeConverterWithDefaultObjectValue() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter(defaultObjectValue = \"f\")");
- }
- });
- }
-
- private ICompilationUnit createTestObjectTypeConverterWithConversionValues() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.OBJECT_TYPE_CONVERTER, EclipseLink.CONVERSION_VALUE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ObjectTypeConverter(conversionValues = {@ConversionValue(dataValue = \"F\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})");
- }
- });
- }
-
- public void testObjectTypeConverterAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER));
-
- attributeResource.removeAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertNull(attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER));
-
- attributeResource.addAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER));
- }
-
- public void testGetDataType() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithDataType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Foo", converter.getDataType());
- }
-
- public void testSetDataType() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithDataType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Foo", converter.getDataType());
-
- converter.setDataType("Bar");
- assertEquals("Bar", converter.getDataType());
-
- assertSourceContains("@ObjectTypeConverter(dataType=Bar.class)", cu);
-
- converter.setDataType("int");
- assertEquals("int", converter.getDataType());
- assertSourceContains("@ObjectTypeConverter(dataType=int.class)", cu);
- }
-
- public void testSetDataTypeNull() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithDataType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Foo", converter.getDataType());
-
- converter.setDataType(null);
- assertNull(converter.getDataType());
-
- assertSourceContains("@ObjectTypeConverter", cu);
- assertSourceDoesNotContain("dataType", cu);
- }
-
- public void testGetObjectType() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithObjectType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Foo", converter.getObjectType());
- }
-
- public void testSetObjectType() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithObjectType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Foo", converter.getObjectType());
-
- converter.setObjectType("Bar");
- assertEquals("Bar", converter.getObjectType());
-
- assertSourceContains("@ObjectTypeConverter(objectType=Bar.class)", cu);
-
- converter.setObjectType("int");
- assertEquals("int", converter.getObjectType());
- assertSourceContains("@ObjectTypeConverter(objectType=int.class)", cu);
- }
-
- public void testSetObjectTypeNull() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithObjectType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("Foo", converter.getObjectType());
-
- converter.setObjectType(null);
- assertNull(converter.getObjectType());
-
- assertSourceContains("@ObjectTypeConverter", cu);
- assertSourceDoesNotContain("objectType", cu);
- }
-
- public void testGetName() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("bar", converter.getName());
- }
-
- public void testSetName() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName("foo");
- assertEquals("foo", converter.getName());
-
- assertSourceContains("@ObjectTypeConverter(name = \"foo\")", cu);
- }
-
- public void testSetNameNull() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName(null);
- assertNull(converter.getName());
-
- assertSourceContains("@ObjectTypeConverter", cu);
- assertSourceDoesNotContain("name=", cu);
- }
-
-
- public void testGetDefaultObjectValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithDefaultObjectValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("f", converter.getDefaultObjectValue());
- }
-
- public void testSetDefaultObjectValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithDefaultObjectValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("f", converter.getDefaultObjectValue());
-
- converter.setDefaultObjectValue("foo");
- assertEquals("foo", converter.getDefaultObjectValue());
-
- assertSourceContains("@ObjectTypeConverter(defaultObjectValue = \"foo\")", cu);
- }
-
- public void testSetDefaultObjectValueNull() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithDefaultObjectValue();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- assertEquals("f", converter.getDefaultObjectValue());
-
- converter.setDefaultObjectValue(null);
- assertNull(converter.getDefaultObjectValue());
-
- assertSourceContains("@ObjectTypeConverter", cu);
- assertSourceDoesNotContain("defaultObjectValue", cu);
- }
-
- public void testConversionValues() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
-
- assertEquals(0, converter.conversionValuesSize());
- assertFalse(converter.conversionValues().hasNext());
- }
-
- public void testConversionValues2() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
-
-
- converter.addConversionValue(0);
- converter.addConversionValue(1);
-
- assertEquals(2, converter.conversionValuesSize());
- ListIterator<EclipseLinkConversionValueAnnotation> conversionValues = converter.conversionValues();
- assertTrue(conversionValues.hasNext());
- assertNotNull(conversionValues.next());
- assertNotNull(conversionValues.next());
- assertFalse(conversionValues.hasNext());
- }
-
- public void testConversionValues3() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
-
- assertEquals(2, converter.conversionValuesSize());
- ListIterator<EclipseLinkConversionValueAnnotation> conversionValues = converter.conversionValues();
- EclipseLinkConversionValueAnnotation conversionValue = conversionValues.next();
- assertEquals("F", conversionValue.getDataValue());
- assertEquals("Female", conversionValue.getObjectValue());
- conversionValue = conversionValues.next();
- assertEquals("M", conversionValue.getDataValue());
- assertEquals("Male", conversionValue.getObjectValue());
- assertFalse(conversionValues.hasNext());
- }
-
- public void testAddConversionValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
-
- converter.addConversionValue(0).setObjectValue("FOO");
- converter.addConversionValue(1);
- converter.addConversionValue(0).setDataValue("BAR");
-
- assertEquals("BAR", converter.conversionValueAt(0).getDataValue());
- assertNull(converter.conversionValueAt(0).getObjectValue());
- assertEquals("FOO", converter.conversionValueAt(1).getObjectValue());
- assertNull(converter.conversionValueAt(1).getDataValue());
- assertNull(converter.conversionValueAt(2).getDataValue());
- assertNull(converter.conversionValueAt(2).getObjectValue());
-
- assertSourceContains("@ObjectTypeConverter(name = \"bar\", conversionValues = {@ConversionValue(dataValue = \"BAR\"),@ConversionValue(objectValue = \"FOO\"), @ConversionValue})", cu);
- }
-
- public void testRemoveConversionValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- converter.addConversionValue(0).setObjectValue("FOO");
-
- Iterator<EclipseLinkConversionValueAnnotation> conversionValues = converter.conversionValues();
- assertEquals("FOO", conversionValues.next().getObjectValue());
- assertEquals("Female", conversionValues.next().getObjectValue());
- assertEquals("Male", conversionValues.next().getObjectValue());
- assertFalse(conversionValues.hasNext());
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(objectValue = \"FOO\"), @ConversionValue(dataValue = \"F\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})", cu);
-
- converter.removeConversionValue(1);
- conversionValues = converter.conversionValues();
- assertEquals("FOO", conversionValues.next().getObjectValue());
- assertEquals("Male", conversionValues.next().getObjectValue());
- assertFalse(conversionValues.hasNext());
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(objectValue = \"FOO\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})", cu);
-
- converter.removeConversionValue(0);
- conversionValues = converter.conversionValues();
- assertEquals("Male", conversionValues.next().getObjectValue());
- assertFalse(conversionValues.hasNext());
- assertSourceContains("@ObjectTypeConverter(conversionValues = @ConversionValue(dataValue = \"M\", objectValue = \"Male\"))", cu);
-
-
- converter.removeConversionValue(0);
- assertSourceDoesNotContain("@conversionValues", cu);
- assertSourceContains("@ObjectTypeConverter", cu);
- }
-
- public void testMoveConversionValue() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- converter.addConversionValue(0).setObjectValue("FOO");
-
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(objectValue = \"FOO\"), @ConversionValue(dataValue = \"F\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})", cu);
-
- converter.moveConversionValue(2, 0);
- assertEquals("Female", converter.conversionValueAt(0).getObjectValue());
- assertEquals("F", converter.conversionValueAt(0).getDataValue());
- assertEquals("Male", converter.conversionValueAt(1).getObjectValue());
- assertEquals("M", converter.conversionValueAt(1).getDataValue());
- assertEquals("FOO", converter.conversionValueAt(2).getObjectValue());
- assertEquals(null, converter.conversionValueAt(2).getDataValue());
- assertEquals(3, converter.conversionValuesSize());
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(dataValue = \"F\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\"), @ConversionValue(objectValue = \"FOO\")})", cu);
- }
-
- public void testMoveConversionValue2() throws Exception {
- ICompilationUnit cu = this.createTestObjectTypeConverterWithConversionValues();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkObjectTypeConverterAnnotation converter = (EclipseLinkObjectTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.OBJECT_TYPE_CONVERTER);
- converter.addConversionValue(0).setObjectValue("FOO");
-
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(objectValue = \"FOO\"), @ConversionValue(dataValue = \"F\", objectValue = \"Female\"), @ConversionValue(dataValue = \"M\", objectValue = \"Male\")})", cu);
-
- converter.moveConversionValue(0, 2);
- assertEquals("Male", converter.conversionValueAt(0).getObjectValue());
- assertEquals("M", converter.conversionValueAt(0).getDataValue());
- assertEquals("FOO", converter.conversionValueAt(1).getObjectValue());
- assertEquals(null, converter.conversionValueAt(1).getDataValue());
- assertEquals("Female", converter.conversionValueAt(2).getObjectValue());
- assertEquals("F", converter.conversionValueAt(2).getDataValue());
- assertEquals(3, converter.conversionValuesSize());
- assertSourceContains("@ObjectTypeConverter(conversionValues = {@ConversionValue(dataValue = \"M\", objectValue = \"Male\"), @ConversionValue(objectValue = \"FOO\"), @ConversionValue(dataValue = \"F\", objectValue = \"Female\")})", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/PrivateOwnedTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/PrivateOwnedTests.java
deleted file mode 100644
index 7a6d40435f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/PrivateOwnedTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkPrivateOwnedAnnotation;
-
-@SuppressWarnings("nls")
-public class PrivateOwnedTests extends EclipseLinkJavaResourceModelTestCase {
-
- public PrivateOwnedTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestPrivateOwned() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.PRIVATE_OWNED);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@PrivateOwned");
- }
- });
- }
-
- public void testPrivateOwned() throws Exception {
- ICompilationUnit cu = this.createTestPrivateOwned();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkPrivateOwnedAnnotation privateOwned = (EclipseLinkPrivateOwnedAnnotation) attributeResource.getAnnotation(EclipseLink.PRIVATE_OWNED);
- assertNotNull(privateOwned);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadOnlyTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadOnlyTests.java
deleted file mode 100644
index 2590d529f9..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadOnlyTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
-
-@SuppressWarnings("nls")
-public class ReadOnlyTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ReadOnlyTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@ReadOnly");
- }
- });
- }
-
- public void testReadOnly() throws Exception {
- ICompilationUnit cu = this.createTestReadOnly();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkReadOnlyAnnotation readOnly = (EclipseLinkReadOnlyAnnotation) typeResource.getAnnotation(EclipseLink.READ_ONLY);
- assertNotNull(readOnly);
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadTransformerAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadTransformerAnnotationTests.java
deleted file mode 100644
index 9a6c204a8c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/ReadTransformerAnnotationTests.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadTransformerAnnotation;
-
-@SuppressWarnings("nls")
-public class ReadTransformerAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public ReadTransformerAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestReadTransformer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.READ_TRANSFORMER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ReadTransformer");
- }
- });
- }
-
- private ICompilationUnit createTestReadTransformerWithTransformerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.READ_TRANSFORMER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ReadTransformer(transformerClass=Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestReadTransformerWithMethod() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.READ_TRANSFORMER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ReadTransformer(method=\"transformerMethod\")");
- }
- });
- }
-
- public void testReadTransformerAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformer();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER));
-
- attributeResource.removeAnnotation(EclipseLink.READ_TRANSFORMER) ;
- assertNull(attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER));
-
- attributeResource.addAnnotation(EclipseLink.READ_TRANSFORMER);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER));
- }
-
- public void testGetTransformerClass() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformerWithTransformerClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkReadTransformerAnnotation readTransformer = (EclipseLinkReadTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER);
- assertEquals("Foo", readTransformer.getTransformerClass());
- }
-
- public void testSetTransformerClass() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformerWithTransformerClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkReadTransformerAnnotation readTransformer = (EclipseLinkReadTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER);
- assertEquals("Foo", readTransformer.getTransformerClass());
-
- readTransformer.setTransformerClass("Bar");
- assertEquals("Bar", readTransformer.getTransformerClass());
-
- assertSourceContains("@ReadTransformer(transformerClass=Bar.class)", cu);
- }
-
- public void testSetTransformerClassNull() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformerWithTransformerClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkReadTransformerAnnotation readTransformer = (EclipseLinkReadTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER);
- assertEquals("Foo", readTransformer.getTransformerClass());
-
- readTransformer.setTransformerClass(null);
- assertNull(readTransformer.getTransformerClass());
-
- assertSourceContains("@ReadTransformer", cu);
- assertSourceDoesNotContain("transformerClass", cu);
- }
-
- public void testGetMethod() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkReadTransformerAnnotation readTransformer = (EclipseLinkReadTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER);
- assertEquals("transformerMethod", readTransformer.getMethod());
- }
-
- public void testSetMethod() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkReadTransformerAnnotation readTransformer = (EclipseLinkReadTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER);
- assertEquals("transformerMethod", readTransformer.getMethod());
-
- readTransformer.setMethod("foo");
- assertEquals("foo", readTransformer.getMethod());
-
- assertSourceContains("@ReadTransformer(method=\"foo\")", cu);
- }
-
- public void testSetMethodNull() throws Exception {
- ICompilationUnit cu = this.createTestReadTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkReadTransformerAnnotation readTransformer = (EclipseLinkReadTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.READ_TRANSFORMER);
- assertEquals("transformerMethod", readTransformer.getMethod());
-
- readTransformer.setMethod(null);
- assertNull(readTransformer.getMethod());
-
- assertSourceContains("@ReadTransformer", cu);
- assertSourceDoesNotContain("method", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/StructConverterAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/StructConverterAnnotationTests.java
deleted file mode 100644
index b8985fe727..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/StructConverterAnnotationTests.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkStructConverterAnnotation;
-
-@SuppressWarnings("nls")
-public class StructConverterAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public StructConverterAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestStructConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.STRUCT_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@StructConverter");
- }
- });
- }
-
- private ICompilationUnit createTestStructConverterWithConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.STRUCT_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@StructConverter(converter=\"Foo\")");
- }
- });
- }
-
- private ICompilationUnit createTestStructConverterWithName() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.STRUCT_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@StructConverter(name=\"bar\")");
- }
- });
- }
-
- public void testStructConverterAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestStructConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER));
-
- attributeResource.removeAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertNull(attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER));
-
- attributeResource.addAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER));
- }
-
- public void testGetConverter() throws Exception {
- ICompilationUnit cu = this.createTestStructConverterWithConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkStructConverterAnnotation converter = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertEquals("Foo", converter.getConverter());
- }
-
- public void testSetConverter() throws Exception {
- ICompilationUnit cu = this.createTestStructConverterWithConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkStructConverterAnnotation converter = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertEquals("Foo", converter.getConverter());
-
- converter.setConverter("Bar");
- assertEquals("Bar", converter.getConverter());
-
- assertSourceContains("@StructConverter(converter=\"Bar\")", cu);
- }
-
- public void testSetConverterNull() throws Exception {
- ICompilationUnit cu = this.createTestStructConverterWithConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkStructConverterAnnotation converter = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertEquals("Foo", converter.getConverter());
-
- converter.setConverter(null);
- assertNull(converter.getConverter());
-
- assertSourceContains("@StructConverter", cu);
- assertSourceDoesNotContain("converter", cu);
- }
-
- public void testGetName() throws Exception {
- ICompilationUnit cu = this.createTestStructConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkStructConverterAnnotation converter = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertEquals("bar", converter.getName());
- }
-
- public void testSetName() throws Exception {
- ICompilationUnit cu = this.createTestStructConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkStructConverterAnnotation converter = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName("foo");
- assertEquals("foo", converter.getName());
-
- assertSourceContains("@StructConverter(name=\"foo\")", cu);
- }
-
- public void testSetNameNull() throws Exception {
- ICompilationUnit cu = this.createTestStructConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkStructConverterAnnotation converter = (EclipseLinkStructConverterAnnotation) attributeResource.getAnnotation(EclipseLink.STRUCT_CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName(null);
- assertNull(converter.getName());
-
- assertSourceContains("@StructConverter", cu);
- assertSourceDoesNotContain("name=", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java
deleted file mode 100644
index 93d0daf2ef..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCacheAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTimeOfDayAnnotation;
-
-@SuppressWarnings("nls")
-public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase {
-
- public TimeOfDayTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestTimeOfDay() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.TIME_OF_DAY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiryTimeOfDay = @TimeOfDay)");
- }
- });
- }
-
- private ICompilationUnit createTestTimeOfDayWithHour() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.TIME_OF_DAY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiryTimeOfDay = @TimeOfDay(hour=5))");
- }
- });
- }
-
- private ICompilationUnit createTestTimeOfDayWithMinute() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.TIME_OF_DAY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiryTimeOfDay = @TimeOfDay(minute=5))");
- }
- });
- }
-
- private ICompilationUnit createTestTimeOfDayWithSecond() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.TIME_OF_DAY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiryTimeOfDay = @TimeOfDay(second=5))");
- }
- });
- }
-
- private ICompilationUnit createTestTimeOfDayWithMillisecond() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.CACHE, EclipseLink.TIME_OF_DAY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Cache(expiryTimeOfDay = @TimeOfDay(millisecond=5))");
- }
- });
- }
-
- public void testExpiryTimeOfDay() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDay();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
-
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
-
- assertNotNull(timeOfDay);
- }
-
- public void testGetHour() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithHour();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getHour());
- }
-
- public void testSetHour() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithHour();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getHour());
-
- timeOfDay.setHour(Integer.valueOf(80));
- assertEquals(Integer.valueOf(80), timeOfDay.getHour());
-
- assertSourceContains("@TimeOfDay(hour=80)", cu);
-
- timeOfDay.setHour(null);
- assertNull(timeOfDay.getHour());
-
- assertSourceDoesNotContain("(hour=80)", cu);
- assertSourceContains("@TimeOfDay", cu);
- }
-
- public void testGetMinute() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithMinute();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getMinute());
- }
-
- public void testSetMinute() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithMinute();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getMinute());
-
- timeOfDay.setMinute(Integer.valueOf(80));
- assertEquals(Integer.valueOf(80), timeOfDay.getMinute());
-
- assertSourceContains("@TimeOfDay(minute=80)", cu);
-
- timeOfDay.setMinute(null);
- assertNull(timeOfDay.getMinute());
-
- assertSourceDoesNotContain("(minute=80)", cu);
- assertSourceContains("@TimeOfDay", cu);
- }
-
- public void testGetSecond() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithSecond();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getSecond());
- }
-
- public void testSetSecond() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithSecond();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getSecond());
-
- timeOfDay.setSecond(Integer.valueOf(80));
- assertEquals(Integer.valueOf(80), timeOfDay.getSecond());
-
- assertSourceContains("@TimeOfDay(second=80)", cu);
-
- timeOfDay.setSecond(null);
- assertNull(timeOfDay.getSecond());
-
- assertSourceDoesNotContain("(second=80)", cu);
- assertSourceContains("@TimeOfDay", cu);
- }
-
- public void testGetMillisecond() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithMillisecond();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getMillisecond());
- }
-
- public void testSetMillisecond() throws Exception {
- ICompilationUnit cu = this.createTestTimeOfDayWithMillisecond();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
-
- EclipseLinkCacheAnnotation cache = (EclipseLinkCacheAnnotation) typeResource.getAnnotation(EclipseLink.CACHE);
- EclipseLinkTimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay();
- assertEquals(Integer.valueOf(5), timeOfDay.getMillisecond());
-
- timeOfDay.setMillisecond(Integer.valueOf(80));
- assertEquals(Integer.valueOf(80), timeOfDay.getMillisecond());
-
- assertSourceContains("@TimeOfDay(millisecond=80)", cu);
-
- timeOfDay.setMillisecond(null);
- assertNull(timeOfDay.getMillisecond());
-
- assertSourceDoesNotContain("(millisecond=80)", cu);
- assertSourceContains("@TimeOfDay", cu);
- }
-
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TransformationAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TransformationAnnotationTests.java
deleted file mode 100644
index ccc4093d95..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TransformationAnnotationTests.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.FetchType;
-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.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTransformationAnnotation;
-
-@SuppressWarnings("nls")
-public class TransformationAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public TransformationAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestTransformation() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TRANSFORMATION);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transformation");
- }
- });
- }
-
- private ICompilationUnit createTestTransformationWithOptional() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TRANSFORMATION);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transformation(optional = true)");
- }
- });
- }
-
- private ICompilationUnit createTestTransformationWithFetch() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TRANSFORMATION, JPA.FETCH_TYPE);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transformation(fetch = FetchType.EAGER)");
- }
- });
- }
-
- public void testTransformationAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestTransformation();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.TRANSFORMATION));
-
- attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance());
- assertNull(attributeResource.getAnnotation(EclipseLink.TRANSFORMATION));
-
- attributeResource.setPrimaryAnnotation(EclipseLink.TRANSFORMATION, EmptyIterable.<String>instance());
- assertNotNull(attributeResource.getAnnotation(EclipseLink.TRANSFORMATION));
- }
-
- public void testGetOptional() throws Exception {
- ICompilationUnit cu = this.createTestTransformationWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTransformationAnnotation transformation = (EclipseLinkTransformationAnnotation) attributeResource.getAnnotation(EclipseLink.TRANSFORMATION);
- assertEquals(Boolean.TRUE, transformation.getOptional());
- }
-
- public void testSetOptional() throws Exception {
- ICompilationUnit cu = this.createTestTransformationWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTransformationAnnotation transformation = (EclipseLinkTransformationAnnotation) attributeResource.getAnnotation(EclipseLink.TRANSFORMATION);
- assertEquals(Boolean.TRUE, transformation.getOptional());
-
- transformation.setOptional(Boolean.FALSE);
- assertEquals(Boolean.FALSE, transformation.getOptional());
-
- assertSourceContains("@Transformation(optional = false)", cu);
- }
-
- public void testSetOptionalNull() throws Exception {
- ICompilationUnit cu = this.createTestTransformationWithOptional();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTransformationAnnotation transformation = (EclipseLinkTransformationAnnotation) attributeResource.getAnnotation(EclipseLink.TRANSFORMATION);
- assertEquals(Boolean.TRUE, transformation.getOptional());
-
- transformation.setOptional(null);
- assertNull(transformation.getOptional());
-
- assertSourceContains("@Transformation", cu);
- assertSourceDoesNotContain("optional", cu);
- }
-
- public void testGetFetch() throws Exception {
- ICompilationUnit cu = this.createTestTransformationWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTransformationAnnotation transformation = (EclipseLinkTransformationAnnotation) attributeResource.getAnnotation(EclipseLink.TRANSFORMATION);
- assertEquals(FetchType.EAGER, transformation.getFetch());
- }
-
- public void testSetFetch() throws Exception {
- ICompilationUnit cu = this.createTestTransformationWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTransformationAnnotation transformation = (EclipseLinkTransformationAnnotation) attributeResource.getAnnotation(EclipseLink.TRANSFORMATION);
- assertEquals(FetchType.EAGER, transformation.getFetch());
-
- transformation.setFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, transformation.getFetch());
-
- assertSourceContains("@Transformation(fetch = LAZY)", cu);
- }
-
- public void testSetFetchNull() throws Exception {
- ICompilationUnit cu = this.createTestTransformationWithFetch();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTransformationAnnotation transformation = (EclipseLinkTransformationAnnotation) attributeResource.getAnnotation(EclipseLink.TRANSFORMATION);
- assertEquals(FetchType.EAGER, transformation.getFetch());
-
- transformation.setFetch(null);
- assertNull(transformation.getFetch());
-
- assertSourceContains("@Transformation", cu);
- assertSourceDoesNotContain("fetch", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TypeConverterAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TypeConverterAnnotationTests.java
deleted file mode 100644
index 49d4ac7a55..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/TypeConverterAnnotationTests.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkTypeConverterAnnotation;
-
-@SuppressWarnings("nls")
-public class TypeConverterAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public TypeConverterAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestTypeConverter() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TypeConverter");
- }
- });
- }
-
- private ICompilationUnit createTestTypeConverterWithDataType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TypeConverter(dataType = Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestTypeConverterWithObjectType() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TypeConverter(objectType = Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestTypeConverterWithName() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.TYPE_CONVERTER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@TypeConverter(name = \"bar\")");
- }
- });
- }
-
- public void testTypeConverterAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverter();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER));
-
- attributeResource.removeAnnotation(EclipseLink.TYPE_CONVERTER);
- assertNull(attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER));
-
- attributeResource.addAnnotation(EclipseLink.TYPE_CONVERTER);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER));
- }
-
- public void testGetTypeDataType() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithDataType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("Foo", converter.getDataType());
- }
-
- public void testSetDataType() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithDataType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("Foo", converter.getDataType());
-
- converter.setDataType("Bar");
- assertEquals("Bar", converter.getDataType());
-
- assertSourceContains("@TypeConverter(dataType = Bar.class)", cu);
-
- converter.setDataType("int");
- assertEquals("int", converter.getDataType());
- assertSourceContains("@TypeConverter(dataType = int.class)", cu);
- }
-
- public void testSetDataTypeNull() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithDataType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("Foo", converter.getDataType());
-
- converter.setDataType(null);
- assertNull(converter.getDataType());
-
- assertSourceContains("@TypeConverter", cu);
- assertSourceDoesNotContain("dataType", cu);
- }
-
- public void testGetTypeObjectType() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithObjectType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("Foo", converter.getObjectType());
- }
-
- public void testSetObjectType() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithObjectType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("Foo", converter.getObjectType());
-
- converter.setObjectType("Bar");
- assertEquals("Bar", converter.getObjectType());
-
- assertSourceContains("@TypeConverter(objectType = Bar.class)", cu);
-
- converter.setObjectType("int");
- assertEquals("int", converter.getObjectType());
- assertSourceContains("@TypeConverter(objectType = int.class)", cu);
- }
-
- public void testSetObjectTypeNull() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithObjectType();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("Foo", converter.getObjectType());
-
- converter.setObjectType(null);
- assertNull(converter.getObjectType());
-
- assertSourceContains("@TypeConverter", cu);
- assertSourceDoesNotContain("objectType", cu);
- }
-
- public void testGetName() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("bar", converter.getName());
- }
-
- public void testSetName() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName("foo");
- assertEquals("foo", converter.getName());
-
- assertSourceContains("@TypeConverter(name = \"foo\")", cu);
- }
-
- public void testSetNameNull() throws Exception {
- ICompilationUnit cu = this.createTestTypeConverterWithName();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkTypeConverterAnnotation converter = (EclipseLinkTypeConverterAnnotation) attributeResource.getAnnotation(EclipseLink.TYPE_CONVERTER);
- assertEquals("bar", converter.getName());
-
- converter.setName(null);
- assertNull(converter.getName());
-
- assertSourceContains("@TypeConverter", cu);
- assertSourceDoesNotContain("name=", cu);
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/WriteTransformerAnnotationTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/WriteTransformerAnnotationTests.java
deleted file mode 100644
index 442bbe81a1..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/resource/java/WriteTransformerAnnotationTests.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 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.eclipselink.core.tests.internal.resource.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-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.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkWriteTransformerAnnotation;
-
-@SuppressWarnings("nls")
-public class WriteTransformerAnnotationTests extends EclipseLinkJavaResourceModelTestCase {
-
- public WriteTransformerAnnotationTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestWriteTransformer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.WRITE_TRANSFORMER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@WriteTransformer");
- }
- });
- }
-
- private ICompilationUnit createTestWriteTransformerWithTransformerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.WRITE_TRANSFORMER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@WriteTransformer(transformerClass = Foo.class)");
- }
- });
- }
-
- private ICompilationUnit createTestWriteTransformerWithMethod() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.WRITE_TRANSFORMER);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@WriteTransformer(method = \"transformerMethod\")");
- }
- });
- }
-
- private ICompilationUnit createTestWriteTransformerWithColumn() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(EclipseLink.WRITE_TRANSFORMER, JPA.COLUMN);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@WriteTransformer(column = @Column(name = \"FOO\"))");
- }
- });
- }
-
-
- public void testWriteTransformerAnnotation() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformer();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- assertNotNull(attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER));
-
- attributeResource.removeAnnotation(EclipseLink.WRITE_TRANSFORMER) ;
- assertNull(attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER));
-
- attributeResource.addAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertNotNull(attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER));
- }
-
- public void testGetTransformerClass() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithTransformerClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertEquals("Foo", writeTransformer.getTransformerClass());
- }
-
- public void testSetTransformerClass() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithTransformerClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertEquals("Foo", writeTransformer.getTransformerClass());
-
- writeTransformer.setTransformerClass("Bar");
- assertEquals("Bar", writeTransformer.getTransformerClass());
-
- assertSourceContains("@WriteTransformer(transformerClass = Bar.class)", cu);
- }
-
- public void testSetTransformerClassNull() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithTransformerClass();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertEquals("Foo", writeTransformer.getTransformerClass());
-
- writeTransformer.setTransformerClass(null);
- assertNull(writeTransformer.getTransformerClass());
-
- assertSourceContains("@WriteTransformer", cu);
- assertSourceDoesNotContain("transformerClass", cu);
- }
-
- public void testGetMethod() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertEquals("transformerMethod", writeTransformer.getMethod());
- }
-
- public void testSetMethod() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertEquals("transformerMethod", writeTransformer.getMethod());
-
- writeTransformer.setMethod("foo");
- assertEquals("foo", writeTransformer.getMethod());
-
- assertSourceContains("@WriteTransformer(method = \"foo\")", cu);
- }
-
- public void testSetMethodNull() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertEquals("transformerMethod", writeTransformer.getMethod());
-
- writeTransformer.setMethod(null);
- assertNull(writeTransformer.getMethod());
-
- assertSourceContains("@WriteTransformer", cu);
- assertSourceDoesNotContain("method", cu);
- }
-
-
- public void testGetColumn() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertNotNull(writeTransformer.getColumn());
- assertEquals("FOO", writeTransformer.getColumn().getName());
- }
-
- public void testAddColumn() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithMethod();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertNull(writeTransformer.getColumn());
-
- writeTransformer.addColumn();
-
- assertNotNull(writeTransformer.getColumn());
- assertSourceContains("@WriteTransformer(method = \"transformerMethod\", column = @Column)", cu);
-
- writeTransformer.getColumn().setName("BAR");
- assertSourceContains("@WriteTransformer(method = \"transformerMethod\", column = @Column(name = \"BAR\"))", cu);
-
- }
-
- public void testRemoveColumn() throws Exception {
- ICompilationUnit cu = this.createTestWriteTransformerWithColumn();
- JavaResourcePersistentType typeResource = buildJavaTypeResource(cu);
- JavaResourcePersistentAttribute attributeResource = typeResource.fields().next();
-
- EclipseLinkWriteTransformerAnnotation writeTransformer = (EclipseLinkWriteTransformerAnnotation) attributeResource.getAnnotation(EclipseLink.WRITE_TRANSFORMER);
- assertNotNull(writeTransformer.getColumn());
- assertEquals("FOO", writeTransformer.getColumn().getName());
-
- writeTransformer.removeColumn();
- assertNull(writeTransformer.getColumn());
-
- assertSourceContains("@WriteTransformer", cu);
- assertSourceDoesNotContain("column", cu);
- }
-
- public void getNonNullColumn() throws Exception {
-
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1ContextModelTestCase.java
deleted file mode 100644
index dda1601884..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1ContextModelTestCase.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v1_1.context;
-
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-public abstract class EclipseLink1_1ContextModelTestCase extends EclipseLinkContextModelTestCase
-{
- public static final String JPA_ANNOTATIONS_PACKAGE_NAME = "javax.persistence"; //$NON-NLS-1$
-
- protected EclipseLink1_1ContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(JpaFacetInstallDataModelProperties.PLATFORM, EclipseLinkPlatform.VERSION_1_1);
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1JpaProjectTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1JpaProjectTests.java
deleted file mode 100644
index d01ac71afa..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/EclipseLink1_1JpaProjectTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v1_1.context;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.internal.operations.JpaFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v1_1.EclipseLink1_1;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public class EclipseLink1_1JpaProjectTests extends EclipseLink1_1ContextModelTestCase
-{
-
- public EclipseLink1_1JpaProjectTests(String name) {
- super(name);
- }
-
- public void testGetDefaultOrmXmlResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
- //add the orm.xml file with eclipselink 1.1 orm content type
- createDefaultOrmXmlFileWithEclipseLink1_1ContentType();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_1_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
-
- //add the orm.xml file with eclipselink orm content type
- createDefaultOrmXmlFileWithEclipseLinkContentType();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
-
- //add the orm.xml file this time with orm content type
- createDefaultOrmXmlFile();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
- }
-
- public void testGetDefaultEclipseLinkOrmXmlResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNull(resource);
-
- //add the eclipselink-orm.xml 1.1 file
- createDefaultEclipseLink1_1OrmXmlFile();
- resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_1_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/eclipselink-orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the eclipselink-orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNull(resource);
- }
-
- private void createDefaultOrmXmlFile() throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.getDefaultOperation().execute(null, null);
- }
-
- private void createDefaultOrmXmlFileWithEclipseLinkContentType() throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.setProperty(JptFileCreationDataModelProperties.FILE_NAME,
- JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.lastSegment());
- config.getDefaultOperation().execute(null, null);
- }
-
- private void createDefaultOrmXmlFileWithEclipseLink1_1ContentType() throws Exception {
- createEclipseLink1_1OrmXmlFile(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.lastSegment());
- }
-
- private void createDefaultEclipseLink1_1OrmXmlFile() throws Exception {
- createEclipseLink1_1OrmXmlFile(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.lastSegment());
- }
-
- private void createEclipseLink1_1OrmXmlFile(String fileName) throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, fileName);
- config.setProperty(JpaFileCreationDataModelProperties.VERSION, EclipseLink1_1.SCHEMA_VERSION);
- config.getDefaultOperation().execute(null, null);
- }
-
- public void testGetMappingFileResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNull(resource);
-
- //add the eclipselink-orm.xml 1.1 file
- createDefaultEclipseLink1_1OrmXmlFile();
- resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_1_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/eclipselink-orm.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the eclipselink-orm.xml file and verify it is not returned from getMappingFileResource()
- resource.delete(null);
- resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNull(resource);
- }
-
- public void testGetDifferentlyNamedMappingFileResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNull(resource);
-
- //create the orm2.xml file
- createEclipseLink1_1OrmXmlFile("orm2.xml");
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_1_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the orm2.xml file and verify it is not returned from getMappingFileResource()
- resource.delete(null);
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNull(resource);
-
- //add the orm2.xml file back
- createEclipseLink1_1OrmXmlFile("orm2.xml");
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_1_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/JptEclipseLink1_1CoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/JptEclipseLink1_1CoreContextModelTests.java
deleted file mode 100644
index 58f761be1e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/JptEclipseLink1_1CoreContextModelTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.v1_1.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_1.context.orm.JptEclipseLink1_1CoreOrmContextModelTests;
-
-public class JptEclipseLink1_1CoreContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink1_1CoreContextModelTests.class.getName());
- suite.addTestSuite(EclipseLink1_1JpaProjectTests.class);
- suite.addTest(JptEclipseLink1_1CoreOrmContextModelTests.suite());
- return suite;
- }
-
- private JptEclipseLink1_1CoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmContextModelTestCase.java
deleted file mode 100644
index 6d57e68f25..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmContextModelTestCase.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v1_1.context.orm;
-
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.JpaFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationOperation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v1_1.EclipseLink1_1;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v1_1.context.EclipseLink1_1ContextModelTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public abstract class EclipseLink1_1OrmContextModelTestCase
- extends EclipseLink1_1ContextModelTestCase
-{
- protected JpaXmlResource eclipseLink1_1OrmXmlResource;
-
-
- protected EclipseLink1_1OrmContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.eclipseLink1_1OrmXmlResource = getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- }
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- // don't create default orm.xml - instead build eclipselink-orm.xml
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.FALSE);
- return dataModel;
- }
-
- @Override
- protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild, IDataModel jpaConfig) throws Exception {
- TestJpaProject testJpaProject = super.buildJpaProject(projectName, autoBuild, jpaConfig);
-
- EclipseLinkOrmFileCreationOperation operation =
- new EclipseLinkOrmFileCreationOperation(buildEclipseLinkOrmConfig(testJpaProject));
- operation.execute(null, null);
-
- return testJpaProject;
- }
-
- protected IDataModel buildEclipseLinkOrmConfig(TestJpaProject testJpaProject) {
- IDataModel dataModel =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- dataModel.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- testJpaProject.getProject().getFolder("src/META-INF").getFullPath());
- dataModel.setProperty(JpaFileCreationDataModelProperties.VERSION, EclipseLink1_1.SCHEMA_VERSION);
- dataModel.setProperty(OrmFileCreationDataModelProperties.ADD_TO_PERSISTENCE_UNIT, Boolean.TRUE);
- return dataModel;
- }
-
- @Override
- protected void tearDown() throws Exception {
- this.eclipseLink1_1OrmXmlResource = null;
- super.tearDown();
- }
-
- @Override
- protected JpaXmlResource getOrmXmlResource() {
- return this.eclipseLink1_1OrmXmlResource;
- }
-
- @Override
- protected XmlEntityMappings getXmlEntityMappings() {
- return (XmlEntityMappings) super.getXmlEntityMappings();
- }
-
- @Override
- protected EclipseLinkEntityMappings getEntityMappings() {
- return (EclipseLinkEntityMappings) super.getEntityMappings();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentAttributeTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentAttributeTests.java
deleted file mode 100644
index a4dd7b7876..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentAttributeTests.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v1_1.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-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.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkIdMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkOneToOneMapping;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public class EclipseLink1_1OrmPersistentAttributeTests
- extends EclipseLink1_1OrmContextModelTestCase
-{
- public EclipseLink1_1OrmPersistentAttributeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- // create both orm.xml and eclipselink-orm.xml
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-
- private ICompilationUnit createTestTypeNullAttributeMapping() throws Exception {
-
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityIdMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append("@Column(name=\"FOO\")");
- }
- });
- }
-
- private ICompilationUnit createTestEntityIdMappingPropertyAccess() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append("@Column(name=\"FOO\")");
- }
- });
- }
-
- private ICompilationUnit createTestEntityOneToOneMapping() throws Exception {
- return this.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");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne");
- sb.append(" private Address address;");
- }
- });
- }
-
- public void testMakeSpecified() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertTrue(ormPersistentAttribute.isVirtual());
- ormPersistentAttribute.convertToSpecified();
-
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ormPersistentAttribute.convertToSpecified();
-
- assertEquals(0, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.specifiedAttributes();
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("name", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- }
-
- public void testMakeSpecifiedMappingKey() throws Exception {
- createTestTypeNullAttributeMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- //take a virtual mapping with a mapping type and make it specified
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertTrue(ormPersistentAttribute.isVirtual());
- assertNull(ormPersistentAttribute.getMapping().getKey());
- ormPersistentAttribute.convertToSpecified(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("address", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof OrmEclipseLinkOneToOneMapping);
-
-
- ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ormPersistentAttribute.convertToSpecified(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
-
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- Iterator<OrmPersistentAttribute> specifiedAttributes = ormPersistentType.specifiedAttributes();
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- assertTrue(specifiedOrmPersistentAttribute.getMapping() instanceof OrmEclipseLinkIdMapping);
-
- specifiedOrmPersistentAttribute = specifiedAttributes.next();
- assertEquals("address", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
- }
-
- public void testMakeVirtual() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- ormPersistentType.virtualAttributes().next().convertToSpecified();
- ormPersistentType.virtualAttributes().next().convertToSpecified();
-
- assertEquals(0, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- assertEquals("id", specifiedOrmPersistentAttribute.getName());
- assertFalse(specifiedOrmPersistentAttribute.isVirtual());
-
- specifiedOrmPersistentAttribute.convertToVirtual();
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
-
- specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- specifiedOrmPersistentAttribute.convertToVirtual();
- assertEquals(2, ormPersistentType.virtualAttributesSize());
- assertEquals(0, ormPersistentType.specifiedAttributesSize());
-
- Iterator<OrmReadOnlyPersistentAttribute> virtualAttributes = ormPersistentType.virtualAttributes();
- OrmReadOnlyPersistentAttribute virtualAttribute = virtualAttributes.next();
- assertEquals("id", virtualAttribute.getName());
- virtualAttribute = virtualAttributes.next();
- assertEquals("name", virtualAttribute.getName());
- }
-
- public void testMakeVirtualNoUnderlyingJavaAttribute() throws Exception {
- createTestType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- ormPersistentType.virtualAttributes().next().convertToSpecified();
- ormPersistentType.virtualAttributes().next().convertToSpecified();
-
-
- ormPersistentType.specifiedAttributes().next().getMapping().setName("noJavaAttribute");
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(2, ormPersistentType.specifiedAttributesSize());
-
-
- OrmPersistentAttribute specifiedOrmPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- specifiedOrmPersistentAttribute.convertToVirtual();
- assertEquals(1, ormPersistentType.virtualAttributesSize());
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
-
- assertEquals("id", ormPersistentType.virtualAttributes().next().getName());
- assertEquals("name", ormPersistentType.specifiedAttributes().next().getName());
- }
-
- public void testVirtualMappingTypeWhenMetadataComplete() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("id", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals("FOO", ((IdMapping) ormPersistentAttribute.getMapping()).getColumn().getName());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertEquals("id", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals("id", ((BasicMapping) ormPersistentAttribute.getMapping()).getColumn().getName());
- }
-
- public void testVirtualMappingTypeWhenMetadataComplete2() throws Exception {
- createTestEntityOneToOneMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
- assertEquals("address", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("address");
- assertEquals("address", ormPersistentAttribute.getName());
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- }
-
- public void testGetJavaPersistentAttribute() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- JavaPersistentAttribute javaPersistentAttribute = javaPersistentType.getAttributeNamed("id");
-
- //virtual orm attribute, access type matches java : FIELD, name matches java
- assertTrue(ormPersistentAttribute.isVirtual());
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- JavaResourcePersistentAttribute javaResourcePersistentAttribute = ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute();
- assertTrue(javaResourcePersistentAttribute.isField());
- assertEquals("id", javaResourcePersistentAttribute.getName());
- assertEquals(javaPersistentType.getResourcePersistentType().persistableFields().next(), javaResourcePersistentAttribute);
-
-
- //specified orm attribute, access type matches java : FIELD, name matches java
- //javaPersistentAttribute should be == to java context model object
- ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
-
-
- //virtual orm attribute, java access type FIELD, orm access type PROPERTY, name matches java
- //verify the property java resource persistent attribute is used in orm.
- ((OrmPersistentAttribute) ormPersistentAttribute).convertToVirtual();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- ormPersistentType.setSpecifiedAccess(AccessType.PROPERTY);
- assertNotSame(ormPersistentAttribute, ormPersistentType.getAttributeNamed("id"));
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- javaResourcePersistentAttribute = ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute();
- assertTrue(javaResourcePersistentAttribute.isProperty());
- assertEquals("id", javaResourcePersistentAttribute.getName());
- assertEquals(javaPersistentType.getResourcePersistentType().persistableProperties().next(), javaResourcePersistentAttribute);
-
-
- ormPersistentType.setSpecifiedAccess(null);//default access will be field
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- OrmPersistentAttribute ormPersistentAttribute2 = ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute2.getMapping().setName("id2");
- assertEquals(null, ormPersistentAttribute2.getJavaPersistentAttribute());
-
- ormPersistentAttribute2.getMapping().setName(null);
- assertEquals(null, ormPersistentAttribute2.getJavaPersistentAttribute());
-
- ormPersistentAttribute2.getMapping().setName("id");
- assertEquals(javaPersistentAttribute, ormPersistentAttribute2.getJavaPersistentAttribute());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(javaPersistentAttribute, ormPersistentAttribute2.getJavaPersistentAttribute());
- }
-
- public void testGetJavaPersistentAttributeMixedAccess() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ormPersistentType.setSpecifiedAccess(AccessType.PROPERTY);
- JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- JavaPersistentAttribute javaPersistentAttribute = javaPersistentType.getAttributeNamed("id");
-
- assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
- assertEquals(AccessType.FIELD, javaPersistentAttribute.getOwningPersistentType().getAccess());
- assertTrue(ormPersistentAttribute.isVirtual());
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- assertEquals(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
- assertEquals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, javaPersistentAttribute.getMappingKey());
-
-
- ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- assertTrue(ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute().isProperty());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isField());
-
- ((OrmPersistentAttribute) ormPersistentAttribute).setSpecifiedAccess(AccessType.FIELD);
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
- assertEquals(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- assertTrue(ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute().isField());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isField());
- }
-
- public void testGetAccess() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- JavaPersistentAttribute javaPersistentAttribute = javaPersistentType.getAttributeNamed("id");
-
- assertTrue(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
- assertTrue(ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute().isField());
- assertEquals(AccessType.FIELD, javaPersistentAttribute.getAccess());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isField());
-
-
- ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
- assertTrue(ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute().isField());
- assertEquals(AccessType.FIELD, javaPersistentAttribute.getAccess());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isField());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
- assertEquals(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getJavaPersistentAttribute().getAccess());
- assertEquals(AccessType.FIELD, javaPersistentAttribute.getAccess());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isField());
- }
-
- public void testGetAccessPropertyInJava() throws Exception {
- createTestEntityIdMappingPropertyAccess();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- JavaPersistentAttribute javaPersistentAttribute = javaPersistentType.getAttributeNamed("id");
-
- assertTrue(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
- assertTrue(ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute().isProperty());
- assertEquals(AccessType.PROPERTY, javaPersistentAttribute.getAccess());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isProperty());
-
-
- ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
- assertTrue(ormPersistentAttribute.getJavaPersistentAttribute().getResourcePersistentAttribute().isProperty());
- assertEquals(AccessType.PROPERTY, javaPersistentAttribute.getAccess());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isProperty());
-
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertFalse(ormPersistentAttribute.isVirtual());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
- assertNotSame(javaPersistentAttribute, ormPersistentAttribute.getJavaPersistentAttribute());
- assertEquals(AccessType.FIELD, ormPersistentAttribute.getJavaPersistentAttribute().getAccess());
- assertEquals(AccessType.PROPERTY, javaPersistentAttribute.getAccess());
- assertTrue(javaPersistentAttribute.getResourcePersistentAttribute().isProperty());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentTypeTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentTypeTests.java
deleted file mode 100644
index 77a1f17b86..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmPersistentTypeTests.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.eclipselink.core.tests.internal.v1_1.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-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.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public class EclipseLink1_1OrmPersistentTypeTests extends EclipseLink1_1OrmContextModelTestCase
-{
- public EclipseLink1_1OrmPersistentTypeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- // create both orm.xml and eclipselink-orm.xml
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-
- private ICompilationUnit createTestEntityIdMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Id");
- sb.append("@Column(name=\"FOO\")");
- }
- });
- }
-//
-// private void createAccessTypeEnum() throws Exception {
-// this.createEnumAndMembers(JPA_ANNOTATIONS_PACKAGE_NAME, "AccessType", "FIELD, PROPERTY;");
-// }
-//
-// private void createAccessAnnotation() throws Exception {
-// this.createAnnotationAndMembers(JPA_ANNOTATIONS_PACKAGE_NAME, "Access", "AccessType value();");
-// createAccessTypeEnum();
-// }
-//
-// private ICompilationUnit createTestEntityAnnotatedFieldPropertySpecified() throws Exception {
-// createAccessAnnotation();
-// return this.createTestType(new DefaultAnnotationWriter() {
-// @Override
-// public Iterator<String> imports() {
-// return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, JPA.ID, JPA.ACCESS, JPA.ACCESS_TYPE);
-// }
-// @Override
-// public void appendTypeAnnotationTo(StringBuilder sb) {
-// sb.append("@Entity");
-// sb.append("@Access(AccessType.PROPERTY)");
-// }
-//
-// @Override
-// public void appendNameFieldAnnotationTo(StringBuilder sb) {
-// sb.append("@Basic");
-// sb.append("@Access(AccessType.FIELD)");
-// }
-//
-// @Override
-// public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
-// sb.append("@Id");
-// }
-// });
-// }
-//
-// private ICompilationUnit createTestEntityFieldSpecifiedPropertyAnnotated() throws Exception {
-// createAccessAnnotation();
-// return this.createTestType(new DefaultAnnotationWriter() {
-// @Override
-// public Iterator<String> imports() {
-// return new ArrayIterator<String>(JPA.ENTITY, JPA.BASIC, JPA.ID, JPA.ACCESS, JPA.ACCESS_TYPE);
-// }
-// @Override
-// public void appendTypeAnnotationTo(StringBuilder sb) {
-// sb.append("@Entity");
-// sb.append("@Access(AccessType.FIELD)");
-// }
-//
-// @Override
-// public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
-// sb.append("@Id");
-// sb.append("@Access(AccessType.PROPERTY)");
-// }
-// });
-// }
-//
-// private ICompilationUnit createTestEntityPropertySpecified() throws Exception {
-// createAccessAnnotation();
-// return this.createTestType(new DefaultAnnotationWriter() {
-// @Override
-// public Iterator<String> imports() {
-// return new ArrayIterator<String>(JPA.ENTITY, JPA.ACCESS, JPA.ACCESS_TYPE);
-// }
-// @Override
-// public void appendTypeAnnotationTo(StringBuilder sb) {
-// sb.append("@Entity");
-// sb.append("@Access(AccessType.PROPERTY)");
-// }
-// });
-// }
-
- public void testGetAccessWithJavaAnnotations() throws Exception {
- createTestEntityIdMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-
- assertEquals(AccessType.FIELD, ormPersistentType.getAccess());
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- assertEquals(null, javaPersistentType.getSpecifiedAccess());
-
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
- ormPersistentAttribute.convertToSpecified();
- assertEquals(AccessType.FIELD, ormPersistentType.getAccess());
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- assertEquals(null, javaPersistentType.getSpecifiedAccess());
-
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(AccessType.FIELD, ormPersistentType.getAccess());
- assertEquals(AccessType.FIELD, javaPersistentType.getAccess());
- }
-
-//TODO Access annotation test
-// public void testGetAccessWithJavaAnnotationsProperty() throws Exception {
-// createTestEntityAnnotatedFieldPropertySpecified();
-// OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-//
-// assertEquals(AccessType.PROPERTY, ormPersistentType.getAccess());
-// assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
-// assertEquals(AccessType.PROPERTY, javaPersistentType.getSpecifiedAccess());
-//
-//
-// OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("id");
-// ormPersistentAttribute.makeSpecified();
-// assertEquals(AccessType.PROPERTY, ormPersistentType.getAccess());
-// assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
-// assertEquals(AccessType.PROPERTY, javaPersistentType.getSpecifiedAccess());
-//
-// ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-// assertEquals(AccessType.FIELD, ormPersistentType.getAccess());
-// assertEquals(AccessType.PROPERTY, javaPersistentType.getAccess());
-// }
-//
-// public void testVirtualAttributes() throws Exception {
-// createTestEntityAnnotatedFieldPropertySpecified();
-// OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-//
-// ListIterator<OrmPersistentAttribute> virtualAttributes = ormPersistentType.virtualAttributes();
-// OrmPersistentAttribute ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
-//
-//
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("name", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-//
-// ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-// virtualAttributes = ormPersistentType.virtualAttributes();
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-//
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("name", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-// }
-//
-// public void testVirtualAttributes2() throws Exception {
-// createTestEntityPropertySpecified();
-// OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-//
-// ListIterator<OrmPersistentAttribute> virtualAttributes = ormPersistentType.virtualAttributes();
-// OrmPersistentAttribute ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-//
-// ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-// virtualAttributes = ormPersistentType.virtualAttributes();
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-//
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("name", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-//
-// ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.FALSE);
-// virtualAttributes = ormPersistentType.virtualAttributes();
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-// }
-//
-// public void testVirtualAttributes3() throws Exception {
-// createTestEntityFieldSpecifiedPropertyAnnotated();
-// OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-//
-// ListIterator<OrmPersistentAttribute> virtualAttributes = ormPersistentType.virtualAttributes();
-// OrmPersistentAttribute ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("name", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.PROPERTY, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-//
-//
-// ormPersistentAttribute.makeSpecified();
-//
-// virtualAttributes = ormPersistentType.virtualAttributes();
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("id", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("name", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-//
-//
-// OrmPersistentAttribute specifiedPersistentAttribute = ormPersistentType.specifiedAttributes().next();
-// assertEquals("id", specifiedPersistentAttribute.getName());
-// assertEquals(AccessType.PROPERTY, specifiedPersistentAttribute.getSpecifiedAccess());
-//
-//
-// ormPersistentType.virtualAttributes().next().makeSpecified();
-// virtualAttributes = ormPersistentType.virtualAttributes();
-// ormPersistentAttribute = virtualAttributes.next();
-// assertEquals("name", ormPersistentAttribute.getName());
-// assertEquals(AccessType.FIELD, ormPersistentAttribute.getAccess());
-//
-// assertFalse(virtualAttributes.hasNext());
-// }
-//
-// public void testGetDefaultAccess() throws Exception {
-// createTestEntityPropertySpecified();
-// OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-// JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
-//
-// assertEquals(AccessType.PROPERTY, ormPersistentType.getDefaultAccess());
-//
-// javaPersistentType.setSpecifiedAccess(AccessType.FIELD);
-// assertEquals(AccessType.FIELD, ormPersistentType.getDefaultAccess());
-//
-// javaPersistentType.setSpecifiedAccess(AccessType.PROPERTY);
-// assertEquals(AccessType.PROPERTY, ormPersistentType.getDefaultAccess());
-//
-//
-// ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
-// assertEquals(AccessType.FIELD, ormPersistentType.getDefaultAccess());
-// }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmTransientMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmTransientMappingTests.java
deleted file mode 100644
index 23d282233d..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/EclipseLink1_1OrmTransientMappingTests.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.eclipselink.core.tests.internal.v1_1.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-
-@SuppressWarnings("nls")
-public class EclipseLink1_1OrmTransientMappingTests
- extends EclipseLink1_1OrmContextModelTestCase
-{
- public EclipseLink1_1OrmTransientMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithTransientMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.TRANSIENT);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@Transient").append(CR);
- }
- });
- }
-
- public void testCreateTransientMapping() throws Exception {
- createTestEntityWithTransientMapping();
- OrmPersistentType ormPersistentType =
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertTrue(persistentAttribute.isVirtual());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
-
- ormPersistentType.addSpecifiedAttribute(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, "id");
-
- persistentAttribute = ormPersistentType.getAttributeNamed("id");
- assertFalse(persistentAttribute.isVirtual());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMappingKey());
- assertEquals(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY, persistentAttribute.getMapping().getKey());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/JptEclipseLink1_1CoreOrmContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/JptEclipseLink1_1CoreOrmContextModelTests.java
deleted file mode 100644
index 896c42604c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_1/context/orm/JptEclipseLink1_1CoreOrmContextModelTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.v1_1.context.orm;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptEclipseLink1_1CoreOrmContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink1_1CoreOrmContextModelTests.class.getName());
-
- suite.addTestSuite(EclipseLink1_1OrmPersistentAttributeTests.class);
- suite.addTestSuite(EclipseLink1_1OrmPersistentTypeTests.class);
- suite.addTestSuite(EclipseLink1_1OrmTransientMappingTests.class);
-
- return suite;
- }
-
-
- private JptEclipseLink1_1CoreOrmContextModelTests() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2ContextModelTestCase.java
deleted file mode 100644
index 9aee7089df..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2ContextModelTestCase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v1_2.context;
-
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-public abstract class EclipseLink1_2ContextModelTestCase extends EclipseLinkContextModelTestCase
-{
- public static final String JPA_ANNOTATIONS_PACKAGE_NAME = "javax.persistence"; //$NON-NLS-1$
-
- protected EclipseLink1_2ContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, EclipseLinkPlatform.VERSION_1_2);
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2JpaProjectTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2JpaProjectTests.java
deleted file mode 100644
index 952962750f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/EclipseLink1_2JpaProjectTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v1_2.context;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.internal.operations.JpaFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v1_2.EclipseLink1_2;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public class EclipseLink1_2JpaProjectTests extends EclipseLink1_2ContextModelTestCase
-{
-
- public EclipseLink1_2JpaProjectTests(String name) {
- super(name);
- }
-
- public void testGetDefaultOrmXmlResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
- //add the orm.xml file with eclipselink 1.2 orm content type
- createDefaultOrmXmlFileWithEclipseLink1_2ContentType();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_2_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
-
- //add the orm.xml file with eclipselink orm content type
- createDefaultOrmXmlFileWithEclipseLinkContentType();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNull(resource);
-
-
- //add the orm.xml file this time with orm content type
- createDefaultOrmXmlFile();
- resource = this.getJpaProject().getDefaultOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE, resource.getContentType());
- assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
- }
-
- public void testGetDefaultEclipseLinkOrmXmlResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNull(resource);
-
- //add the eclipselink-orm.xml 1.2 file
- createDefaultEclipseLink1_2OrmXmlFile();
- resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_2_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/eclipselink-orm.xml", resource.getFile().getProjectRelativePath().toString());
-
-
- //delete the eclipselink-orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
- resource.delete(null);
- resource = this.getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- assertNull(resource);
- }
-
- private void createDefaultOrmXmlFile() throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.getDefaultOperation().execute(null, null);
- }
-
- private void createDefaultOrmXmlFileWithEclipseLinkContentType() throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.setProperty(JptFileCreationDataModelProperties.FILE_NAME,
- JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.lastSegment());
- config.getDefaultOperation().execute(null, null);
- }
-
- private void createDefaultOrmXmlFileWithEclipseLink1_2ContentType() throws Exception {
- createEclipseLink1_2OrmXmlFile(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.lastSegment());
- }
-
- private void createDefaultEclipseLink1_2OrmXmlFile() throws Exception {
- createEclipseLink1_2OrmXmlFile(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.lastSegment());
- }
-
- private void createEclipseLink1_2OrmXmlFile(String fileName) throws Exception {
- IDataModel config =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, fileName);
- config.setProperty(JpaFileCreationDataModelProperties.VERSION, EclipseLink1_2.SCHEMA_VERSION);
- config.getDefaultOperation().execute(null, null);
- }
-
- public void testGetMappingFileResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNull(resource);
-
- //add the eclipselink-orm.xml 1.2 file
- createDefaultEclipseLink1_2OrmXmlFile();
- resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_2_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/eclipselink-orm.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the eclipselink-orm.xml file and verify it is not returned from getMappingFileResource()
- resource.delete(null);
- resource = this.getJpaProject().getMappingFileXmlResource(JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH);
- assertNull(resource);
- }
-
- public void testGetDifferentlyNamedMappingFileResource() throws Exception {
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNull(resource);
-
- //create the orm2.xml file
- createEclipseLink1_2OrmXmlFile("orm2.xml");
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_2_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
-
- //delete the orm2.xml file and verify it is not returned from getMappingFileResource()
- resource.delete(null);
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNull(resource);
-
- //add the orm2.xml file back
- createEclipseLink1_2OrmXmlFile("orm2.xml");
- resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
- assertNotNull(resource);
- assertEquals(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_1_2_RESOURCE_TYPE, resource.getResourceType());
- assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/JptEclipseLink1_2CoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/JptEclipseLink1_2CoreContextModelTests.java
deleted file mode 100644
index 3adee587c8..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v1_2/context/JptEclipseLink1_2CoreContextModelTests.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.eclipselink.core.tests.internal.v1_2.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptEclipseLink1_2CoreContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink1_2CoreContextModelTests.class.getName());
- suite.addTestSuite(EclipseLink1_2JpaProjectTests.class);
- // suite.addTest(JptEclipseLink1_2CoreOrmContextModelTests.suite());
- return suite;
- }
-
- private JptEclipseLink1_2CoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/EclipseLink2_0ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/EclipseLink2_0ContextModelTestCase.java
deleted file mode 100644
index 81e169f5ef..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/EclipseLink2_0ContextModelTestCase.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context;
-
-import org.eclipse.jpt.jpa.core.JpaFacet;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLinkContextModelTestCase;
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-public abstract class EclipseLink2_0ContextModelTestCase extends EclipseLinkContextModelTestCase
-{
- protected EclipseLink2_0ContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_2_0.getVersionString());
- dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, EclipseLinkPlatform.VERSION_2_0);
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/JptEclipseLink2_0CoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/JptEclipseLink2_0CoreContextModelTests.java
deleted file mode 100644
index 8221ce7fd1..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/JptEclipseLink2_0CoreContextModelTests.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009 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.eclipselink.core.tests.internal.v2_0.context;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.java.JptEclipseLink2_0JavaContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.orm.JptEclipseLink2_0OrmContextModelTests;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.persistence.JptEclipseLink2_0CorePersistenceContextModelTests;
-
-/**
- * JptEclipseLink2_0CoreContextModelTests
- */
-public class JptEclipseLink2_0CoreContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink2_0CoreContextModelTests.class.getName());
-
- suite.addTest(JptEclipseLink2_0CorePersistenceContextModelTests.suite());
- suite.addTest(JptEclipseLink2_0JavaContextModelTests.suite());
- suite.addTest(JptEclipseLink2_0OrmContextModelTests.suite());
-
- return suite;
- }
-
- private JptEclipseLink2_0CoreContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaCollectionTableTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaCollectionTableTests.java
deleted file mode 100644
index e70de2afae..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaCollectionTableTests.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.jpa.core.jpa2.context.CollectionTable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCollectionTable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.CollectionTable2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-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.UniqueConstraintAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaCollectionTableTests extends EclipseLink2_0ContextModelTestCase
-{
- public EclipseLink2_0JavaCollectionTableTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithElementCollection() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ElementCollection").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidElementCollection() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ElementCollection").append(CR);
- sb.append(" private Collection<String> projects;").append(CR);
- }
- });
- }
-
-
- public void testUpdateSpecifiedName() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertNull(collectionTable.getSpecifiedName());
- assertNull(resourceCollectionTable);
-
-
- //set name in the resource model, verify context model updated
- attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- resourceCollectionTable.setName("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", collectionTable.getSpecifiedName());
- assertEquals("FOO", resourceCollectionTable.getName());
-
- //set name to null in the resource model
- resourceCollectionTable.setName(null);
- getJpaProject().synchronizeContextModel();
- assertNull(collectionTable.getSpecifiedName());
- assertNull(resourceCollectionTable.getName());
-
- resourceCollectionTable.setName("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", collectionTable.getSpecifiedName());
- assertEquals("FOO", resourceCollectionTable.getName());
-
- attributeResource.removeAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNull(collectionTable.getSpecifiedName());
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedName() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation resourceCollectionTable3 = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertNull(collectionTable.getSpecifiedName());
- assertNull(resourceCollectionTable3);
-
- //set name in the context model, verify resource model modified
- collectionTable.setSpecifiedName("foo");
- resourceCollectionTable3 = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- assertEquals("foo", collectionTable.getSpecifiedName());
- assertEquals("foo", resourceCollectionTable3.getName());
-
- //set name to null in the context model
- collectionTable.setSpecifiedName(null);
- assertNull(collectionTable.getSpecifiedName());
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testDefaultName() throws Exception {
- createTestEntityWithValidElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- assertEquals(TYPE_NAME + "_projects", collectionTable.getDefaultName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
-
- //add the collection table annotation, verify default collection table name is the same
- attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- assertEquals(TYPE_NAME + "_projects", collectionTable.getDefaultName());
- assertNotNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
-
- //set the entity name, verify default collection table name updates
- getJavaEntity().setSpecifiedName("Foo");
- assertEquals("Foo_projects", collectionTable.getDefaultName());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertNull(collectionTable.getSpecifiedSchema());
- assertNull(resourceCollectionTable);
-
-
- //set schema in the resource model, verify context model updated
- attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- resourceCollectionTable.setSchema("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", collectionTable.getSpecifiedSchema());
- assertEquals("FOO", resourceCollectionTable.getSchema());
-
- //set schema to null in the resource model
- resourceCollectionTable.setSchema(null);
- getJpaProject().synchronizeContextModel();
- assertNull(collectionTable.getSpecifiedSchema());
- assertNull(resourceCollectionTable.getSchema());
-
- resourceCollectionTable.setSchema("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", collectionTable.getSpecifiedSchema());
- assertEquals("FOO", resourceCollectionTable.getSchema());
-
- attributeResource.removeAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNull(collectionTable.getSpecifiedSchema());
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertNull(collectionTable.getSpecifiedSchema());
- assertNull(resourceCollectionTable);
-
- //set schema in the context model, verify resource model modified
- collectionTable.setSpecifiedSchema("foo");
- resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- assertEquals("foo", collectionTable.getSpecifiedSchema());
- assertEquals("foo", resourceCollectionTable.getSchema());
-
- //set schema to null in the context model
- collectionTable.setSpecifiedSchema(null);
- assertNull(collectionTable.getSpecifiedSchema());
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertNull(collectionTable.getSpecifiedCatalog());
- assertNull(resourceCollectionTable);
-
-
- //set catalog in the resource model, verify context model updated
- attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- resourceCollectionTable.setCatalog("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", collectionTable.getSpecifiedCatalog());
- assertEquals("FOO", resourceCollectionTable.getCatalog());
-
- //set catalog to null in the resource model
- resourceCollectionTable.setCatalog(null);
- getJpaProject().synchronizeContextModel();
- assertNull(collectionTable.getSpecifiedCatalog());
- assertNull(resourceCollectionTable.getCatalog());
-
- resourceCollectionTable.setCatalog("FOO");
- getJpaProject().synchronizeContextModel();
- assertEquals("FOO", collectionTable.getSpecifiedCatalog());
- assertEquals("FOO", resourceCollectionTable.getCatalog());
-
- attributeResource.removeAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertNull(collectionTable.getSpecifiedCatalog());
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertNull(collectionTable.getSpecifiedCatalog());
- assertNull(resourceCollectionTable);
-
- //set catalog in the context model, verify resource model modified
- collectionTable.setSpecifiedCatalog("foo");
- resourceCollectionTable = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- assertEquals("foo", collectionTable.getSpecifiedCatalog());
- assertEquals("foo", resourceCollectionTable.getCatalog());
-
- //set catalog to null in the context model
- collectionTable.setSpecifiedCatalog(null);
- assertNull(collectionTable.getSpecifiedCatalog());
- assertNull(attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
-
- JoinColumn joinColumn = collectionTable.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- CollectionTable2_0Annotation joinTableResource = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertEquals("FOO", joinTableResource.joinColumnAt(0).getName());
-
- JoinColumn joinColumn2 = collectionTable.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(1).getName());
-
- JoinColumn joinColumn3 = collectionTable.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.joinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(2).getName());
-
- ListIterator<JavaJoinColumn> joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- collectionTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- collectionTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- collectionTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- CollectionTable2_0Annotation joinTableResource = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- assertEquals(3, joinTableResource.joinColumnsSize());
-
- collectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(2, joinTableResource.joinColumnsSize());
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.joinColumnAt(1).getName());
-
- collectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(1, joinTableResource.joinColumnsSize());
- assertEquals("BAZ", joinTableResource.joinColumnAt(0).getName());
-
- collectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(0, joinTableResource.joinColumnsSize());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- collectionTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- collectionTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- collectionTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- CollectionTable2_0Annotation joinTableResource = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- assertEquals(3, joinTableResource.joinColumnsSize());
-
-
- collectionTable.moveSpecifiedJoinColumn(2, 0);
- ListIterator<JavaJoinColumn> joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAZ", joinTableResource.joinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(2).getName());
-
-
- collectionTable.moveSpecifiedJoinColumn(0, 1);
- joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", joinTableResource.joinColumnAt(0).getName());
- assertEquals("BAR", joinTableResource.joinColumnAt(1).getName());
- assertEquals("FOO", joinTableResource.joinColumnAt(2).getName());
- }
-
- public void testUpdateJoinColumns() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- CollectionTable2_0Annotation joinTableResource = (CollectionTable2_0Annotation) attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- joinTableResource.addJoinColumn(0);
- joinTableResource.addJoinColumn(1);
- joinTableResource.addJoinColumn(2);
-
- joinTableResource.joinColumnAt(0).setName("FOO");
- joinTableResource.joinColumnAt(1).setName("BAR");
- joinTableResource.joinColumnAt(2).setName("BAZ");
- getJpaProject().synchronizeContextModel();
-
- ListIterator<JavaJoinColumn> joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.moveJoinColumn(2, 0);
- getJpaProject().synchronizeContextModel();
- joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.moveJoinColumn(0, 1);
- getJpaProject().synchronizeContextModel();
- joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.removeJoinColumn(1);
- getJpaProject().synchronizeContextModel();
- joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.removeJoinColumn(1);
- getJpaProject().synchronizeContextModel();
- joinColumns = collectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- joinTableResource.removeJoinColumn(0);
- getJpaProject().synchronizeContextModel();
- assertFalse(collectionTable.specifiedJoinColumns().hasNext());
- }
-
- public void testGetDefaultJoinColumn() {
- //TODO
- }
-
- public void testSpecifiedJoinColumnsSize() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- assertEquals(0, collectionTable.specifiedJoinColumnsSize());
-
- collectionTable.addSpecifiedJoinColumn(0);
- assertEquals(1, collectionTable.specifiedJoinColumnsSize());
-
- collectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(0, collectionTable.specifiedJoinColumnsSize());
- }
-
- public void testUniqueConstraints() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- ListIterator<JavaUniqueConstraint> uniqueConstraints = collectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "bar");
- getJpaProject().synchronizeContextModel();
-
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("foo", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
-
- assertEquals(0, collectionTable.uniqueConstraintsSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- joinTableAnnotation.addUniqueConstraint(0).addColumnName(0, "foo");
- joinTableAnnotation.addUniqueConstraint(1).addColumnName(0, "bar");
-
- getJpaProject().synchronizeContextModel();
-
- assertEquals(2, collectionTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
- collectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- collectionTable.addUniqueConstraint(0).addColumnName(0, "BAR");
- collectionTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = joinTableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- CollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
- collectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- collectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- collectionTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
- ListIterator<UniqueConstraintAnnotation> uniqueConstraints = joinTableAnnotation.uniqueConstraints();
-
- assertEquals("BAZ", uniqueConstraints.next().columnNames().next());
- assertEquals("FOO", uniqueConstraints.next().columnNames().next());
- assertEquals("BAR", uniqueConstraints.next().columnNames().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
- collectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- collectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- collectionTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertEquals(3, joinTableAnnotation.uniqueConstraintsSize());
-
- collectionTable.removeUniqueConstraint(1);
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- Iterator<JavaUniqueConstraint> uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- collectionTable.removeUniqueConstraint(1);
- uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- assertFalse(uniqueConstraintAnnotations.hasNext());
-
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- collectionTable.removeUniqueConstraint(0);
- uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertFalse(uniqueConstraintAnnotations.hasNext());
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
- collectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- collectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- collectionTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.getAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- assertEquals(3, joinTableAnnotation.uniqueConstraintsSize());
-
-
- collectionTable.moveUniqueConstraint(2, 0);
- ListIterator<JavaUniqueConstraint> uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
-
- ListIterator<UniqueConstraintAnnotation> uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
-
-
- collectionTable.moveUniqueConstraint(0, 1);
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
-
- uniqueConstraintAnnotations = joinTableAnnotation.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("BAR", uniqueConstraintAnnotations.next().columnNames().next());
- assertEquals("FOO", uniqueConstraintAnnotations.next().columnNames().next());
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- createTestEntityWithElementCollection();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 collectionTable = elementCollectionMapping.getCollectionTable();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- CollectionTable2_0Annotation joinTableAnnotation = (CollectionTable2_0Annotation) attributeResource.addAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME);
-
- joinTableAnnotation.addUniqueConstraint(0).addColumnName("FOO");
- joinTableAnnotation.addUniqueConstraint(1).addColumnName("BAR");
- joinTableAnnotation.addUniqueConstraint(2).addColumnName("BAZ");
- getJpaProject().synchronizeContextModel();
-
-
- ListIterator<JavaUniqueConstraint> uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.moveUniqueConstraint(2, 0);
- getJpaProject().synchronizeContextModel();
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.moveUniqueConstraint(0, 1);
- getJpaProject().synchronizeContextModel();
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.removeUniqueConstraint(1);
- getJpaProject().synchronizeContextModel();
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.removeUniqueConstraint(1);
- getJpaProject().synchronizeContextModel();
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- joinTableAnnotation.removeUniqueConstraint(0);
- getJpaProject().synchronizeContextModel();
- uniqueConstraints = collectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
deleted file mode 100644
index 261b72f53c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaElementCollectionMappingTests.java
+++ /dev/null
@@ -1,2077 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.TransientMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.VersionMapping;
-import org.eclipse.jpt.jpa.core.context.VirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
-import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
-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.ManyToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaElementCollectionMappingTests
- extends EclipseLink2_0ContextModelTestCase
-{
- public static final String EMBEDDABLE_TYPE_NAME = "Address";
- public static final String FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME = PACKAGE_NAME + "." + EMBEDDABLE_TYPE_NAME;
-
- private ICompilationUnit createTestEntityWithElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ElementCollection").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithGenericEmbeddableElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithGenericBasicElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection<String> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithNonGenericElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidGenericMapElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Map<Integer, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private void createTestTargetEmbeddableAddress() 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("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDED);
- sb.append(";");
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").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 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 name;").append(CR);
- sb.append(CR);
- sb.append(" private String abbr;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Map<Address, PropertyInfo> parcels;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private void createTestEmbeddablePropertyInfo() 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("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDED);
- sb.append(";");
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("PropertyInfo").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private Integer parcelNumber;").append(CR);
- sb.append(CR);
- sb.append(" private Integer size;").append(CR);
- sb.append(CR);
- sb.append(" private java.math.BigDecimal tax;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PropertyInfo.java", sourceWriter);
- }
-
- private void createSelfReferentialElementCollection() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ELEMENT_COLLECTION);
- sb.append(";");
- sb.append(CR).append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Foo").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.List<Foo> elementCollection;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Foo.java", sourceWriter);
- }
-
- public EclipseLink2_0JavaElementCollectionMappingTests(String name) {
- super(name);
- }
-
- public void testMorphToBasicMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof BasicMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(BasicAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToDefault() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testMorphToVersionMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof VersionMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(VersionAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToIdMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof IdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(IdAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(EmbeddedAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToTransientMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof TransientMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(TransientAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof OneToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(OneToManyAnnotation.ANNOTATION_NAME));
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
-
- persistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertTrue(persistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertFalse(persistentAttribute.getMapping().isDefault());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertNull(attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME));
- assertNotNull(attributeResource.getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME));
- }
-
- public void testUpdateSpecifiedTargetEntity() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- ElementCollection2_0Annotation elementCollectionAnnotation = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
-
- assertNull(elementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollectionAnnotation.getTargetClass());
-
- //set target class in the resource model, verify context model updated
- elementCollectionAnnotation.setTargetClass("newTargetClass");
- this.getJpaProject().synchronizeContextModel();
- assertEquals("newTargetClass", elementCollectionMapping.getSpecifiedTargetClass());
- assertEquals("newTargetClass", elementCollectionAnnotation.getTargetClass());
-
- //set target class to null in the resource model
- elementCollectionAnnotation.setTargetClass(null);
- this.getJpaProject().synchronizeContextModel();
- assertNull(elementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollectionAnnotation.getTargetClass());
- }
-
- public void testModifySpecifiedTargetClass() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
-
- assertNull(elementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollection.getTargetClass());
-
- //set target class in the context model, verify resource model updated
- elementCollectionMapping.setSpecifiedTargetClass("newTargetClass");
- assertEquals("newTargetClass", elementCollectionMapping.getSpecifiedTargetClass());
- assertEquals("newTargetClass", elementCollection.getTargetClass());
-
- //set target class to null in the context model
- elementCollectionMapping.setSpecifiedTargetClass(null);
- assertNull(elementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollection.getTargetClass());
- }
-
- public void testDefaultTargetClass() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- //targetEntity not in the persistence unit, default still set, handled by validation
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
-
- //add targetEntity to the persistence unit
- addXmlClassRef(PACKAGE_NAME + ".Address");
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
-
- //test default still the same when specified target entity it set
- elementCollectionMapping.setSpecifiedTargetClass("foo");
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- JavaPersistentType addressPersistentType = addressClassRef.getJavaPersistentType();
-
- //test target is not an Embeddable, default target entity still exists, this case handled with validation
- addressPersistentType.setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
- }
-
- public void testDefaultTargetClassNonGenericCollection() throws Exception {
- createTestEntityWithNonGenericElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertNull(elementCollectionMapping.getDefaultTargetClass());
- }
-
- public void testDefaultTargetClassGenericCollection() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
- }
-
- public void testDefaultTargetClassNonGenericMap() throws Exception {
- createTestEntityWithValidNonGenericMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertNull(elementCollectionMapping.getDefaultTargetClass());
- }
-
- public void testDefaultTargetClassGenericMap() throws Exception {
- createTestEntityWithValidGenericMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getDefaultTargetClass());
- }
-
- public void testTargetClass() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getTargetClass());
-
- elementCollectionMapping.setSpecifiedTargetClass("foo");
- assertEquals("foo", elementCollectionMapping.getTargetClass());
-
- elementCollectionMapping.setSpecifiedTargetClass(null);
- assertEquals(PACKAGE_NAME + ".Address", elementCollectionMapping.getTargetClass());
- }
-
- protected Embeddable getResolvedTargetEmbeddable(ElementCollectionMapping2_0 mapping) {
- return (Embeddable) ReflectionTools.executeMethod(mapping, "getResolvedTargetEmbeddable");
- }
-
- public void testResolvedTargetEmbeddable() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- //target embeddable not in the persistence unit
- assertNull(this.getResolvedTargetEmbeddable(elementCollectionMapping));
-
- //add target embeddable to the persistence unit, now target embeddable should resolve
- createTestTargetEmbeddableAddress();
- addXmlClassRef(PACKAGE_NAME + ".Address");
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- ClassRef addressClassRef = classRefs.next();
- TypeMapping addressTypeMapping = addressClassRef.getJavaPersistentType().getMapping();
- assertEquals(addressTypeMapping, this.getResolvedTargetEmbeddable(elementCollectionMapping));
-
- //test default still the same when specified target entity it set
- elementCollectionMapping.setSpecifiedTargetClass("foo");
- assertNull(this.getResolvedTargetEmbeddable(elementCollectionMapping));
-
-
- elementCollectionMapping.setSpecifiedTargetClass(PACKAGE_NAME + ".Address");
- assertEquals(addressTypeMapping, this.getResolvedTargetEmbeddable(elementCollectionMapping));
-
-
- elementCollectionMapping.setSpecifiedTargetClass(null);
- assertEquals(addressTypeMapping, this.getResolvedTargetEmbeddable(elementCollectionMapping));
- }
-
- public void testResolvedTargetEmbeddableWithBasicType() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- //target is a basic type, so resolved target embeddable is null
- assertNull(this.getResolvedTargetEmbeddable(elementCollectionMapping));
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
-
- assertNull(elementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
-
- //set fetch in the resource model, verify context model updated
- elementCollection.setFetch(org.eclipse.jpt.jpa.core.resource.java.FetchType.EAGER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(FetchType.EAGER, elementCollectionMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.FetchType.EAGER, elementCollection.getFetch());
-
- elementCollection.setFetch(org.eclipse.jpt.jpa.core.resource.java.FetchType.LAZY);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(FetchType.LAZY, elementCollectionMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.FetchType.LAZY, elementCollection.getFetch());
-
- //set fetch to null in the resource model
- elementCollection.setFetch(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(elementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- ElementCollection2_0Annotation elementCollection = (ElementCollection2_0Annotation) attributeResource.getAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
-
- assertNull(elementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
-
- //set fetch in the context model, verify resource model updated
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(FetchType.EAGER, elementCollectionMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.FetchType.EAGER, elementCollection.getFetch());
-
- elementCollectionMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(FetchType.LAZY, elementCollectionMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.jpa.core.resource.java.FetchType.LAZY, elementCollection.getFetch());
-
- //set fetch to null in the context model
- elementCollectionMapping.setSpecifiedFetch(null);
- assertNull(elementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
- }
-
- public void testGetValueTypeEmbeddable() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
- }
-
- public void testGetValueTypeNone() throws Exception {
- createTestEntityWithNonGenericElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.NO_TYPE, elementCollectionMapping.getValueType());
-
- elementCollectionMapping.setSpecifiedTargetClass("Address");
- assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
- }
-
- public void testGetValueTypeBasic() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
- }
-
- public void testUpdateMapKey() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKey());
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNotNull(mapKey);
-
- //set mapKey name in the resource model, verify context model updated
- mapKey.setName("myMapKey");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("myMapKey", elementCollectionMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey name to null in the resource model
- mapKey.setName(null);
- getJpaProject().synchronizeContextModel();
- assertNull(elementCollectionMapping.getSpecifiedMapKey());
- assertNull(mapKey.getName());
-
- mapKey.setName("myMapKey");
- attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(elementCollectionMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKey() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- elementCollectionMapping.setSpecifiedMapKey("myMapKey");
- MapKeyAnnotation mapKeyAnnotation = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertEquals("myMapKey", elementCollectionMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", mapKeyAnnotation.getName());
-
- //set mapKey to null in the context model
- elementCollectionMapping.setSpecifiedMapKey(null);
- assertNull(elementCollectionMapping.getSpecifiedMapKey());
- mapKeyAnnotation = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(mapKeyAnnotation.getName());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidGenericMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping2_0 = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- Iterator<String> mapKeyNames =
- elementCollectionMapping2_0.candidateMapKeyNames();
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping2_0 = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- Iterator<String> mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- elementCollectionMapping2_0.setSpecifiedTargetClass("Address");
- mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- elementCollectionMapping2_0.setSpecifiedTargetClass("String");
- mapKeyNames = elementCollectionMapping2_0.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
- }
-
- public void testUpdateMapKeyClass() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
- MapKeyClass2_0Annotation mapKeyClassAnnotation = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertNotNull(mapKeyClassAnnotation);
-
- //set mapKey name in the resource model, verify context model updated
- mapKeyClassAnnotation.setValue("myMapKeyClass");
- this.getJpaProject().synchronizeContextModel();
- assertEquals("myMapKeyClass", elementCollectionMapping.getSpecifiedMapKeyClass());
- assertEquals("myMapKeyClass", mapKeyClassAnnotation.getValue());
-
- //set mapKey name to null in the resource model
- mapKeyClassAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(mapKeyClassAnnotation.getValue());
-
- mapKeyClassAnnotation.setValue("myMapKeyClass");
- attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKeyClass() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- elementCollectionMapping.setSpecifiedMapKeyClass("String");
- MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertEquals("String", elementCollectionMapping.getSpecifiedMapKeyClass());
- assertEquals("String", mapKeyClass.getValue());
-
- //set mapKey to null in the context model
- elementCollectionMapping.setSpecifiedMapKeyClass(null);
- assertNull(elementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testDefaultMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals("java.lang.Integer", elementCollectionMapping.getDefaultMapKeyClass());
-
- //test default still the same when specified target entity it set
- elementCollectionMapping.setSpecifiedMapKeyClass("foo");
- assertEquals("java.lang.Integer", elementCollectionMapping.getDefaultMapKeyClass());
- }
-
- public void testDefaultMapKeyClassCollectionType() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertNull(elementCollectionMapping.getDefaultMapKeyClass());
- }
-
- public void testMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertEquals("java.lang.Integer", elementCollectionMapping.getMapKeyClass());
-
- elementCollectionMapping.setSpecifiedMapKeyClass("foo");
- assertEquals("foo", elementCollectionMapping.getMapKeyClass());
-
- elementCollectionMapping.setSpecifiedMapKeyClass(null);
- assertEquals("java.lang.Integer", elementCollectionMapping.getMapKeyClass());
- }
-
- public void testOrderColumnDefaults() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- Orderable2_0 orderable = ((Orderable2_0) elementCollectionMapping.getOrderable());
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- orderable.setOrderColumnOrdering(true);
- OrderColumn2_0 orderColumn = orderable.getOrderColumn();
- assertEquals(true, orderable.isOrderColumnOrdering());
- assertEquals(null, orderColumn.getSpecifiedName());
- assertEquals("addresses_ORDER", orderColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_addresses", orderColumn.getTable());
-
- orderColumn.setSpecifiedName("FOO");
- assertEquals("FOO", orderColumn.getSpecifiedName());
- assertEquals("addresses_ORDER", orderColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_addresses", orderColumn.getTable());
- }
-
- public void testGetValueColumn() throws Exception {
- createTestEntityWithElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertNull(elementCollectionMapping.getValueColumn().getSpecifiedName());
- assertEquals("id", elementCollectionMapping.getValueColumn().getName());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- ColumnAnnotation column = (ColumnAnnotation) attributeResource.addAnnotation(JPA.COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", elementCollectionMapping.getValueColumn().getSpecifiedName());
- assertEquals("foo", elementCollectionMapping.getValueColumn().getName());
- assertEquals("id", elementCollectionMapping.getValueColumn().getDefaultName());
- }
-
- public void testSpecifiedAttributeOverrides() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- JavaAttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
-
- ListIterator<JavaAttributeOverride> specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
-
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAZ");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- }
-
- public void testVirtualAttributeOverrides() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertEquals("addresses", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
- ReadOnlyAttributeOverride defaultAttributeOverride = attributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_addresses", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- Embeddable embeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping cityMapping = (BasicMapping) embeddable.getPersistentType().getAttributeNamed("city").getMapping();
- cityMapping.getColumn().setSpecifiedName("FOO");
- cityMapping.getColumn().setSpecifiedTable("BAR");
- cityMapping.getColumn().setColumnDefinition("COLUMN_DEF");
- cityMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- cityMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- cityMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- cityMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- assertEquals("addresses", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
- defaultAttributeOverride = attributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("FOO", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR", defaultAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEF", defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(false, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(5, defaultAttributeOverride.getColumn().getLength());
- assertEquals(6, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(7, defaultAttributeOverride.getColumn().getScale());
-
- cityMapping.getColumn().setSpecifiedName(null);
- cityMapping.getColumn().setSpecifiedTable(null);
- cityMapping.getColumn().setColumnDefinition(null);
- cityMapping.getColumn().setSpecifiedInsertable(null);
- cityMapping.getColumn().setSpecifiedUpdatable(null);
- cityMapping.getColumn().setSpecifiedUnique(null);
- cityMapping.getColumn().setSpecifiedNullable(null);
- cityMapping.getColumn().setSpecifiedLength(null);
- cityMapping.getColumn().setSpecifiedPrecision(null);
- cityMapping.getColumn().setSpecifiedScale(null);
- defaultAttributeOverride = attributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_addresses", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- assertEquals(0, attributeOverrideContainer.specifiedOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(2, attributeOverrideContainer.specifiedOverridesSize());
- }
-
- public void testAttributeOverridesSize() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- assertEquals(4, attributeOverrideContainer.overridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(6, attributeOverrideContainer.overridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- getJpaProject().synchronizeContextModel();
- assertEquals(6, attributeOverrideContainer.overridesSize());
- }
-
- public void testVirtualAttributeOverridesSize() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("state.name");
- getJpaProject().synchronizeContextModel();
- assertEquals(2, attributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- attributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- attributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- attributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- assertEquals("city", attributeOverrideContainer.virtualOverrides().next().getName());
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
-
- attributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrides.hasNext());
-
- Iterator<VirtualAttributeOverride> virtualAttributeOverrides = (Iterator<VirtualAttributeOverride>) attributeOverrideContainer.virtualOverrides();
- assertEquals("city", virtualAttributeOverrides.next().getName());
- assertEquals("state.name", virtualAttributeOverrides.next().getName());
- assertEquals("state.abbr", virtualAttributeOverrides.next().getName());
- assertEquals("zip", virtualAttributeOverrides.next().getName());
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testAttributeOverrideSetVirtual2() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- ListIterator<VirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) attributeOverrideContainer.virtualOverrides();
- virtualAttributeOverrides.next();
- virtualAttributeOverrides.next().convertToSpecified();
- attributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- attributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- attributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testNestedVirtualAttributeOverrides() throws Exception {
- createTestEntityWithGenericEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ListIterator<ClassRef> specifiedClassRefs = getPersistenceUnit().specifiedClassRefs();
- PersistentType persistentType = specifiedClassRefs.next().getJavaPersistentType();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentType.getAttributeNamed("addresses").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
-
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<VirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) attributeOverrideContainer.virtualOverrides();
- ReadOnlyAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("city", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("state.name", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("state.abbr", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("zip", virtualAttributeOverride.getName());
- assertEquals(false, virtualAttributeOverrides.hasNext());
-
-
- PersistentType addressPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- EmbeddedMapping nestedEmbeddedMapping = (EmbeddedMapping) addressPersistentType.getAttributeNamed("state").getMapping();
- AttributeOverrideContainer nestedAttributeOverrideContainer = nestedEmbeddedMapping.getAttributeOverrideContainer();
- assertEquals(2, nestedAttributeOverrideContainer.virtualOverridesSize());
- virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) nestedAttributeOverrideContainer.virtualOverrides();
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("abbr", virtualAttributeOverride.getName());
-
- PersistentType statePersistentType = specifiedClassRefs.next().getJavaPersistentType();
- BasicMapping abbrMapping = (BasicMapping) statePersistentType.getAttributeNamed("abbr").getMapping();
- abbrMapping.getColumn().setSpecifiedName("BLAH");
- abbrMapping.getColumn().setSpecifiedTable("BLAH_TABLE");
- abbrMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- abbrMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- abbrMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- abbrMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- abbrMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- abbrMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- abbrMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- abbrMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- //check the nested embedded (Address.state) attribute override to verify it is getting settings from the specified column on State.abbr
- virtualAttributeOverride = ((EmbeddedMapping) addressPersistentType.getAttributeNamed("state").getMapping()).getAttributeOverrideContainer().getOverrideNamed("abbr");
- assertEquals("abbr", virtualAttributeOverride.getName());
- assertEquals("BLAH", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(false, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(5, virtualAttributeOverride.getColumn().getLength());
- assertEquals(6, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(7, virtualAttributeOverride.getColumn().getScale());
- }
-
- public void testGetMapKeyColumn() throws Exception {
- createTestEntityWithValidGenericMapElementCollectionMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) persistentAttribute.getMapping();
-
- assertNull(elementCollectionMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("addresses_KEY", elementCollectionMapping.getMapKeyColumn().getName());
- assertEquals(TYPE_NAME + "_addresses", elementCollectionMapping.getMapKeyColumn().getTable());//collection table name
-
- elementCollectionMapping.getCollectionTable().setSpecifiedName("MY_COLLECTION_TABLE");
- assertEquals("MY_COLLECTION_TABLE", elementCollectionMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", elementCollectionMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", elementCollectionMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", elementCollectionMapping.getMapKeyColumn().getDefaultName());
- }
-
- public void testMapKeyValueSpecifiedAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
-
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
-
- ListIterator<JavaAttributeOverride> specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
-
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.BAR");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAZ");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
- ListIterator<JavaAttributeOverride> specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BLAH");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
- }
-
- public void testMapKeyValueVirtualAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- AttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertEquals("parcels", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- ReadOnlyAttributeOverride defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_parcels", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- Embeddable addressEmbeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping cityMapping = (BasicMapping) addressEmbeddable.getPersistentType().getAttributeNamed("city").getMapping();
- cityMapping.getColumn().setSpecifiedName("FOO");
- cityMapping.getColumn().setSpecifiedTable("BAR");
- cityMapping.getColumn().setColumnDefinition("COLUMN_DEF");
- cityMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- cityMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- cityMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- cityMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- assertEquals("parcels", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("FOO", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR", defaultAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEF", defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(false, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(5, defaultAttributeOverride.getColumn().getLength());
- assertEquals(6, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(7, defaultAttributeOverride.getColumn().getScale());
-
- cityMapping.getColumn().setSpecifiedName(null);
- cityMapping.getColumn().setSpecifiedTable(null);
- cityMapping.getColumn().setColumnDefinition(null);
- cityMapping.getColumn().setSpecifiedInsertable(null);
- cityMapping.getColumn().setSpecifiedUpdatable(null);
- cityMapping.getColumn().setSpecifiedUnique(null);
- cityMapping.getColumn().setSpecifiedNullable(null);
- cityMapping.getColumn().setSpecifiedLength(null);
- cityMapping.getColumn().setSpecifiedPrecision(null);
- cityMapping.getColumn().setSpecifiedScale(null);
- defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_parcels", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("key.city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
-
-
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
- defaultAttributeOverride = attributeOverrideContainer.virtualOverrides().next();
- assertEquals("parcelNumber", defaultAttributeOverride.getName());
- assertEquals("parcelNumber", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_parcels", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
-
- classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- classRefs.next();
- Embeddable propertyInfoEmbeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping parcelNumberMapping = (BasicMapping) propertyInfoEmbeddable.getPersistentType().getAttributeNamed("parcelNumber").getMapping();
- parcelNumberMapping.getColumn().setSpecifiedName("FOO1");
- parcelNumberMapping.getColumn().setSpecifiedTable("BAR1");
- parcelNumberMapping.getColumn().setColumnDefinition("COLUMN_DEF1");
- parcelNumberMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- parcelNumberMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- parcelNumberMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- parcelNumberMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- parcelNumberMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- parcelNumberMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- parcelNumberMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- assertEquals("parcels", attributeResource.getName());
-
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
- defaultAttributeOverride = attributeOverrideContainer.virtualOverrides().next();
- assertEquals("parcelNumber", defaultAttributeOverride.getName());
- assertEquals("FOO1", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR1", defaultAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEF1", defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(false, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(5, defaultAttributeOverride.getColumn().getLength());
- assertEquals(6, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(7, defaultAttributeOverride.getColumn().getScale());
-
- parcelNumberMapping.getColumn().setSpecifiedName(null);
- parcelNumberMapping.getColumn().setSpecifiedTable(null);
- parcelNumberMapping.getColumn().setColumnDefinition(null);
- parcelNumberMapping.getColumn().setSpecifiedInsertable(null);
- parcelNumberMapping.getColumn().setSpecifiedUpdatable(null);
- parcelNumberMapping.getColumn().setSpecifiedUnique(null);
- parcelNumberMapping.getColumn().setSpecifiedNullable(null);
- parcelNumberMapping.getColumn().setSpecifiedLength(null);
- parcelNumberMapping.getColumn().setSpecifiedPrecision(null);
- parcelNumberMapping.getColumn().setSpecifiedScale(null);
- defaultAttributeOverride = attributeOverrideContainer.virtualOverrides().next();
- assertEquals("parcelNumber", defaultAttributeOverride.getName());
- assertEquals("parcelNumber", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_parcels", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
- annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("value.parcelNumber");
- getJpaProject().synchronizeContextModel();
- assertEquals(2, attributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testMapKeyValueSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- AttributeOverrideContainer valueAttributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- AttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(0, valueAttributeOverrideContainer.specifiedOverridesSize());
- assertEquals(0, mapKeyAttributeOverrideContainer.specifiedOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.FOO2");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(2, valueAttributeOverrideContainer.specifiedOverridesSize());
- assertEquals(1, mapKeyAttributeOverrideContainer.specifiedOverridesSize());
- }
-
- public void testMapKeyValueAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- AttributeOverrideContainer valueAttributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- AttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(4, mapKeyAttributeOverrideContainer.overridesSize());
- assertEquals(3, valueAttributeOverrideContainer.overridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.FOO2");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(5, mapKeyAttributeOverrideContainer.overridesSize());
- assertEquals(5, valueAttributeOverrideContainer.overridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- getJpaProject().synchronizeContextModel();
- assertEquals(5, mapKeyAttributeOverrideContainer.overridesSize());
- assertEquals(6, valueAttributeOverrideContainer.overridesSize());
- }
-
- public void testMapKeyValueVirtualAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- AttributeOverrideContainer valueAttributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- AttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- assertEquals(3, valueAttributeOverrideContainer.virtualOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- assertEquals(3, valueAttributeOverrideContainer.virtualOverridesSize());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.city");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.parcelNumber");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- assertEquals(2, valueAttributeOverrideContainer.virtualOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.state.name");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("size");
- getJpaProject().synchronizeContextModel();
- assertEquals(2, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- assertEquals(1, valueAttributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testMapKeyValueAttributeOverrideSetVirtual() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- AttributeOverrideContainer valueAttributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- AttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
- valueAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- valueAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("value.parcelNumber", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("value.size", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- valueAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- mapKeyAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("value.size", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- assertEquals("parcelNumber", valueAttributeOverrideContainer.virtualOverrides().next().getName());
- assertEquals(2, valueAttributeOverrideContainer.virtualOverridesSize());
- assertEquals("city", mapKeyAttributeOverrideContainer.virtualOverrides().next().getName());
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
- valueAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- mapKeyAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrides.hasNext());
-
- Iterator<VirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) valueAttributeOverrideContainer.virtualOverrides();
- assertEquals("parcelNumber", virtualAttributeOverrides.next().getName());
- assertEquals("size", virtualAttributeOverrides.next().getName());
- assertEquals("tax", virtualAttributeOverrides.next().getName());
- assertEquals(3, valueAttributeOverrideContainer.virtualOverridesSize());
-
- virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) mapKeyAttributeOverrideContainer.virtualOverrides();
- assertEquals("city", virtualAttributeOverrides.next().getName());
- assertEquals("state.name", virtualAttributeOverrides.next().getName());
- assertEquals("state.abbr", virtualAttributeOverrides.next().getName());
- assertEquals("zip", virtualAttributeOverrides.next().getName());
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
-
- public void testMapKeyValueMoveSpecifiedAttributeOverride() throws Exception {
- createTestEntityWithEmbeddableKeyAndValueElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
- createTestEmbeddablePropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_EMBEDDABLE_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- AttributeOverrideContainer valueAttributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- AttributeOverrideContainer mapKeyAttributeOverrideContainer = elementCollectionMapping.getMapKeyAttributeOverrideContainer();
- valueAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- valueAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- ListIterator<AttributeOverride> specifiedOverrides = (ListIterator<AttributeOverride>) valueAttributeOverrideContainer.specifiedOverrides();
- assertEquals("parcelNumber", specifiedOverrides.next().getName());
- assertEquals("size", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
- specifiedOverrides = (ListIterator<AttributeOverride>) mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("city", specifiedOverrides.next().getName());
- assertEquals("state.name", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("value.size", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("value.parcelNumber", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- specifiedOverrides = (ListIterator<AttributeOverride>) valueAttributeOverrideContainer.specifiedOverrides();
- assertEquals("size", specifiedOverrides.next().getName());
- assertEquals("parcelNumber", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
- specifiedOverrides = (ListIterator<AttributeOverride>) mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("city", specifiedOverrides.next().getName());
- assertEquals("state.name", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
-
- attributeResource.moveAnnotation(3, 2, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("value.size", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("value.parcelNumber", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.state.name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- specifiedOverrides = (ListIterator<AttributeOverride>) valueAttributeOverrideContainer.specifiedOverrides();
- assertEquals("size", specifiedOverrides.next().getName());
- assertEquals("parcelNumber", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
- specifiedOverrides = (ListIterator<AttributeOverride>) mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("state.name", specifiedOverrides.next().getName());
- assertEquals("city", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
- }
-
- public void testSelfReferentialElementCollection() throws Exception {
- createSelfReferentialElementCollection();
- addXmlClassRef(PACKAGE_NAME + ".Foo");
-
- //If there is a StackOverflowError you will not be able to get the mapping
- JavaElementCollectionMapping2_0 elementCollectionMapping = (JavaElementCollectionMapping2_0) getJavaPersistentType().getAttributeNamed("elementCollection").getMapping();
- assertFalse(elementCollectionMapping.allOverridableAttributeMappingNames().hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaEntityTests.java
deleted file mode 100644
index 5325595b5f..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaEntityTests.java
+++ /dev/null
@@ -1,1813 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AssociationOverride;
-import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.InheritanceType;
-import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.VirtualAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.VirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
-import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.Cacheable2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AssociationOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkMappingKeys;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaEntityTests extends EclipseLink2_0ContextModelTestCase
-{
- protected static final String SUB_TYPE_NAME = "AnnotationTestTypeChild";
- protected static final String FULLY_QUALIFIED_SUB_TYPE_NAME = PACKAGE_NAME + "." + SUB_TYPE_NAME;
-
-
- public EclipseLink2_0JavaEntityTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntity() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ONE_TO_ONE, JPA.MANY_TO_ONE, JPA.ONE_TO_MANY, JPA.MANY_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("private String foo;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToOne");
- sb.append(CR);
- sb.append(" private int address2;").append(CR);
- sb.append(CR);
- sb.append(" @OneToMany");
- sb.append(CR);
- sb.append(" private int address3;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToMany");
- sb.append(CR);
- sb.append(" private int address4;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private ICompilationUnit createTestAbstractEntityTablePerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.INHERITANCE, JPA.INHERITANCE_TYPE, JPA.ONE_TO_ONE, JPA.MANY_TO_ONE, JPA.ONE_TO_MANY, JPA.MANY_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)");
- sb.append("abstract");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("private String foo;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToOne");
- sb.append(CR);
- sb.append(" private int address2;").append(CR);
- sb.append(CR);
- sb.append(" @OneToMany");
- sb.append(CR);
- sb.append(" private int address3;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToMany");
- sb.append(CR);
- sb.append(" private int address4;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private void createTestSubType() 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("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- private void createTestMappedSuperclassCustomer() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.MAPPED_SUPERCLASS);
- 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(CR);
- sb.append("@MappedSuperclass");
- sb.append(CR);
- sb.append("public class ").append("Customer ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String id;").append(CR);
- sb.append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @Embedded").append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Customer.java", sourceWriter);
- }
- private void createTestMappedSuperclassCustomerWithElementCollection() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.MAPPED_SUPERCLASS);
- 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(CR);
- sb.append("@MappedSuperclass");
- sb.append(CR);
- sb.append("public class ").append("Customer ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String id;").append(CR);
- sb.append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Customer.java", sourceWriter);
- }
-
- private void createTestEntityLongTimeCustomer() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- 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(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("LongTimeCustomer extends Customer ");
- sb.append("{}");
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "LongTimeCustomer.java", sourceWriter);
- }
-
-
- private void createTestEmbeddableAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDED);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ONE_TO_ONE);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private String street;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne").append(CR);
- sb.append(" private State state;").append(CR);
- sb.append(CR);
- sb.append(" @Embedded").append(CR);
- sb.append(" private ZipCode zipCode;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- private void createTestEmbeddableZipCode() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("ZipCode").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private String zip;").append(CR);
- sb.append(CR);
- sb.append(" private String plusfour;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "ZipCode.java", sourceWriter);
- }
-
- public void testAttributeMappingKeyAllowed() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Entity entity = (Entity) getJavaPersistentType().getMapping();
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.BASIC_COLLECTION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.TRANSFORMATION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(EclipseLinkMappingKeys.VARIABLE_ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- }
-
- public void testOverridableAttributes() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributes = getJavaEntity().overridableAttributeNames();
- assertFalse(overridableAttributes.hasNext());
-
-
- getJavaEntity().setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
-
- overridableAttributes = getJavaEntity().overridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testOverridableAttributeNames() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributeNames = getJavaEntity().overridableAttributeNames();
- assertFalse(overridableAttributeNames.hasNext());
-
-
- getJavaEntity().setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
-
- overridableAttributeNames = getJavaEntity().overridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testAllOverridableAttributes() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributes = getJavaEntity().allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAttributesTablePerClass() throws Exception {
- createTestAbstractEntityTablePerClass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributes = getJavaEntity().allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
-
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity abstractEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
- overridableAttributes = abstractEntity.allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAssociationsTablePerClass() throws Exception {
- createTestAbstractEntityTablePerClass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociations = getJavaEntity().allOverridableAssociationNames();
- assertEquals("address", overridableAssociations.next());
- assertEquals("address2", overridableAssociations.next());
- assertEquals("address3", overridableAssociations.next());
- assertEquals("address4", overridableAssociations.next());
- assertFalse(overridableAssociations.hasNext());
-
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity abstractEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
- overridableAssociations = abstractEntity.allOverridableAssociationNames();
- assertEquals("address", overridableAssociations.next());
- assertEquals("address2", overridableAssociations.next());
- assertEquals("address3", overridableAssociations.next());
- assertEquals("address4", overridableAssociations.next());
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testAllOverridableAttributesMappedSuperclassInOrmXml() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributes = getJavaEntity().allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAttributeNames() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributeNames = getJavaEntity().allOverridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertEquals("foo", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testSpecifiedAttributeOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
- ListIterator<JavaAttributeOverride> specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
-
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAZ");
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- typeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- typeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAttributeOverrides = (ListIterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- }
-
- public void testDefaultAttributeOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity javaEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
- AttributeOverrideContainer overrideContainer = javaEntity.getAttributeOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- VirtualAttributeOverride virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
-
- MappedSuperclass mappedSuperclass = (MappedSuperclass) getJavaPersistentType().getMapping();
-
- BasicMapping idMapping = (BasicMapping) mappedSuperclass.getPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("FOO", virtualAttributeOverride.getColumn().getName());
- assertEquals("BAR", virtualAttributeOverride.getColumn().getTable());
-
- idMapping.getColumn().setSpecifiedName(null);
- idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
- virtualAttributeOverride.convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
- }
-
- public void testDefaultAttributeOverridesEntityHierachy() throws Exception {
- createTestAbstractEntityTablePerClass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity javaEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
- AttributeOverrideContainer overrideContainer = javaEntity.getAttributeOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- VirtualAttributeOverride virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
-
- JavaEntity superclass = (JavaEntity) getJavaPersistentType().getMapping();
-
- BasicMapping idMapping = (BasicMapping) superclass.getPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("FOO", virtualAttributeOverride.getColumn().getName());
- assertEquals("BAR", virtualAttributeOverride.getColumn().getTable());
-
- idMapping.getColumn().setSpecifiedName(null);
- idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
- virtualAttributeOverride.convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
- }
-
- public void testSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
- assertEquals(0, overrideContainer.specifiedOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(2, overrideContainer.specifiedOverridesSize());
- }
-
- public void testDefaultAttributeOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(1, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(0, overrideContainer.virtualOverridesSize());
- }
-
- public void testAttributeOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
-
- assertEquals(3, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(3, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(3, overrideContainer.overridesSize());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) typeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("bar");
- getJpaProject().synchronizeContextModel();
- assertEquals(4, overrideContainer.overridesSize());
- }
-
- public void testAttributeOverrideSetVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<NestableAnnotation> attributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideSetVirtual2() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
-
- ListIterator<JavaVirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<JavaVirtualAttributeOverride>) overrideContainer.virtualOverrides();
- virtualAttributeOverrides.next();
- virtualAttributeOverrides.next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<NestableAnnotation> attributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("name", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("id", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideSetVirtualTrue() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(3, CollectionTools.size(typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)));
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
-
- Iterator<NestableAnnotation> attributeOverrideResources = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("name", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
- assertEquals("foo", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
- assertFalse(attributeOverrideResources.hasNext());
-
- Iterator<JavaAttributeOverride> attributeOverrides = (Iterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("foo", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrideResources = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("foo", ((AttributeOverrideAnnotation) attributeOverrideResources.next()).getName());
- assertFalse(attributeOverrideResources.hasNext());
-
- attributeOverrides = (Iterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("foo", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrideResources = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrideResources.hasNext());
- attributeOverrides = (Iterator<JavaAttributeOverride>) overrideContainer.specifiedOverrides();
- assertFalse(attributeOverrides.hasNext());
-
- assertNull(typeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- Iterator<NestableAnnotation> javaAttributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals(3, CollectionTools.size(javaAttributeOverrides));
-
-
- overrideContainer.moveSpecifiedOverride(2, 0);
- ListIterator<AttributeOverride> attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("foo", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
-
- javaAttributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("name", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
- assertEquals("foo", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
- assertEquals("id", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
-
-
- overrideContainer.moveSpecifiedOverride(0, 1);
- attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("foo", attributeOverrides.next().getName());
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
-
- javaAttributeOverrides = typeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("foo", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
- assertEquals("name", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
- assertEquals("id", ((AttributeOverrideAnnotation) javaAttributeOverrides.next()).getName());
- }
-//
- public void testUpdateSpecifiedAttributeOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- ((AttributeOverrideAnnotation) typeResource.addAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((AttributeOverrideAnnotation) typeResource.addAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((AttributeOverrideAnnotation) typeResource.addAnnotation(2, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ");
- getJpaProject().synchronizeContextModel();
-
- ListIterator<AttributeOverride> attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.moveAnnotation(2, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.moveAnnotation(0, 1, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- typeResource.removeAnnotation(0, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- attributeOverrides = (ListIterator<AttributeOverride>) overrideContainer.specifiedOverrides();
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AttributeOverrideContainer overrideContainer = getJavaEntity().getAttributeOverrideContainer();
-
- ListIterator<JavaVirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<JavaVirtualAttributeOverride>) overrideContainer.virtualOverrides();
- JavaVirtualAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("foo", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
- assertFalse(virtualAttributeOverrides.hasNext());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- AttributeOverride specifiedAttributeOverride = overrideContainer.specifiedOverrides().next();
- assertFalse(specifiedAttributeOverride.isVirtual());
-
-
- virtualAttributeOverrides = (ListIterator<JavaVirtualAttributeOverride>) overrideContainer.virtualOverrides();
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("foo", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
- assertFalse(virtualAttributeOverrides.hasNext());
- }
-
-
- public void testOverridableAssociations() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociations = getJavaEntity().overridableAssociationNames();
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testOverridableAssociationNames() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociationNames = getJavaEntity().overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
-// //TODO add all mapping types to the mapped superclass to test which ones are overridable
- public void testAllOverridableAssociationNames() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociationNames = getJavaEntity().allOverridableAssociationNames();
- assertEquals("address", overridableAssociationNames.next());
- assertEquals("address2", overridableAssociationNames.next());
- assertEquals("address3", overridableAssociationNames.next());
- assertEquals("address4", overridableAssociationNames.next());
- assertFalse(overridableAssociationNames.hasNext());
- }
-
- public void testAllOverridableAssociationsMappedSuperclassInOrmXml() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAssociations = getJavaEntity().allOverridableAssociationNames();
- assertEquals("address", overridableAssociations.next());
- assertEquals("address2", overridableAssociations.next());
- assertEquals("address3", overridableAssociations.next());
- assertEquals("address4", overridableAssociations.next());
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testSpecifiedAssociationOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
- ListIterator<JavaAssociationOverride> specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
-
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(1, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
-
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAZ");
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- typeResource.moveAnnotation(1, 0, JPA.ASSOCIATION_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
-
- typeResource.removeAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedAssociationOverrides = (ListIterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertFalse(specifiedAssociationOverrides.hasNext());
- }
-
- public void testVirtualAssociationOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- JavaEntity javaEntity = (JavaEntity) classRefs.next().getJavaPersistentType().getMapping();
- AssociationOverrideContainer overrideContainer = javaEntity.getAssociationOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, overrideContainer.virtualOverridesSize());
- VirtualAssociationOverride virtualAssociationOverride = overrideContainer.virtualOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
-
- //MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
- //BasicMapping idMapping = (BasicMapping) mappedSuperclass.persistentType().attributeNamed("id").getMapping();
- //idMapping.getColumn().setSpecifiedName("FOO");
- //idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, overrideContainer.virtualOverridesSize());
- virtualAssociationOverride = overrideContainer.virtualOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
- //idMapping.getColumn().setSpecifiedName(null);
- //idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(SUB_TYPE_NAME, typeResource.getName());
- assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- virtualAssociationOverride = overrideContainer.virtualOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
- virtualAssociationOverride.convertToSpecified();
- assertEquals(3, overrideContainer.virtualOverridesSize());
-
-
-
-// //TODO joinColumns for default association overrides
-//// IJoinColumn defaultJoinColumn = defaultAssociationOverride.joinColumns().next();
-//// assertEquals("address", defaultJoinColumn.getName());
-//// assertEquals("address", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals(SUB_TYPE_NAME, defaultJoinColumn.getTable());
-////
-////
-//// IMappedSuperclass mappedSuperclass = (IMappedSuperclass) javaPersistentType().getMapping();
-////
-//// IOneToOneMapping addressMapping = (IOneToOneMapping) mappedSuperclass.persistentType().attributeNamed("address").getMapping();
-//// IJoinColumn joinColumn = addressMapping.addSpecifiedJoinColumn(0);
-//// joinColumn.setSpecifiedName("FOO");
-//// joinColumn.setSpecifiedReferencedColumnName("BAR");
-//// joinColumn.setSpecifiedTable("BAZ");
-////
-//// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-//// assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME));
-//// assertNull(typeResource.annotation(AssociationOverrides.ANNOTATION_NAME));
-////
-//// assertEquals(1, CollectionTools.size(javaEntity.defaultAssociationOverrides()));
-//// defaultAssociationOverride = javaEntity.defaultAssociationOverrides().next();
-//// assertEquals("address", defaultAssociationOverride.getName());
-//// assertEquals("FOO", defaultJoinColumn.getName());
-//// assertEquals("BAR", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals("BAZ", defaultJoinColumn.getTable());
-////
-//// joinColumn.setSpecifiedName(null);
-//// joinColumn.setSpecifiedReferencedColumnName(null);
-//// joinColumn.setSpecifiedTable(null);
-//// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-//// assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME));
-//// assertNull(typeResource.annotation(AssociationOverrides.ANNOTATION_NAME));
-////
-//// defaultAssociationOverride = javaEntity.defaultAssociationOverrides().next();
-//// assertEquals("address", defaultJoinColumn.getName());
-//// assertEquals("address", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals(SUB_TYPE_NAME, defaultJoinColumn.getTable());
-////
-//// javaEntity.addSpecifiedAssociationOverride(0).setName("address");
-//// assertEquals(0, CollectionTools.size(javaEntity.defaultAssociationOverrides()));
-
- }
-
- public void testSpecifiedAssociationOverridesSize() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- assertEquals(0, overrideContainer.specifiedOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- //add an annotation to the resource model and verify the context model is updated
- AssociationOverrideAnnotation associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("FOO");
- associationOverride = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- associationOverride.setName("BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(2, overrideContainer.specifiedOverridesSize());
- }
-
- public void testVirtualAssociationOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- assertEquals(4, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(3, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(1, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(0, overrideContainer.virtualOverridesSize());
- }
-
- public void testAssociationOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- assertEquals(4, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(4, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(4, overrideContainer.overridesSize());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- AssociationOverrideAnnotation annotation = (AssociationOverrideAnnotation) typeResource.addAnnotation(0, JPA.ASSOCIATION_OVERRIDE, JPA.ASSOCIATION_OVERRIDES);
- annotation.setName("bar");
- getJpaProject().synchronizeContextModel();
- assertEquals(5, overrideContainer.overridesSize());
- }
-
- public void testAssociationOverrideSetVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<NestableAnnotation> associationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("address", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertEquals("address2", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideSetVirtual2() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- ListIterator<JavaVirtualAssociationOverride> virtualAssociationOverrides = (ListIterator<JavaVirtualAssociationOverride>) overrideContainer.virtualOverrides();
- virtualAssociationOverrides.next();
- virtualAssociationOverrides.next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- Iterator<NestableAnnotation> associationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("address2", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertEquals("address", ((AssociationOverrideAnnotation) associationOverrides.next()).getName());
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideSetVirtualTrue() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
- assertEquals(2, CollectionTools.size(typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)));
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
-
- Iterator<NestableAnnotation> associationOverrideResources = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("address2", ((AssociationOverrideAnnotation) associationOverrideResources.next()).getName());
- assertFalse(associationOverrideResources.hasNext());
-
- Iterator<JavaAssociationOverride> associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("address2", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
- associationOverrideResources = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(associationOverrideResources.hasNext());
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertFalse(associationOverrides.hasNext());
-
- assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
- }
-
- public void testMoveSpecifiedAssociationOverride() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_SUB_TYPE_NAME);
-
- Iterator<NestableAnnotation> javaAssociationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals(2, CollectionTools.size(javaAssociationOverrides));
-
-
- overrideContainer.moveSpecifiedOverride(1, 0);
- Iterator<JavaAssociationOverride> associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("address2", associationOverrides.next().getName());
- assertEquals("address", associationOverrides.next().getName());
-
- javaAssociationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("address2", ((AssociationOverrideAnnotation) javaAssociationOverrides.next()).getName());
- assertEquals("address", ((AssociationOverrideAnnotation) javaAssociationOverrides.next()).getName());
-
-
- overrideContainer.moveSpecifiedOverride(0, 1);
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("address", associationOverrides.next().getName());
- assertEquals("address2", associationOverrides.next().getName());
-
- javaAssociationOverrides = typeResource.annotations(AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("address", ((AssociationOverrideAnnotation) javaAssociationOverrides.next()).getName());
- assertEquals("address2", ((AssociationOverrideAnnotation) javaAssociationOverrides.next()).getName());
- }
-
- public void testUpdateSpecifiedAssociationOverrides() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
-
- ((AssociationOverrideAnnotation) typeResource.addAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("FOO");
- ((AssociationOverrideAnnotation) typeResource.addAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAR");
- ((AssociationOverrideAnnotation) typeResource.addAnnotation(2, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME)).setName("BAZ");
- getJpaProject().synchronizeContextModel();
-
- Iterator<JavaAssociationOverride> associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("FOO", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.moveAnnotation(2, 0, AssociationOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.moveAnnotation(0, 1, AssociationOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.removeAnnotation(1, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- typeResource.removeAnnotation(0, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- associationOverrides = (Iterator<JavaAssociationOverride>) overrideContainer.specifiedOverrides();
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- AssociationOverrideContainer overrideContainer = getJavaEntity().getAssociationOverrideContainer();
-
- ListIterator<JavaVirtualAssociationOverride> virtualAssociationOverrides = (ListIterator<JavaVirtualAssociationOverride>) overrideContainer.virtualOverrides();
- VirtualAssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address2", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address3", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address4", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
- assertFalse(virtualAssociationOverrides.hasNext());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- AssociationOverride specifiedAssociationOverride = overrideContainer.specifiedOverrides().next();
- assertFalse(specifiedAssociationOverride.isVirtual());
-
-
- virtualAssociationOverrides = (ListIterator<JavaVirtualAssociationOverride>) overrideContainer.virtualOverrides();
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address2", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address3", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address4", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
- assertFalse(virtualAssociationOverrides.hasNext());
- }
-
- public void testNestedVirtualAttributeOverrides() throws Exception {
- createTestMappedSuperclassCustomer();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- addXmlClassRef(PACKAGE_NAME + ".Customer");
- addXmlClassRef(PACKAGE_NAME + ".LongTimeCustomer");
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".ZipCode");
- ListIterator<ClassRef> specifiedClassRefs = getPersistenceUnit().specifiedClassRefs();
- PersistentType customerPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- PersistentType longTimeCustomerPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- PersistentType addressPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- PersistentType zipCodePersistentType = specifiedClassRefs.next().getJavaPersistentType();
-
- AttributeOverrideContainer attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
-
- assertEquals(6, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<VirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) attributeOverrideContainer.virtualOverrides();
- VirtualAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.street", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.city", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.zip", virtualAttributeOverride.getName());
- assertEquals("zip", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("plusfour", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- assertEquals(null, virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
-
- BasicMapping plusFourMapping = (BasicMapping) zipCodePersistentType.getAttributeNamed("plusfour").getMapping();
- plusFourMapping.getColumn().setSpecifiedName("BLAH");
- plusFourMapping.getColumn().setSpecifiedTable("BLAH_TABLE");
- plusFourMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- plusFourMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- plusFourMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- plusFourMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- plusFourMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- //check the top-level embedded (Customer.address) attribute override to verify it is getting settings from the specified column on Zipcode.plusfour
- virtualAttributeOverride = (VirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(false, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(5, virtualAttributeOverride.getColumn().getLength());
- assertEquals(6, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(7, virtualAttributeOverride.getColumn().getScale());
-
- //set an attribute override on Address.zipCode embedded mapping
- AttributeOverride specifiedAttributeOverride = ((VirtualAttributeOverride) ((EmbeddedMapping) addressPersistentType.getAttributeNamed("zipCode").getMapping()).getAttributeOverrideContainer().getOverrideNamed("plusfour")).convertToSpecified();
- specifiedAttributeOverride.getColumn().setSpecifiedName("BLAH_OVERRIDE");
- specifiedAttributeOverride.getColumn().setSpecifiedTable("BLAH_TABLE_OVERRIDE");
- specifiedAttributeOverride.getColumn().setColumnDefinition("COLUMN_DEFINITION_OVERRIDE");
-
-
- attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- virtualAttributeOverride = (VirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH_OVERRIDE", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE_OVERRIDE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
- specifiedAttributeOverride = virtualAttributeOverride.convertToSpecified();
- assertEquals(false, specifiedAttributeOverride.isVirtual());
- assertEquals("address.zipCode.plusfour", specifiedAttributeOverride.getName());
- //TODO I have the default wrong in this case, but this was wrong before as well. Need to fix this later
-// assertEquals("plusfour", specifiedAttributeOverride.getColumn().getDefaultName());
- assertEquals("BLAH_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedName());
-// assertEquals("Customer", specifiedAttributeOverride.getColumn().getDefaultTable());
- assertEquals("BLAH_TABLE_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", specifiedAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, specifiedAttributeOverride.getColumn().isInsertable());
- assertEquals(true, specifiedAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, specifiedAttributeOverride.getColumn().isUnique());
- assertEquals(true, specifiedAttributeOverride.getColumn().isNullable());
- assertEquals(255, specifiedAttributeOverride.getColumn().getLength());
- assertEquals(0, specifiedAttributeOverride.getColumn().getPrecision());
- assertEquals(0, specifiedAttributeOverride.getColumn().getScale());
- }
-
- public void testNestedVirtualAttributeOverridesElementCollection() throws Exception {
- createTestMappedSuperclassCustomerWithElementCollection();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- addXmlClassRef(PACKAGE_NAME + ".Customer");
- addXmlClassRef(PACKAGE_NAME + ".LongTimeCustomer");
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".ZipCode");
- ListIterator<ClassRef> specifiedClassRefs = getPersistenceUnit().specifiedClassRefs();
- PersistentType customerPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- PersistentType longTimeCustomerPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- PersistentType addressPersistentType = specifiedClassRefs.next().getJavaPersistentType();
- PersistentType zipCodePersistentType = specifiedClassRefs.next().getJavaPersistentType();
-
- AttributeOverrideContainer attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
-
- assertEquals(6, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<VirtualAttributeOverride> virtualAttributeOverrides = (ListIterator<VirtualAttributeOverride>) attributeOverrideContainer.virtualOverrides();
- VirtualAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.street", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.city", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.zip", virtualAttributeOverride.getName());
- assertEquals("zip", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("plusfour", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- assertEquals(null, virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
-
- BasicMapping plusFourMapping = (BasicMapping) zipCodePersistentType.getAttributeNamed("plusfour").getMapping();
- plusFourMapping.getColumn().setSpecifiedName("BLAH");
- plusFourMapping.getColumn().setSpecifiedTable("BLAH_TABLE");
- plusFourMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- plusFourMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- plusFourMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- plusFourMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- plusFourMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- //check the top-level embedded (Customer.address) attribute override to verify it is getting settings from the specified column on Zipcode.plusfour
- virtualAttributeOverride = (VirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(false, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(5, virtualAttributeOverride.getColumn().getLength());
- assertEquals(6, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(7, virtualAttributeOverride.getColumn().getScale());
-
- //set an attribute override on Address.zipCode embedded mapping
- AttributeOverride specifiedAttributeOverride = ((VirtualAttributeOverride) ((EmbeddedMapping) addressPersistentType.getAttributeNamed("zipCode").getMapping()).getAttributeOverrideContainer().getOverrideNamed("plusfour")).convertToSpecified();
- specifiedAttributeOverride.getColumn().setSpecifiedName("BLAH_OVERRIDE");
- specifiedAttributeOverride.getColumn().setSpecifiedTable("BLAH_TABLE_OVERRIDE");
- specifiedAttributeOverride.getColumn().setColumnDefinition("COLUMN_DEFINITION_OVERRIDE");
-
-
- attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- virtualAttributeOverride = (VirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH_OVERRIDE", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE_OVERRIDE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
- specifiedAttributeOverride = virtualAttributeOverride.convertToSpecified();
- assertEquals(false, specifiedAttributeOverride.isVirtual());
- assertEquals("address.zipCode.plusfour", specifiedAttributeOverride.getName());
- //TODO I have the default wrong in this case, but this was wrong before as well. Need to fix this later
-// assertEquals("plusfour", specifiedAttributeOverride.getColumn().getDefaultName());
- assertEquals("BLAH_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedName());
-// assertEquals("Customer", specifiedAttributeOverride.getColumn().getDefaultTable());
- assertEquals("BLAH_TABLE_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", specifiedAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, specifiedAttributeOverride.getColumn().isInsertable());
- assertEquals(true, specifiedAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, specifiedAttributeOverride.getColumn().isUnique());
- assertEquals(true, specifiedAttributeOverride.getColumn().isNullable());
- assertEquals(255, specifiedAttributeOverride.getColumn().getLength());
- assertEquals(0, specifiedAttributeOverride.getColumn().getPrecision());
- assertEquals(0, specifiedAttributeOverride.getColumn().getScale());
- }
-
- public void testNestedVirtualAssociationOverrides() throws Exception {
- createTestMappedSuperclassCustomer();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- addXmlClassRef(PACKAGE_NAME + ".Customer");
- addXmlClassRef(PACKAGE_NAME + ".LongTimeCustomer");
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".ZipCode");
- ListIterator<ClassRef> specifiedClassRefs = getPersistenceUnit().specifiedClassRefs();
- specifiedClassRefs.next();
- PersistentType longTimeCustomerPersistentType = specifiedClassRefs.next().getJavaPersistentType();
-
- AssociationOverrideContainer attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAssociationOverrideContainer();
-
- assertEquals(1, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<VirtualAssociationOverride> virtualAssociationOverrides = (ListIterator<VirtualAssociationOverride>) attributeOverrideContainer.virtualOverrides();
- VirtualAssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address.state", virtualAssociationOverride.getName());
- }
-
- public void testNestedVirtualAssociationOverridesElementCollection() throws Exception {
- createTestMappedSuperclassCustomerWithElementCollection();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- addXmlClassRef(PACKAGE_NAME + ".Customer");
- addXmlClassRef(PACKAGE_NAME + ".LongTimeCustomer");
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".ZipCode");
- ListIterator<ClassRef> specifiedClassRefs = getPersistenceUnit().specifiedClassRefs();
- specifiedClassRefs.next();
- PersistentType longTimeCustomerPersistentType = specifiedClassRefs.next().getJavaPersistentType();
-
- AssociationOverrideContainer attributeOverrideContainer = ((Entity) longTimeCustomerPersistentType.getMapping()).getAssociationOverrideContainer();
-
- assertEquals(1, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<VirtualAssociationOverride> virtualAssociationOverrides = (ListIterator<VirtualAssociationOverride>) attributeOverrideContainer.virtualOverrides();
- VirtualAssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address.state", virtualAssociationOverride.getName());
- }
-
- public void testSetSpecifiedCacheable() throws Exception {
- ICompilationUnit cu = createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaEntity()).getCacheable();
- Cacheable2_0Annotation cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable(false)", cu);
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable", cu);
-
- cacheable.setSpecifiedCacheable(null);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
- assertSourceDoesNotContain("@Cacheable", cu);
- }
-
- public void testGetSpecifiedCacheable() throws Exception {
- ICompilationUnit cu = createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaEntity()).getCacheable();
- Cacheable2_0Annotation cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
-
- getJavaPersistentType().getResourcePersistentType().addAnnotation(JPA2_0.CACHEABLE);
- getJpaProject().synchronizeContextModel();
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable", cu);
-
- cacheableAnnotation.setValue(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable(false)", cu);
-
- cacheableAnnotation.setValue(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.TRUE, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable(true)", cu);
-
- cacheableAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable", cu);
-
- getJavaPersistentType().getResourcePersistentType().removeAnnotation(JPA2_0.CACHEABLE);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
- assertSourceDoesNotContain("@Cacheable", cu);
- }
-
- public void testIsDefaultCacheable() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaEntity()).getCacheable();
- PersistenceUnit2_0 persistenceUnit = getPersistenceUnit();
- assertEquals(SharedCacheMode.DISABLE_SELECTIVE, persistenceUnit.getSharedCacheMode());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.ALL);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.UNSPECIFIED);
- assertEquals(true, cacheable.isDefaultCacheable());
- }
-
- public void testInheritedIsDefaultCacheable() throws Exception {
- createTestEntity();
- createTestSubType();
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) getJavaEntity()).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaEntity().getParentEntity()).getCacheable();
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(null);
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
deleted file mode 100644
index 6b1955408a..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToManyMappingTests.java
+++ /dev/null
@@ -1,1303 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
-import org.eclipse.jpt.jpa.core.jpa2.context.ManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-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.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetch;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkRelationshipMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkJoinFetchAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaManyToManyMappingTests
- extends EclipseLink2_0ContextModelTestCase
-{
- public EclipseLink2_0JavaManyToManyMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithJoinFetchManyToMany() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, EclipseLink.JOIN_FETCH);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToMany").append(CR);
- sb.append("@JoinFetch").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidGenericMapManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private java.util.Map<Integer, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- 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("import ");
- sb.append(JPA.MANY_TO_MANY);
- 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(" @ManyToMany").append(CR);
- sb.append(" private java.util.Collection<AnnotationTestType> employees;").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 String address;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityWithEmbeddableKeyManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private java.util.Map<Address, PropertyInfo> parcels;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private void createTestEmbeddableAddress() 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("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDED);
- sb.append(";");
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").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 createTestEntityPropertyInfo() 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("PropertyInfo").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private Integer parcelNumber;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private Integer size;").append(CR);
- sb.append(CR);
- sb.append(" private java.math.BigDecimal tax;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PropertyInfo.java", sourceWriter);
- }
-
- public void testGetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to INNER specifically, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change resource to OUTER, test context
-
- joinFetchAnnotation.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // remove value from resource, test context
-
- joinFetchAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // remove annotation, text context
-
- attributeResource.removeAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(joinFetchAnnotation.getValue());
- assertNull(contextJoinFetch.getValue());
- }
-
- public void testSetJoinFetchValue() throws Exception {
- createTestEntityWithJoinFetchManyToMany();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- EclipseLinkRelationshipMapping manyToManyMapping = (EclipseLinkRelationshipMapping) persistentAttribute.getMapping();
- EclipseLinkJoinFetch contextJoinFetch = manyToManyMapping.getJoinFetch();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- EclipseLinkJoinFetchAnnotation joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to INNER specifically, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
-
- assertNull(joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
-
- // change context to OUTER, test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.OUTER);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.OUTER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.OUTER, contextJoinFetch.getValue());
-
- // set context to null, test resource
-
- contextJoinFetch.setValue(null);
-
- assertNull(attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME));
- assertNull(contextJoinFetch.getValue());
-
- // change context to INNER specifically (this time from no annotation), test resource
-
- contextJoinFetch.setValue(EclipseLinkJoinFetchType.INNER);
- joinFetchAnnotation = (EclipseLinkJoinFetchAnnotation) attributeResource.getAnnotation(EclipseLinkJoinFetchAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.JoinFetchType.INNER, joinFetchAnnotation.getValue());
- assertEquals(EclipseLinkJoinFetchType.INNER, contextJoinFetch.getValue());
- }
-
- public void testCandidateMappedByAttributeNames() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames =
- manyToManyMapping.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());
- assertEquals("employees", attributeNames.next());
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- attributeNames =
- manyToManyMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- attributeNames =
- manyToManyMapping.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());
- assertEquals("employees", attributeNames.next());
- assertFalse(attributeNames.hasNext());
-
- AttributeMapping stateFooMapping = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
- assertEquals("foo", stateFooMapping.getName());
- }
-
- public void testCandidateMappedByAttributeNamesElementCollection() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddressWithElementCollection();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- PersistentAttribute persistentAttribute = (getJavaPersistentType()).attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames =
- manyToManyMapping.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());
-
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- attributeNames =
- manyToManyMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- attributeNames =
- manyToManyMapping.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 = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
- assertEquals("foo", stateFooMapping.getName());
- }
-
- public void testUpdateMapKey() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(manyToManyMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(manyToManyMapping.getSpecifiedMapKey());
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNotNull(mapKey);
-
- //set mapKey name in the resource model, verify context model updated
- mapKey.setName("myMapKey");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey name to null in the resource model
- mapKey.setName(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(manyToManyMapping.getSpecifiedMapKey());
- assertNull(mapKey.getName());
-
- mapKey.setName("myMapKey");
- attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(manyToManyMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKey() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(manyToManyMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- manyToManyMapping.setSpecifiedMapKey("myMapKey");
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertEquals("myMapKey", manyToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", mapKey.getName());
- //set mapKey to null in the context model
- manyToManyMapping.setSpecifiedMapKey(null);
- assertNull(manyToManyMapping.getSpecifiedMapKey());
- mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(mapKey.getName());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidGenericMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping2_0 = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> mapKeyNames =
- manyToManyMapping2_0.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertEquals("employees", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping manyToManyMapping2_0 = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- manyToManyMapping2_0.setSpecifiedTargetEntity("Address");
- mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertEquals("employees", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- manyToManyMapping2_0.setSpecifiedTargetEntity("String");
- mapKeyNames = manyToManyMapping2_0.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
- }
-
- public void testUpdateMapKeyClass() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
- MapKeyClass2_0Annotation mapKeyClassAnnotation = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertNotNull(mapKeyClassAnnotation);
-
- //set mapKey name in the resource model, verify context model updated
- mapKeyClassAnnotation.setValue("myMapKeyClass");
- this.getJpaProject().synchronizeContextModel();
- assertEquals("myMapKeyClass", manyToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("myMapKeyClass", mapKeyClassAnnotation.getValue());
-
- //set mapKey name to null in the resource model
- mapKeyClassAnnotation.setValue(null);
- this.getJpaProject().synchronizeContextModel();
- assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(mapKeyClassAnnotation.getValue());
-
- mapKeyClassAnnotation.setValue("myMapKeyClass");
- attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKeyClass() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- manyToManyMapping.setSpecifiedMapKeyClass("String");
- MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertEquals("String", manyToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("String", mapKeyClass.getValue());
-
- //set mapKey to null in the context model
- manyToManyMapping.setSpecifiedMapKeyClass(null);
- assertNull(manyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testDefaultMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
-
- assertEquals("java.lang.Integer", manyToManyMapping.getDefaultMapKeyClass());
-
- //test default still the same when specified target entity it set
- manyToManyMapping.setSpecifiedMapKeyClass("foo");
- assertEquals("java.lang.Integer", manyToManyMapping.getDefaultMapKeyClass());
- }
-
- public void testDefaultMapKeyClassCollectionType() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
-
- assertNull(manyToManyMapping.getDefaultMapKeyClass());
- }
-
- public void testMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapManyToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
-
- assertEquals("java.lang.Integer", manyToManyMapping.getMapKeyClass());
-
- manyToManyMapping.setSpecifiedMapKeyClass("foo");
- assertEquals("foo", manyToManyMapping.getMapKeyClass());
-
- manyToManyMapping.setSpecifiedMapKeyClass(null);
- assertEquals("java.lang.Integer", manyToManyMapping.getMapKeyClass());
- }
-
- public void testOrderColumnDefaults() throws Exception {
- createTestEntityPrintQueue();
- createTestEntityPrintJob();
-
- addXmlClassRef(PACKAGE_NAME + ".PrintQueue");
- addXmlClassRef(PACKAGE_NAME + ".PrintJob");
- JavaPersistentType printQueuePersistentType = (JavaPersistentType) getPersistenceUnit().getPersistentType("test.PrintQueue");
- ManyToManyMapping jobsMapping = (ManyToManyMapping) printQueuePersistentType.getAttributeNamed("jobs").getMapping();
- JavaPersistentType printJobPersistentType = (JavaPersistentType) getPersistenceUnit().getPersistentType("test.PrintJob");
- ManyToManyMapping queuesMapping = (ManyToManyMapping) printJobPersistentType.getAttributeNamed("queues").getMapping();
-
- Orderable2_0 jobsOrderable = ((Orderable2_0) jobsMapping.getOrderable());
- OrderColumn2_0 jobsOrderColumn = jobsOrderable.getOrderColumn();
- assertEquals(true, jobsOrderable.isOrderColumnOrdering());
- assertEquals(null, jobsOrderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", jobsOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", jobsOrderColumn.getTable()); //the join table name
- Orderable2_0 queuesOrderable = ((Orderable2_0) queuesMapping.getOrderable());
- OrderColumn2_0 queuesOrderColumn = queuesOrderable.getOrderColumn();
- assertEquals(true, queuesOrderable.isOrderColumnOrdering());
- assertEquals(null, queuesOrderColumn.getSpecifiedName());
- assertEquals("queues_ORDER", queuesOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", queuesOrderColumn.getTable());
-
- jobsOrderColumn.setSpecifiedName("FOO");
- assertEquals("FOO", jobsOrderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", jobsOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", jobsOrderColumn.getTable());
- queuesOrderColumn.setSpecifiedName("BAR");
- assertEquals("BAR", queuesOrderColumn.getSpecifiedName());
- assertEquals("queues_ORDER", queuesOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", queuesOrderColumn.getTable());
-
- ((Entity) printJobPersistentType.getMapping()).getTable().setSpecifiedName("MY_TABLE");
- assertEquals("MY_TABLE_PrintQueue", jobsOrderColumn.getTable());
- assertEquals("MY_TABLE_PrintQueue", queuesOrderColumn.getTable());
-
- ((Entity) printQueuePersistentType.getMapping()).getTable().setSpecifiedName("OTHER_TABLE");
- assertEquals("MY_TABLE_OTHER_TABLE", jobsOrderColumn.getTable());
- assertEquals("MY_TABLE_OTHER_TABLE", queuesOrderColumn.getTable());
-
- queuesMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- assertEquals("MY_JOIN_TABLE", jobsOrderColumn.getTable());
- assertEquals("MY_JOIN_TABLE", queuesOrderColumn.getTable());
- }
-
- private void createTestEntityPrintQueue() 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.MANY_TO_MANY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ORDER_COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintQueue").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToMany(mappedBy=\"queues\")").append(CR);
- sb.append(" @OrderColumn").append(CR);
- sb.append(" private java.util.List<PrintJob> jobs;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintQueue.java", sourceWriter);
- }
-
- private void createTestEntityPrintJob() 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.MANY_TO_MANY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ORDER_COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintJob").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(" @ManyToMany").append(CR);
- sb.append(" @OrderColumn").append(CR);
- sb.append(" private java.util.List<PrintQueue> queues;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintJob.java", sourceWriter);
- }
-
- public void testGetMapKeyColumnMappedByStrategy() throws Exception {
- createTestEntityWithValidGenericMapManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
- manyToManyMapping.getRelationship().setStrategyToMappedBy();
- manyToManyMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("employees");
-
- assertNull(manyToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("addresses_KEY", manyToManyMapping.getMapKeyColumn().getName());
- assertEquals("Address_" + TYPE_NAME, manyToManyMapping.getMapKeyColumn().getTable());//join table name of owning many-to-many
-
- PersistentType persistentType = getPersistenceUnit().getPersistentType("test.Address");
- ManyToManyMapping owningManyToManyMapping = (ManyToManyMapping) persistentType.getAttributeNamed("employees").getMapping();
- ((JoinTableRelationshipStrategy) owningManyToManyMapping.getRelationship().getStrategy()).getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- assertEquals("MY_JOIN_TABLE", manyToManyMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", manyToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", manyToManyMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", manyToManyMapping.getMapKeyColumn().getDefaultName());
- }
-
- public void testGetMapKeyColumnJoinTableStrategy() throws Exception {
- createTestEntityWithValidGenericMapManyToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- ManyToManyMapping2_0 manyToManyMapping = (ManyToManyMapping2_0) persistentAttribute.getMapping();
-
- assertNull(manyToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("addresses_KEY", manyToManyMapping.getMapKeyColumn().getName());
- assertEquals(TYPE_NAME + "_Address", manyToManyMapping.getMapKeyColumn().getTable());//join table name
-
- manyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- assertEquals("MY_JOIN_TABLE", manyToManyMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", manyToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", manyToManyMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", manyToManyMapping.getMapKeyColumn().getDefaultName());
- }
-
- public void testMapKeySpecifiedAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
-
- ListIterator<JavaAttributeOverride> specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.BAR");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAZ");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BLAH");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
- }
-
- public void testMapKeyValueVirtualAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertEquals("parcels", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- ReadOnlyAttributeOverride defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_PropertyInfo", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- Embeddable addressEmbeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping cityMapping = (BasicMapping) addressEmbeddable.getPersistentType().getAttributeNamed("city").getMapping();
- cityMapping.getColumn().setSpecifiedName("FOO");
- cityMapping.getColumn().setSpecifiedTable("BAR");
- cityMapping.getColumn().setColumnDefinition("COLUMN_DEF");
- cityMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- cityMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- cityMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- cityMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- assertEquals("parcels", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("FOO", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR", defaultAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEF", defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(false, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(5, defaultAttributeOverride.getColumn().getLength());
- assertEquals(6, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(7, defaultAttributeOverride.getColumn().getScale());
-
- cityMapping.getColumn().setSpecifiedName(null);
- cityMapping.getColumn().setSpecifiedTable(null);
- cityMapping.getColumn().setColumnDefinition(null);
- cityMapping.getColumn().setSpecifiedInsertable(null);
- cityMapping.getColumn().setSpecifiedUpdatable(null);
- cityMapping.getColumn().setSpecifiedUnique(null);
- cityMapping.getColumn().setSpecifiedNullable(null);
- cityMapping.getColumn().setSpecifiedLength(null);
- cityMapping.getColumn().setSpecifiedPrecision(null);
- cityMapping.getColumn().setSpecifiedScale(null);
- defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_PropertyInfo", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("key.city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testMapKeyValueSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(0, mapKeyAttributeOverrideContainer.specifiedOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.FOO2");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(3, mapKeyAttributeOverrideContainer.specifiedOverridesSize());
- }
-
- public void testMapKeyValueAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(4, mapKeyAttributeOverrideContainer.overridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.FOO2");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(7, mapKeyAttributeOverrideContainer.overridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- getJpaProject().synchronizeContextModel();
- assertEquals(7, mapKeyAttributeOverrideContainer.overridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.state.foo");
- getJpaProject().synchronizeContextModel();
- assertEquals(7, mapKeyAttributeOverrideContainer.overridesSize());
- }
-
- public void testMapKeyValueVirtualAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.state.foo");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("size");
- getJpaProject().synchronizeContextModel();
- assertEquals(2, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testMapKeyValueAttributeOverrideSetVirtual() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.state.foo", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- mapKeyAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("key.state.foo", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- mapKeyAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrides.hasNext());
-
- Iterator<JavaVirtualAttributeOverride> virtualAttributeOverrides = mapKeyAttributeOverrideContainer.virtualOverrides();
- assertEquals("city", virtualAttributeOverrides.next().getName());
- assertEquals("state.foo", virtualAttributeOverrides.next().getName());
- assertEquals("state.address", virtualAttributeOverrides.next().getName());
- assertEquals("zip", virtualAttributeOverrides.next().getName());
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
-
- public void testMapKeyValueMoveSpecifiedAttributeOverride() throws Exception {
- createTestEntityWithEmbeddableKeyManyToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaManyToManyMapping2_0 manyToManyMapping = (JavaManyToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = manyToManyMapping.getMapKeyAttributeOverrideContainer();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- ListIterator<JavaAttributeOverride> specifiedOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("city", specifiedOverrides.next().getName());
- assertEquals("state.foo", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("key.state.foo", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- specifiedOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("state.foo", specifiedOverrides.next().getName());
- assertEquals("city", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToOneMappingTests.java
deleted file mode 100644
index 5a0a6e10ca..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaManyToOneMappingTests.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-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.ManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneRelationship2_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.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_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.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaManyToOneMappingTests
- extends EclipseLink2_0ContextModelTestCase
-{
- public EclipseLink2_0JavaManyToOneMappingTests(String name) {
- super(name);
- }
-
-
- private void createTestEntity() throws Exception {
- createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_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(" @ManyToOne");
- 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.MANY_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(" @ManyToOne @Id").append(CR);
- sb.append(" private " + TYPE_NAME + " manyToOne;").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.MANY_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(" @ManyToOne @MapsId").append(CR);
- sb.append(" private " + TYPE_NAME + " manyToOne;").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();
- }
- }
-
- public void testUpdateDerivedId() 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("manyToOne");
- JavaManyToOneMapping2_0 contextMapping = (JavaManyToOneMapping2_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 testSetDerivedId() 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("manyToOne");
- JavaManyToOneMapping2_0 contextMapping = (JavaManyToOneMapping2_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("manyToOne");
- JavaManyToOneMapping2_0 contextMapping = (JavaManyToOneMapping2_0) contextAttribute.getMapping();
-
- 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 {
- createTestEntity();
- 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("address");
- JavaManyToOneMapping2_0 contextMapping = (JavaManyToOneMapping2_0) contextAttribute.getMapping();
-
- assertNull(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 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("manyToOne");
-
- ((MapsId2_0Annotation) resourceAttribute.getAnnotation(JPA2_0.MAPS_ID)).setValue("foo");
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceAttribute.getAnnotation(JPA.ID));
- 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());
-
- 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());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
- ManyToOneMapping2_0 mapping = (ManyToOneMapping2_0) contextAttribute.getMapping();
- ManyToOneRelationship2_0 rel = (ManyToOneRelationship2_0) mapping.getRelationship();
-
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinColumn();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinTable();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinColumn();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
- ManyToOneMapping2_0 mapping = (ManyToOneMapping2_0) contextAttribute.getMapping();
- ManyToOneRelationship2_0 rel = (ManyToOneRelationship2_0) mapping.getRelationship();
-
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceAttribute.addAnnotation(JPA.JOIN_COLUMN);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceAttribute.addAnnotation(JPA.JOIN_TABLE);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
-
- resourceAttribute.removeAnnotation(JPA.JOIN_COLUMN);
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
-
- resourceAttribute.removeAnnotation(JPA.JOIN_TABLE);
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaMappedSuperclassTests.java
deleted file mode 100644
index 900873b3e9..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaMappedSuperclassTests.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.Cacheable2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTracking;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomizer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkReadOnly;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkChangeTrackingAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkCustomizerAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLinkReadOnlyAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaMappedSuperclassTests extends EclipseLink2_0ContextModelTestCase
-{
- protected static final String SUB_TYPE_NAME = "AnnotationTestTypeChild";
- protected static final String FULLY_QUALIFIED_SUB_TYPE_NAME = PACKAGE_NAME + "." + SUB_TYPE_NAME;
-
- private ICompilationUnit createTestMappedSuperclass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private void createTestSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.MAPPED_SUPERCLASS);
- sb.append(";");
- sb.append(CR);
- sb.append("@MappedSuperclass");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- private ICompilationUnit createTestMappedSuperclassWithReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- sb.append("@ReadOnly").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassWithConvertAndCustomizerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- sb.append(" @Customizer(Foo.class");
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassWithChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CHANGE_TRACKING);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- sb.append(" @ChangeTracking").append(CR);
- }
- });
- }
-
- public EclipseLink2_0JavaMappedSuperclassTests(String name) {
- super(name);
- }
-
-
- public void testGetReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(true, readOnly.isReadOnly());
- }
-
- public void testGetSpecifiedReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
- }
-
- //TODO test inheriting a default readonly from you superclass
- public void testGetDefaultReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(false, readOnly.isDefaultReadOnly());
- }
-
- public void testSetSpecifiedReadOnly() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(true, readOnly.isReadOnly());
-
- readOnly.setSpecifiedReadOnly(Boolean.FALSE);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- assertNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertEquals(null, readOnly.getSpecifiedReadOnly());//Boolean.FALSE and null really mean the same thing since there are only 2 states in the java resource model
-
- readOnly.setSpecifiedReadOnly(Boolean.TRUE);
- assertNotNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
-
- readOnly.setSpecifiedReadOnly(null);
- assertNull(typeResource.getAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME));
- assertEquals(null, readOnly.getSpecifiedReadOnly());//Boolean.FALSE and null really mean the same thing since there are only 2 states in the java resource model
- }
-
- public void testSpecifiedReadOnlyUpdatesFromResourceModelChange() throws Exception {
- createTestMappedSuperclassWithReadOnly();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkReadOnly readOnly = mappedSuperclass.getReadOnly();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
-
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- typeResource.removeAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(null, readOnly.getSpecifiedReadOnly());
- assertEquals(false, readOnly.isDefaultReadOnly());
-
- typeResource.addAnnotation(EclipseLinkReadOnlyAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, readOnly.getSpecifiedReadOnly());
- }
-
- public void testGetCustomizerClass() throws Exception {
- createTestMappedSuperclassWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping()).getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testSetCustomizerClass() throws Exception {
- createTestMappedSuperclassWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkCustomizer customizer = ((EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping()).getCustomizer();
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
-
-
- customizer.setSpecifiedCustomizerClass(null);
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals(null, customizerAnnotation);
-
-
- customizer.setSpecifiedCustomizerClass("Bar");
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- assertEquals("Bar", customizerAnnotation.getValue());
- }
-
- public void testGetCustomizerClassUpdatesFromResourceModelChange() throws Exception {
- createTestMappedSuperclassWithConvertAndCustomizerClass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkCustomizer customizer = mappedSuperclass.getCustomizer();
-
- assertEquals("Foo", customizer.getSpecifiedCustomizerClass());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkCustomizerAnnotation customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.getAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- customizerAnnotation.setValue("Bar");
- getJpaProject().synchronizeContextModel();
- assertEquals("Bar", customizer.getSpecifiedCustomizerClass());
-
- typeResource.removeAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation = (EclipseLinkCustomizerAnnotation) typeResource.addAnnotation(EclipseLinkCustomizerAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
- assertEquals(null, customizer.getSpecifiedCustomizerClass());
-
- customizerAnnotation.setValue("FooBar");
- getJpaProject().synchronizeContextModel();
- assertEquals("FooBar", customizer.getSpecifiedCustomizerClass());
- }
-
- public void testGetChangeTracking() throws Exception {
- createTestMappedSuperclassWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = mappedSuperclass.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test context value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change resource to ATTRIBUTE specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change resource to OBJECT specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change resource to DEFERRED specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change resource to AUTO specifically, test context
-
- resourceChangeTracking.setValue(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove value from resource, test context
-
- resourceChangeTracking.setValue(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // remove annotation, text context
-
- typeResource.removeAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getDefaultType());
- assertNull(contextChangeTracking.getSpecifiedType());
- }
-
- public void testSetChangeTracking() throws Exception {
- createTestMappedSuperclassWithChangeTracking();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
- EclipseLinkChangeTracking contextChangeTracking = mappedSuperclass.getChangeTracking();
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- EclipseLinkChangeTrackingAnnotation resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- // base annotated, test resource value
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertNull(resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
-
- // change context to ATTRIBUTE specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.ATTRIBUTE, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, contextChangeTracking.getSpecifiedType());
-
- // change context to OBJECT specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.OBJECT, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, contextChangeTracking.getSpecifiedType());
-
- // change context to DEFERRED specifically, test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.DEFERRED, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, contextChangeTracking.getSpecifiedType());
-
- // change context to null, test resource
-
- contextChangeTracking.setSpecifiedType(null);
-
- assertNull(typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME));
- assertNull(contextChangeTracking.getSpecifiedType());
-
- // change context to AUTO specifically (this time from no annotation), test resource
-
- contextChangeTracking.setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
- resourceChangeTracking = (EclipseLinkChangeTrackingAnnotation) typeResource.getAnnotation(EclipseLinkChangeTrackingAnnotation.ANNOTATION_NAME);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.java.ChangeTrackingType.AUTO, resourceChangeTracking.getValue());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, contextChangeTracking.getSpecifiedType());
- }
-
-
- public void testSetSpecifiedCacheable() throws Exception {
- ICompilationUnit cu = createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaPersistentType().getMapping()).getCacheable();
- Cacheable2_0Annotation cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable(false)", cu);
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable", cu);
-
- cacheable.setSpecifiedCacheable(null);
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
- assertSourceDoesNotContain("@Cacheable", cu);
- }
-
- public void testGetSpecifiedCacheable() throws Exception {
- ICompilationUnit cu = createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaPersistentType().getMapping()).getCacheable();
- Cacheable2_0Annotation cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
-
- getJavaPersistentType().getResourcePersistentType().addAnnotation(JPA2_0.CACHEABLE);
- getJpaProject().synchronizeContextModel();
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable", cu);
-
- cacheableAnnotation.setValue(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable(false)", cu);
-
- cacheableAnnotation.setValue(Boolean.TRUE);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.TRUE, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable(true)", cu);
-
- cacheableAnnotation.setValue(null);
- getJpaProject().synchronizeContextModel();
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation.getValue());
- assertSourceContains("@Cacheable", cu);
-
- getJavaPersistentType().getResourcePersistentType().removeAnnotation(JPA2_0.CACHEABLE);
- getJpaProject().synchronizeContextModel();
- cacheableAnnotation = (Cacheable2_0Annotation) getJavaPersistentType().getResourcePersistentType().getAnnotation(JPA2_0.CACHEABLE);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, cacheableAnnotation);
- assertSourceDoesNotContain("@Cacheable", cu);
- }
-
- public void testIsDefaultCacheable() throws Exception {
- createTestMappedSuperclass();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaPersistentType().getMapping()).getCacheable();
- PersistenceUnit2_0 persistenceUnit = getPersistenceUnit();
- assertEquals(SharedCacheMode.DISABLE_SELECTIVE, persistenceUnit.getSharedCacheMode());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.ALL);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit.setSpecifiedSharedCacheMode(SharedCacheMode.UNSPECIFIED);
- assertEquals(true, cacheable.isDefaultCacheable());
- }
-
- public void testInheritedIsDefaultCacheable() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(FULLY_QUALIFIED_SUB_TYPE_NAME);
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) getJavaPersistentType().getMapping()).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) getJavaPersistentType().getSuperPersistentType().getMapping()).getCacheable();
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(null);
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
deleted file mode 100644
index b7601a0dfd..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToManyMappingTests.java
+++ /dev/null
@@ -1,1422 +0,0 @@
-/*******************************************************************************
-* 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
-import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToManyMapping2_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.MapKeyClass2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.OneToMany2_0Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-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.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-/**
- * EclipseLink2_0JavaOneToManyMappingTests
- */
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaOneToManyMappingTests
- extends EclipseLink2_0ContextModelTestCase
-{
- public EclipseLink2_0JavaOneToManyMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntity() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToMany").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidGenericMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
- 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("import ");
- sb.append(JPA.MANY_TO_ONE);
- 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(" @ManyToOne").append(CR);
- sb.append(" private AnnotationTestType employee;").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 String address;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityWithEmbeddableKeyOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map<Address, PropertyInfo> parcels;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private void createTestEmbeddableAddress() 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("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDED);
- sb.append(";");
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").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 createTestEntityPropertyInfo() 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("PropertyInfo").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private Integer parcelNumber;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private Integer size;").append(CR);
- sb.append(CR);
- sb.append(" private java.math.BigDecimal tax;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PropertyInfo.java", sourceWriter);
- }
- private ICompilationUnit createTestEntityWithValidOneToManyMappingOrphanRemovalSpecified() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany(orphanRemoval=false)").append(CR);
- sb.append(" private Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private JavaOrphanRemovable2_0 getOrphanRemovalOf(OneToManyMapping2_0 oneToManyMapping) {
- return ((JavaOrphanRemovalHolder2_0) oneToManyMapping).getOrphanRemoval();
- }
-
- public void testDefaultOneToManyGetDefaultOrphanRemoval() throws Exception {
- this.createTestEntity();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- assertEquals(false, this.getOrphanRemovalOf(oneToManyMapping).isDefaultOrphanRemoval());
- }
-
- public void testSpecifiedOneToManyGetDefaultOrphanRemoval() throws Exception {
- this.createTestEntity();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- assertEquals(false, this.getOrphanRemovalOf(oneToManyMapping).isDefaultOrphanRemoval());
- }
-
- public void testGetOrphanRemoval() throws Exception {
- this.createTestEntity();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
-
-
- 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();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
-
- assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY);
- oneToMany.setOrphanRemoval(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- }
-
- public void testGetSpecifiedOrphanRemoval2() throws Exception {
- this.createTestEntityWithValidOneToManyMappingOrphanRemovalSpecified();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
-
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- }
-
- public void testSetSpecifiedOrphanRemoval() throws Exception {
- this.createTestEntity();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
- assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY);
-
- assertEquals(Boolean.TRUE, oneToMany.getOrphanRemoval());
-
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(null);
- assertNotNull(attributeResource.getAnnotation(JPA.ONE_TO_MANY)); // .getElement);
- }
-
- public void testSetSpecifiedOrphanRemoval2() throws Exception {
- this.createTestEntity();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
- assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE);
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY);
-
- assertEquals(Boolean.TRUE, oneToMany.getOrphanRemoval());
-
- oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(null);
- assertNotNull(attributeResource.getAnnotation(JPA.ONE_TO_MANY));
-
- oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- }
-
- public void testGetSpecifiedOrphanRemovalUpdatesFromResourceModelChange() throws Exception {
- this.createTestEntity();
- this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
-
- assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- OneToMany2_0Annotation oneToMany = (OneToMany2_0Annotation) attributeResource.getAnnotation(JPA.ONE_TO_MANY);
- oneToMany.setOrphanRemoval(Boolean.FALSE);
- getJpaProject().synchronizeContextModel();
-
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- oneToMany.setOrphanRemoval(null);
- getJpaProject().synchronizeContextModel();
- assertNull(mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertSame(oneToManyMapping, persistentAttribute.getMapping());
-
- oneToMany.setOrphanRemoval(Boolean.FALSE);
- attributeResource.setPrimaryAnnotation(null, EmptyIterable.<String>instance());
- getJpaProject().synchronizeContextModel();
-
- assertTrue(persistentAttribute.getMapping().isDefault());
- }
-
- public void testUpdateMapKey() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(oneToManyMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(oneToManyMapping.getSpecifiedMapKey());
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNotNull(mapKey);
-
- //set mapKey name in the resource model, verify context model updated
- mapKey.setName("myMapKey");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey name to null in the resource model
- mapKey.setName(null);
- getJpaProject().synchronizeContextModel();
-
- assertNull(oneToManyMapping.getSpecifiedMapKey());
- assertNull(mapKey.getName());
-
- mapKey.setName("myMapKey");
- attributeResource.removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(oneToManyMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKey() throws Exception {
- createTestEntityWithOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping oneToManyMapping = (OneToManyMapping) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(oneToManyMapping.getSpecifiedMapKey());
- assertNull(attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- oneToManyMapping.setSpecifiedMapKey("myMapKey");
- MapKeyAnnotation mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertEquals("myMapKey", oneToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", mapKey.getName());
-
- //set mapKey to null in the context model
- oneToManyMapping.setSpecifiedMapKey(null);
- assertNull(oneToManyMapping.getSpecifiedMapKey());
- mapKey = (MapKeyAnnotation) attributeResource.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- assertNull(mapKey.getName());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames =
- javaOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertEquals("employee", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) getJavaPersistentType().getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames = javaOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = javaOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertEquals("employee", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testUpdateMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
-
- //set mapKey in the resource model, verify context model does not change
- attributeResource.addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
- MapKeyClass2_0Annotation mapKeyClassAnnotation = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertNotNull(mapKeyClassAnnotation);
-
- //set mapKey name in the resource model, verify context model updated
- mapKeyClassAnnotation.setValue("myMapKeyClass");
- this.getJpaProject().synchronizeContextModel();
- assertEquals("myMapKeyClass", oneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("myMapKeyClass", mapKeyClassAnnotation.getValue());
-
- //set mapKey name to null in the resource model
- mapKeyClassAnnotation.setValue(null);
- this.getJpaProject().synchronizeContextModel();
- assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(mapKeyClassAnnotation.getValue());
-
- mapKeyClassAnnotation.setValue("myMapKeyClass");
- attributeResource.removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testModifyMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
-
- //set mapKey in the context model, verify resource model updated
- oneToManyMapping.setSpecifiedMapKeyClass("String");
- MapKeyClass2_0Annotation mapKeyClass = (MapKeyClass2_0Annotation) attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- assertEquals("String", oneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("String", mapKeyClass.getValue());
-
- //set mapKey to null in the context model
- oneToManyMapping.setSpecifiedMapKeyClass(null);
- assertNull(oneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(attributeResource.getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME));
- }
-
- public void testDefaultMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
-
- assertEquals("java.lang.String", oneToManyMapping.getDefaultMapKeyClass());
-
- //test default still the same when specified target entity it set
- oneToManyMapping.setSpecifiedMapKeyClass("foo");
- assertEquals("java.lang.String", oneToManyMapping.getDefaultMapKeyClass());
- }
-
- public void testDefaultMapKeyClassCollectionType() throws Exception {
- createTestEntityWithValidOneToManyMappingOrphanRemovalSpecified();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
-
- assertNull(oneToManyMapping.getDefaultMapKeyClass());
- }
-
- public void testMapKeyClass() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
-
- assertEquals("java.lang.String", oneToManyMapping.getMapKeyClass());
-
- oneToManyMapping.setSpecifiedMapKeyClass("foo");
- assertEquals("foo", oneToManyMapping.getMapKeyClass());
-
- oneToManyMapping.setSpecifiedMapKeyClass(null);
- assertEquals("java.lang.String", oneToManyMapping.getMapKeyClass());
- }
-
- public void testOrderColumnDefaults() throws Exception {
- createTestEntityPrintQueue();
- createTestEntityPrintJob();
-
- addXmlClassRef(PACKAGE_NAME + ".PrintQueue");
- addXmlClassRef(PACKAGE_NAME + ".PrintJob");
-
- OneToManyMapping oneToManyMapping = (OneToManyMapping) getJavaPersistentType().getAttributeNamed("jobs").getMapping();
-
- Orderable2_0 orderable = ((Orderable2_0) oneToManyMapping.getOrderable());
- OrderColumn2_0 orderColumn = orderable.getOrderColumn();
- assertEquals(true, orderable.isOrderColumnOrdering());
- assertEquals(null, orderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", orderColumn.getDefaultName());
- assertEquals("PrintJob", orderColumn.getTable());
-
- orderColumn.setSpecifiedName("FOO");
- assertEquals("FOO", orderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", orderColumn.getDefaultName());
- assertEquals("PrintJob", orderColumn.getTable());
-
- JavaPersistentType printJobPersistentType = (JavaPersistentType) getPersistenceUnit().getPersistentType("test.PrintJob");
- ((Entity) printJobPersistentType.getMapping()).getTable().setSpecifiedName("MY_TABLE");
-
- assertEquals("MY_TABLE", orderColumn.getTable());
- }
-
- private void createTestEntityPrintQueue() 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.ONE_TO_MANY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ORDER_COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintQueue").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @OneToMany(mappedBy=\"queue\")").append(CR);
- sb.append(" @OrderColumn").append(CR);
- sb.append(" private java.util.List<PrintJob> jobs;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintQueue.java", sourceWriter);
- }
-
- private void createTestEntityPrintJob() 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.MANY_TO_ONE);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintJob").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(" @ManyToOne").append(CR);
- sb.append(" private PrintQueue queue;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintJob.java", sourceWriter);
- }
-
- public void testGetMapKeyColumnMappedByStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- oneToManyMapping.getRelationship().setStrategyToMappedBy();
- oneToManyMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("employee");
-
- assertNull(oneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("addresses_KEY", oneToManyMapping.getMapKeyColumn().getName());
- assertEquals("Address", oneToManyMapping.getMapKeyColumn().getTable());//owing entity table name
-
- Entity addressEntity = getPersistenceUnit().getEntity("test.Address");
- addressEntity.getTable().setSpecifiedName("MY_PRIMARY_TABLE");
- assertEquals("MY_PRIMARY_TABLE", oneToManyMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", oneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", oneToManyMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", oneToManyMapping.getMapKeyColumn().getDefaultName());
- }
-
- public void testGetMapKeyColumnJoinTableStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
-
- assertNull(oneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("addresses_KEY", oneToManyMapping.getMapKeyColumn().getName());
- assertEquals(TYPE_NAME + "_Address", oneToManyMapping.getMapKeyColumn().getTable());//join table name
-
- oneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("MY_PRIMARY_TABLE");
- assertEquals("MY_PRIMARY_TABLE", oneToManyMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", oneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", oneToManyMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", oneToManyMapping.getMapKeyColumn().getDefaultName());
- }
-
- public void testTargetForeignKeyJoinColumnStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- ((JoinColumnRelationship) oneToManyMapping.getRelationship()).setStrategyToJoinColumn();
-
- JoinColumn joinColumn = ((JoinColumnRelationship) oneToManyMapping.getRelationship()).getJoinColumnStrategy().specifiedJoinColumns().next();
-
- assertEquals("addresses_id", joinColumn.getDefaultName());
- assertEquals("Address", joinColumn.getDefaultTable());//target table name
-
- Entity addressEntity = getPersistenceUnit().getEntity("test.Address");
- addressEntity.getTable().setSpecifiedName("ADDRESS_PRIMARY_TABLE");
- assertEquals("ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable());
-
- joinColumn.setSpecifiedName("FOO");
- assertEquals("addresses_id", joinColumn.getDefaultName());
- assertEquals("FOO", joinColumn.getSpecifiedName());
- assertEquals("ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable());
- }
-
- //target foreign key case
- public void testGetMapKeyColumnJoinColumnStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- ((JoinColumnRelationship) oneToManyMapping.getRelationship()).setStrategyToJoinColumn();
-
- assertNull(oneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("addresses_KEY", oneToManyMapping.getMapKeyColumn().getName());
- assertEquals("Address", oneToManyMapping.getMapKeyColumn().getTable());//target table name
-
- Entity addressEntity = getPersistenceUnit().getEntity("test.Address");
- addressEntity.getTable().setSpecifiedName("ADDRESS_PRIMARY_TABLE");
- assertEquals("ADDRESS_PRIMARY_TABLE", oneToManyMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", oneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", oneToManyMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", oneToManyMapping.getMapKeyColumn().getDefaultName());
- assertEquals("ADDRESS_PRIMARY_TABLE", oneToManyMapping.getMapKeyColumn().getDefaultTable());
- }
-
- //target foreign key case
- public void testOrderColumnDefaultsJoinColumnStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
-
- PersistentAttribute persistentAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 oneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- ((JoinColumnRelationship) oneToManyMapping.getRelationship()).setStrategyToJoinColumn();
- ((Orderable2_0) oneToManyMapping.getOrderable()).setOrderColumnOrdering(true);
- OrderColumn2_0 orderColumn = ((Orderable2_0) oneToManyMapping.getOrderable()).getOrderColumn();
-
-
- assertNull(orderColumn.getSpecifiedName());
- assertEquals("addresses_ORDER", orderColumn.getName());
- assertEquals("Address", orderColumn.getTable());//target table name
-
- Entity addressEntity = getPersistenceUnit().getEntity("test.Address");
- addressEntity.getTable().setSpecifiedName("ADDRESS_PRIMARY_TABLE");
- assertEquals("ADDRESS_PRIMARY_TABLE", orderColumn.getTable());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- OneToManyAnnotation annotation = (OneToManyAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_MANY);
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 mapping = (OneToManyMapping2_0) contextAttribute.getMapping();
- OneToManyRelationship2_0 rel = (OneToManyRelationship2_0) mapping.getRelationship();
-
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinColumn();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToMappedBy();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinTable();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntity();
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- JavaResourcePersistentAttribute resourceAttribute = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME).persistableAttributes().next();
- OneToManyAnnotation annotation = (OneToManyAnnotation) resourceAttribute.getAnnotation(JPA.ONE_TO_MANY);
- PersistentAttribute contextAttribute = getJavaPersistentType().attributes().next();
- OneToManyMapping2_0 mapping = (OneToManyMapping2_0) contextAttribute.getMapping();
- OneToManyRelationship2_0 rel = (OneToManyRelationship2_0) mapping.getRelationship();
-
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- annotation.setMappedBy("foo");
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceAttribute.addAnnotation(JPA.JOIN_TABLE);
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceAttribute.addAnnotation(JPA.JOIN_COLUMN);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNotNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- annotation.setMappedBy(null);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceAttribute.removeAnnotation(JPA.JOIN_TABLE);
- getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceAttribute.removeAnnotation(JPA.JOIN_COLUMN);
- getJpaProject().synchronizeContextModel();
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_COLUMN));
- assertNull(resourceAttribute.getAnnotation(JPA.JOIN_TABLE));
- assertNull(annotation.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testMapKeySpecifiedAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
-
- ListIterator<JavaAttributeOverride> specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.BAR");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAZ");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BLAH");
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- attributeResource.moveAnnotation(1, 0, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(1, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("BLAH", specifiedMapKeyAttributeOverrides.next().getName());
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("value.BAR", specifiedMapKeyAttributeOverrides.next().getName());
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
-
- attributeResource.removeAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- getJpaProject().synchronizeContextModel();
- specifiedMapKeyAttributeOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertFalse(specifiedMapKeyAttributeOverrides.hasNext());
- }
-
- public void testMapKeyValueVirtualAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- assertEquals("parcels", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- ReadOnlyAttributeOverride defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_PropertyInfo", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
-
- ListIterator<ClassRef> classRefs = getPersistenceUnit().specifiedClassRefs();
- classRefs.next();
- Embeddable addressEmbeddable = (Embeddable) classRefs.next().getJavaPersistentType().getMapping();
-
- BasicMapping cityMapping = (BasicMapping) addressEmbeddable.getPersistentType().getAttributeNamed("city").getMapping();
- cityMapping.getColumn().setSpecifiedName("FOO");
- cityMapping.getColumn().setSpecifiedTable("BAR");
- cityMapping.getColumn().setColumnDefinition("COLUMN_DEF");
- cityMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- cityMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- cityMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- cityMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- cityMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- assertEquals("parcels", attributeResource.getName());
- assertNull(attributeResource.getAnnotation(AttributeOverrideAnnotation.ANNOTATION_NAME));
- assertNull(attributeResource.getAnnotation(AttributeOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("FOO", defaultAttributeOverride.getColumn().getName());
- assertEquals("BAR", defaultAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEF", defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(false, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(5, defaultAttributeOverride.getColumn().getLength());
- assertEquals(6, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(7, defaultAttributeOverride.getColumn().getScale());
-
- cityMapping.getColumn().setSpecifiedName(null);
- cityMapping.getColumn().setSpecifiedTable(null);
- cityMapping.getColumn().setColumnDefinition(null);
- cityMapping.getColumn().setSpecifiedInsertable(null);
- cityMapping.getColumn().setSpecifiedUpdatable(null);
- cityMapping.getColumn().setSpecifiedUnique(null);
- cityMapping.getColumn().setSpecifiedNullable(null);
- cityMapping.getColumn().setSpecifiedLength(null);
- cityMapping.getColumn().setSpecifiedPrecision(null);
- cityMapping.getColumn().setSpecifiedScale(null);
- defaultAttributeOverride = mapKeyAttributeOverrideContainer.virtualOverrides().next();
- assertEquals("city", defaultAttributeOverride.getName());
- assertEquals("city", defaultAttributeOverride.getColumn().getName());
- assertEquals(TYPE_NAME +"_PropertyInfo", defaultAttributeOverride.getColumn().getTable());
- assertEquals(null, defaultAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, defaultAttributeOverride.getColumn().isInsertable());
- assertEquals(true, defaultAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, defaultAttributeOverride.getColumn().isUnique());
- assertEquals(true, defaultAttributeOverride.getColumn().isNullable());
- assertEquals(255, defaultAttributeOverride.getColumn().getLength());
- assertEquals(0, defaultAttributeOverride.getColumn().getPrecision());
- assertEquals(0, defaultAttributeOverride.getColumn().getScale());
-
- AttributeOverrideAnnotation annotation = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- annotation.setName("key.city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testMapKeyValueSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(0, mapKeyAttributeOverrideContainer.specifiedOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.FOO2");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(3, mapKeyAttributeOverrideContainer.specifiedOverridesSize());
- }
-
- public void testMapKeyValueAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(4, mapKeyAttributeOverrideContainer.overridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("value.FOO2");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(7, mapKeyAttributeOverrideContainer.overridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("city");
- getJpaProject().synchronizeContextModel();
- assertEquals(7, mapKeyAttributeOverrideContainer.overridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.state.foo");
- getJpaProject().synchronizeContextModel();
- assertEquals(7, mapKeyAttributeOverrideContainer.overridesSize());
- }
-
- public void testMapKeyValueVirtualAttributeOverridesSize() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- //add an annotation to the resource model and verify the context model is updated
- AttributeOverrideAnnotation attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("FOO");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.BAR");
- getJpaProject().synchronizeContextModel();
-
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.city");
- getJpaProject().synchronizeContextModel();
- assertEquals(3, mapKeyAttributeOverrideContainer.virtualOverridesSize());
-
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("key.state.foo");
- attributeOverride = (AttributeOverrideAnnotation) attributeResource.addAnnotation(0, JPA.ATTRIBUTE_OVERRIDE, JPA.ATTRIBUTE_OVERRIDES);
- attributeOverride.setName("size");
- getJpaProject().synchronizeContextModel();
- assertEquals(2, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
- public void testMapKeyValueAttributeOverrideSetVirtual() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.state.foo", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- mapKeyAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertEquals("key.state.foo", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- mapKeyAttributeOverrideContainer.specifiedOverrides().next().convertToVirtual();
- attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
- assertFalse(attributeOverrides.hasNext());
-
- Iterator<JavaVirtualAttributeOverride> virtualAttributeOverrides = mapKeyAttributeOverrideContainer.virtualOverrides();
- assertEquals("city", virtualAttributeOverrides.next().getName());
- assertEquals("state.foo", virtualAttributeOverrides.next().getName());
- assertEquals("state.address", virtualAttributeOverrides.next().getName());
- assertEquals("zip", virtualAttributeOverrides.next().getName());
- assertEquals(4, mapKeyAttributeOverrideContainer.virtualOverridesSize());
- }
-
-
- public void testMapKeyValueMoveSpecifiedAttributeOverride() throws Exception {
- createTestEntityWithEmbeddableKeyOneToManyMapping();
- createTestEmbeddableAddress();
- createTestEmbeddableState();
- createTestEntityPropertyInfo();
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".PropertyInfo");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- JavaOneToManyMapping2_0 oneToManyMapping = (JavaOneToManyMapping2_0) getJavaPersistentType().getAttributeNamed("parcels").getMapping();
- JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer = oneToManyMapping.getMapKeyAttributeOverrideContainer();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
- mapKeyAttributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- ListIterator<JavaAttributeOverride> specifiedOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("city", specifiedOverrides.next().getName());
- assertEquals("state.foo", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
-
- attributeResource.moveAnnotation(1, 0, AttributeOverridesAnnotation.ANNOTATION_NAME);
- getJpaProject().synchronizeContextModel();
-
- Iterator<NestableAnnotation> attributeOverrides = attributeResource.annotations(AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME);
-
- assertEquals("key.state.foo", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertEquals("key.city", ((AttributeOverrideAnnotation) attributeOverrides.next()).getName());
- assertFalse(attributeOverrides.hasNext());
-
- specifiedOverrides = mapKeyAttributeOverrideContainer.specifiedOverrides();
- assertEquals("state.foo", specifiedOverrides.next().getName());
- assertEquals("city", specifiedOverrides.next().getName());
- assertFalse(specifiedOverrides.hasNext());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java
deleted file mode 100644
index 8d0d5add4c..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/EclipseLink2_0JavaOneToOneMappingTests.java
+++ /dev/null
@@ -1,818 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v2_0.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.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-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.JavaBasicMapping;
-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.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.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0JavaOneToOneMappingTests
- extends EclipseLink2_0ContextModelTestCase
-{
- public EclipseLink2_0JavaOneToOneMappingTests(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 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 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 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 testUpdateDerivedId() 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 testSetDerivedId() 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 {
- createTestEntity();
- 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("address");
- JavaOneToOneMapping2_0 contextMapping = (JavaOneToOneMapping2_0) contextAttribute.getMapping();
-
- assertNull(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 testMorphMapping() 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");
-
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertTrue(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
- assertNull(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertTrue(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
- assertNull(((JavaOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertTrue(((JavaManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
- assertNull(((JavaManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- // this is no longer supported (it was a bit of a testing hack anyway...)
- // contextAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- // the *real* test is whether the Id annotation still results in a 1:1 mapping...
- contextAttribute.setMappingKey(null); // clear any mapping annotation
- resourceAttribute.addAnnotation(JPA.ID); // add Id annotation
- this.getJpaProject().synchronizeContextModel();
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
- assertTrue(contextAttribute.getMapping() instanceof JavaOneToOneMapping2_0);
-
- contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertNotNull(resourceAttribute.getAnnotation(JPA.ID));
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
- assertTrue(contextAttribute.getMapping() instanceof JavaManyToOneMapping2_0);
-
- contextAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertNull(resourceAttribute.getAnnotation(JPA.ID));
- assertNull(resourceAttribute.getAnnotation(JPA2_0.MAPS_ID));
- assertTrue(contextAttribute.getMapping() instanceof JavaBasicMapping);
- }
-
- 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());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/JptEclipseLink2_0JavaContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/JptEclipseLink2_0JavaContextModelTests.java
deleted file mode 100644
index e2b65fa942..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/java/JptEclipseLink2_0JavaContextModelTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.java;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptEclipseLink2_0JavaContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink2_0JavaContextModelTests.class.getName());
- suite.addTestSuite(EclipseLink2_0JavaCollectionTableTests.class);
- suite.addTestSuite(EclipseLink2_0JavaElementCollectionMappingTests.class);
- suite.addTestSuite(EclipseLink2_0JavaEntityTests.class);
- suite.addTestSuite(EclipseLink2_0JavaManyToManyMappingTests.class);
- suite.addTestSuite(EclipseLink2_0JavaManyToOneMappingTests.class);
- suite.addTestSuite(EclipseLink2_0JavaMappedSuperclassTests.class);
- suite.addTestSuite(EclipseLink2_0JavaOneToManyMappingTests.class);
- suite.addTestSuite(EclipseLink2_0JavaOneToOneMappingTests.class);
- return suite;
- }
-
- private JptEclipseLink2_0JavaContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmCollectionTableTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmCollectionTableTests.java
deleted file mode 100644
index 89fb8aafb3..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmCollectionTableTests.java
+++ /dev/null
@@ -1,752 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.CollectionTable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCollectionTable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmCollectionTable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlCollectionTable;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlElementCollection_2_0;
-import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmCollectionTableTests extends EclipseLink2_0OrmContextModelTestCase
-{
- public EclipseLink2_0OrmCollectionTableTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString());
- getXmlPersistenceUnit().getMappingFiles().add(mappingFileRef);
- getPersistenceXmlResource().save(null);
- }
-
- private ICompilationUnit createTestEntityWithValidElementCollection() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID, "java.util.Collection");
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ElementCollection").append(CR);
- sb.append(" private Collection<String> projects;").append(CR);
- sb.append("@Id").append(CR);
- }
- });
- }
-
- public void testUpdateSpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = elementCollectionMapping.getCollectionTable();
-
- assertNull(ormCollectionTable.getSpecifiedName());
- assertNull(resourceElementCollection.getCollectionTable());
-
-
- //set name in the resource model, verify context model updated
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- resourceElementCollection.getCollectionTable().setName("FOO");
- assertEquals("FOO", ormCollectionTable.getSpecifiedName());
- assertEquals("FOO", resourceElementCollection.getCollectionTable().getName());
-
- //set name to null in the resource model
- resourceElementCollection.getCollectionTable().setName(null);
- assertNull(ormCollectionTable.getSpecifiedName());
- assertNull(resourceElementCollection.getCollectionTable().getName());
-
- resourceElementCollection.getCollectionTable().setName("FOO");
- assertEquals("FOO", ormCollectionTable.getSpecifiedName());
- assertEquals("FOO", resourceElementCollection.getCollectionTable().getName());
-
- resourceElementCollection.setCollectionTable(null);
- assertNull(ormCollectionTable.getSpecifiedName());
- assertNull(resourceElementCollection.getCollectionTable());
- }
-
- public void testModifySpecifiedName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = elementCollectionMapping.getCollectionTable();
-
- assertNull(ormCollectionTable.getSpecifiedName());
- assertNull(resourceElementCollection.getCollectionTable());
-
- //set name in the context model, verify resource model modified
- ormCollectionTable.setSpecifiedName("foo");
- assertEquals("foo", ormCollectionTable.getSpecifiedName());
- assertEquals("foo", resourceElementCollection.getCollectionTable().getName());
-
- //set name to null in the context model
- ormCollectionTable.setSpecifiedName(null);
- assertNull(ormCollectionTable.getSpecifiedName());
- assertNull(resourceElementCollection.getCollectionTable());
- }
-
- public void testVirtualCollectionTable() throws Exception {
- createTestEntityWithValidElementCollection();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("projects");
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- CollectionTable2_0 virtualCollectionTable = virtualElementCollectionMapping.getCollectionTable();
-
- assertTrue(ormPersistentAttribute.isVirtual());
- assertEquals(TYPE_NAME + "_projects", virtualCollectionTable.getName());
- assertNull(virtualCollectionTable.getSpecifiedCatalog());
- assertNull(virtualCollectionTable.getSpecifiedSchema());
- assertEquals(0, virtualCollectionTable.specifiedJoinColumnsSize());
- JoinColumn virtualJoinColumn = virtualCollectionTable.getDefaultJoinColumn();
- assertEquals(TYPE_NAME + "_id", virtualJoinColumn.getDefaultName());
- assertEquals("id", virtualJoinColumn.getDefaultReferencedColumnName());
-
- JavaPersistentAttribute javaPersistentAttribute = ormPersistentAttribute.getJavaPersistentAttribute();
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) javaPersistentAttribute.getMapping();
- JavaCollectionTable2_0 javaCollectionTable = javaElementCollectionMapping.getCollectionTable();
- javaCollectionTable.setSpecifiedName("FOO");
- javaCollectionTable.setSpecifiedCatalog("CATALOG");
- javaCollectionTable.setSpecifiedSchema("SCHEMA");
- JavaJoinColumn javaJoinColumn = javaCollectionTable.addSpecifiedJoinColumn(0);
- javaJoinColumn.setSpecifiedName("NAME");
- javaJoinColumn.setSpecifiedReferencedColumnName("REFERENCED_NAME");
-
- assertEquals("FOO", virtualCollectionTable.getSpecifiedName());
- assertEquals("CATALOG", virtualCollectionTable.getSpecifiedCatalog());
- assertEquals("SCHEMA", virtualCollectionTable.getSpecifiedSchema());
- assertEquals(1, virtualCollectionTable.specifiedJoinColumnsSize());
- virtualJoinColumn = virtualCollectionTable.specifiedJoinColumns().next();
- assertEquals("NAME", virtualJoinColumn.getSpecifiedName());
- assertEquals("REFERENCED_NAME", virtualJoinColumn.getSpecifiedReferencedColumnName());
- }
-
- public void testUpdateDefaultNameFromJavaTable() throws Exception {
- createTestEntityWithValidElementCollection();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "projects");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- assertEquals(TYPE_NAME + "_projects", ormCollectionTable.getDefaultName());
-
- ((JavaEntity) ormPersistentType.getJavaPersistentType().getMapping()).setSpecifiedName("Foo");
- assertEquals("Foo_projects", ormCollectionTable.getDefaultName());
-
- ((OrmEntity) ormPersistentType.getMapping()).setSpecifiedName("Bar");
- assertEquals("Bar_projects", ormCollectionTable.getDefaultName());
-
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("projects").getMapping();
- javaElementCollectionMapping.getCollectionTable().setSpecifiedName("JAVA_COLLECTION_TABLE");
-
- assertEquals("Bar_projects", ormCollectionTable.getDefaultName());
-
-
- //set metadata-complete to true, will ignore java annotation settings
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertEquals("Bar_projects", ormCollectionTable.getDefaultName());
-
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- //remove element collection mapping from the orm.xml file
- ormPersistentAttribute.convertToVirtual();
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null);
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("projects");
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute2.getMapping();
- CollectionTable2_0 virtualCollectionTable = virtualElementCollectionMapping.getCollectionTable();
- assertTrue(ormPersistentAttribute2.isVirtual());
- assertEquals("JAVA_COLLECTION_TABLE", virtualCollectionTable.getSpecifiedName());//specifiedName since this is a virtual mapping now
-
- javaElementCollectionMapping.getCollectionTable().setSpecifiedName(null);
- assertNull(virtualCollectionTable.getSpecifiedName());
- assertEquals("Bar_projects", virtualCollectionTable.getDefaultName());
- }
-
- public void testUpdateSpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- assertNull(ormCollectionTable.getSpecifiedSchema());
- assertNull(resourceElementCollection.getCollectionTable());
-
- //set schema in the resource model, verify context model updated
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- resourceElementCollection.getCollectionTable().setSchema("FOO");
- assertEquals("FOO", ormCollectionTable.getSpecifiedSchema());
- assertEquals("FOO", resourceElementCollection.getCollectionTable().getSchema());
-
- //set Schema to null in the resource model
- resourceElementCollection.getCollectionTable().setSchema(null);
- assertNull(ormCollectionTable.getSpecifiedSchema());
- assertNull(resourceElementCollection.getCollectionTable().getSchema());
-
- resourceElementCollection.getCollectionTable().setSchema("FOO");
- assertEquals("FOO", ormCollectionTable.getSpecifiedSchema());
- assertEquals("FOO", resourceElementCollection.getCollectionTable().getSchema());
-
- resourceElementCollection.setCollectionTable(null);
- assertNull(ormCollectionTable.getSpecifiedSchema());
- assertNull(resourceElementCollection.getCollectionTable());
- }
-
- public void testModifySpecifiedSchema() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- assertNull(ormCollectionTable.getSpecifiedSchema());
- assertNull(resourceElementCollection.getCollectionTable());
-
- //set Schema in the context model, verify resource model modified
- ormCollectionTable.setSpecifiedSchema("foo");
- assertEquals("foo", ormCollectionTable.getSpecifiedSchema());
- assertEquals("foo", resourceElementCollection.getCollectionTable().getSchema());
-
- //set Schema to null in the context model
- ormCollectionTable.setSpecifiedSchema(null);
- assertNull(ormCollectionTable.getSpecifiedSchema());
- assertNull(resourceElementCollection.getCollectionTable());
- }
-
- public void testUpdateSpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- assertNull(ormCollectionTable.getSpecifiedCatalog());
- assertNull(resourceElementCollection.getCollectionTable());
-
- //set Catalog in the resource model, verify context model updated
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- resourceElementCollection.getCollectionTable().setCatalog("FOO");
- assertEquals("FOO", ormCollectionTable.getSpecifiedCatalog());
- assertEquals("FOO", resourceElementCollection.getCollectionTable().getCatalog());
-
- //set Catalog to null in the resource model
- resourceElementCollection.getCollectionTable().setCatalog(null);
- assertNull(ormCollectionTable.getSpecifiedCatalog());
- assertNull(resourceElementCollection.getCollectionTable().getCatalog());
-
- resourceElementCollection.getCollectionTable().setCatalog("FOO");
- assertEquals("FOO", ormCollectionTable.getSpecifiedCatalog());
- assertEquals("FOO", resourceElementCollection.getCollectionTable().getCatalog());
-
- resourceElementCollection.setCollectionTable(null);
- assertNull(ormCollectionTable.getSpecifiedCatalog());
- assertNull(resourceElementCollection.getCollectionTable());
- }
-
- public void testModifySpecifiedCatalog() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- assertNull(ormCollectionTable.getSpecifiedCatalog());
- assertNull(resourceElementCollection.getCollectionTable());
-
- //set Catalog in the context model, verify resource model modified
- ormCollectionTable.setSpecifiedCatalog("foo");
- assertEquals("foo", ormCollectionTable.getSpecifiedCatalog());
- assertEquals("foo", resourceElementCollection.getCollectionTable().getCatalog());
-
- //set Catalog to null in the context model
- ormCollectionTable.setSpecifiedCatalog(null);
- assertNull(ormCollectionTable.getSpecifiedCatalog());
- assertNull(resourceElementCollection.getCollectionTable());
- }
-
- public void testAddSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- OrmJoinColumn joinColumn = ormCollectionTable.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName("FOO");
-
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
- assertEquals("FOO", resourceCollectionTable.getJoinColumns().get(0).getName());
-
- OrmJoinColumn joinColumn2 = ormCollectionTable.addSpecifiedJoinColumn(0);
- joinColumn2.setSpecifiedName("BAR");
-
- assertEquals("BAR", resourceCollectionTable.getJoinColumns().get(0).getName());
- assertEquals("FOO", resourceCollectionTable.getJoinColumns().get(1).getName());
-
- OrmJoinColumn joinColumn3 = ormCollectionTable.addSpecifiedJoinColumn(1);
- joinColumn3.setSpecifiedName("BAZ");
-
- assertEquals("BAR", resourceCollectionTable.getJoinColumns().get(0).getName());
- assertEquals("BAZ", resourceCollectionTable.getJoinColumns().get(1).getName());
- assertEquals("FOO", resourceCollectionTable.getJoinColumns().get(2).getName());
-
- ListIterator<OrmJoinColumn> joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals(joinColumn2, joinColumns.next());
- assertEquals(joinColumn3, joinColumns.next());
- assertEquals(joinColumn, joinColumns.next());
-
- joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- }
-
- public void testRemoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- ormCollectionTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormCollectionTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormCollectionTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
- assertEquals(3, resourceCollectionTable.getJoinColumns().size());
-
- ormCollectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(2, resourceCollectionTable.getJoinColumns().size());
- assertEquals("BAR", resourceCollectionTable.getJoinColumns().get(0).getName());
- assertEquals("BAZ", resourceCollectionTable.getJoinColumns().get(1).getName());
-
- ormCollectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(1, resourceCollectionTable.getJoinColumns().size());
- assertEquals("BAZ", resourceCollectionTable.getJoinColumns().get(0).getName());
-
- ormCollectionTable.removeSpecifiedJoinColumn(0);
- assertEquals(0, resourceCollectionTable.getJoinColumns().size());
- }
-
- public void testMoveSpecifiedJoinColumn() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
-
- ormCollectionTable.addSpecifiedJoinColumn(0).setSpecifiedName("FOO");
- ormCollectionTable.addSpecifiedJoinColumn(1).setSpecifiedName("BAR");
- ormCollectionTable.addSpecifiedJoinColumn(2).setSpecifiedName("BAZ");
-
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
- assertEquals(3, resourceCollectionTable.getJoinColumns().size());
-
-
- ormCollectionTable.moveSpecifiedJoinColumn(2, 0);
- ListIterator<OrmJoinColumn> joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAR", resourceCollectionTable.getJoinColumns().get(0).getName());
- assertEquals("BAZ", resourceCollectionTable.getJoinColumns().get(1).getName());
- assertEquals("FOO", resourceCollectionTable.getJoinColumns().get(2).getName());
-
-
- ormCollectionTable.moveSpecifiedJoinColumn(0, 1);
- joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
-
- assertEquals("BAZ", resourceCollectionTable.getJoinColumns().get(0).getName());
- assertEquals("BAR", resourceCollectionTable.getJoinColumns().get(1).getName());
- assertEquals("FOO", resourceCollectionTable.getJoinColumns().get(2).getName());
- }
-
-
- public void testUpdateJoinColumns() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- resourceCollectionTable.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
- resourceCollectionTable.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
- resourceCollectionTable.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
-
- resourceCollectionTable.getJoinColumns().get(0).setName("FOO");
- resourceCollectionTable.getJoinColumns().get(1).setName("BAR");
- resourceCollectionTable.getJoinColumns().get(2).setName("BAZ");
-
- ListIterator<OrmJoinColumn> joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("FOO", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- resourceCollectionTable.getJoinColumns().move(2, 0);
- joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- resourceCollectionTable.getJoinColumns().move(0, 1);
- joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("BAR", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- resourceCollectionTable.getJoinColumns().remove(1);
- joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertEquals("FOO", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- resourceCollectionTable.getJoinColumns().remove(1);
- joinColumns = ormCollectionTable.specifiedJoinColumns();
- assertEquals("BAZ", joinColumns.next().getName());
- assertFalse(joinColumns.hasNext());
-
- resourceCollectionTable.getJoinColumns().remove(0);
- assertFalse(ormCollectionTable.specifiedJoinColumns().hasNext());
- }
-
- public void testUniqueConstraints() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("bar", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("foo", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsSize() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- assertEquals(0, ormCollectionTable.uniqueConstraintsSize());
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "foo");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "bar");
-
- assertEquals(2, ormCollectionTable.uniqueConstraintsSize());
- }
-
- public void testAddUniqueConstraint() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "BAR");
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = resourceCollectionTable.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testAddUniqueConstraint2() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormCollectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "BAZ");
-
- ListIterator<XmlUniqueConstraint> uniqueConstraints = resourceCollectionTable.getUniqueConstraints().listIterator();
-
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().get(0));
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testRemoveUniqueConstraint() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormCollectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormCollectionTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, resourceCollectionTable.getUniqueConstraints().size());
-
- ormCollectionTable.removeUniqueConstraint(1);
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = resourceCollectionTable.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- Iterator<OrmUniqueConstraint> uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- ormCollectionTable.removeUniqueConstraint(1);
- uniqueConstraintResources = resourceCollectionTable.getUniqueConstraints().listIterator();
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- assertFalse(uniqueConstraintResources.hasNext());
-
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
-
- ormCollectionTable.removeUniqueConstraint(0);
- uniqueConstraintResources = resourceCollectionTable.getUniqueConstraints().listIterator();
- assertFalse(uniqueConstraintResources.hasNext());
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testMoveUniqueConstraint() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- ormCollectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- ormCollectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- ormCollectionTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- assertEquals(3, resourceCollectionTable.getUniqueConstraints().size());
-
-
- ormCollectionTable.moveUniqueConstraint(2, 0);
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
-
- ListIterator<XmlUniqueConstraint> uniqueConstraintResources = resourceCollectionTable.getUniqueConstraints().listIterator();
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
-
-
- ormCollectionTable.moveUniqueConstraint(0, 1);
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
-
- uniqueConstraintResources = resourceCollectionTable.getUniqueConstraints().listIterator();
- assertEquals("BAZ", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("BAR", uniqueConstraintResources.next().getColumnNames().get(0));
- assertEquals("FOO", uniqueConstraintResources.next().getColumnNames().get(0));
- }
-
- public void testUpdateUniqueConstraints() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 resourceElementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- OrmCollectionTable2_0 ormCollectionTable = ormElementCollectionMapping.getCollectionTable();
- resourceElementCollection.setCollectionTable(OrmFactory.eINSTANCE.createXmlCollectionTable());
- XmlCollectionTable resourceCollectionTable = resourceElementCollection.getCollectionTable();
-
- XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(0, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "FOO");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(1, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAR");
-
- uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- resourceCollectionTable.getUniqueConstraints().add(2, uniqueConstraintResource);
- uniqueConstraintResource.getColumnNames().add(0, "BAZ");
-
-
- ListIterator<OrmUniqueConstraint> uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- resourceCollectionTable.getUniqueConstraints().move(2, 0);
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- resourceCollectionTable.getUniqueConstraints().move(0, 1);
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- resourceCollectionTable.getUniqueConstraints().remove(1);
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- resourceCollectionTable.getUniqueConstraints().remove(1);
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- resourceCollectionTable.getUniqueConstraints().remove(0);
- uniqueConstraints = ormCollectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
- }
-
- public void testUniqueConstraintsFromJava() throws Exception {
- createTestEntityWithValidElementCollection();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentType.attributes().next().getMapping();
- CollectionTable2_0 virtualCollectionTable = virtualElementCollectionMapping.getCollectionTable();
-
- assertTrue(ormPersistentType.attributes().next().isVirtual());
-
- ListIterator<UniqueConstraint> uniqueConstraints = (ListIterator<UniqueConstraint>) virtualCollectionTable.uniqueConstraints();
- assertFalse(uniqueConstraints.hasNext());
-
- JavaElementCollectionMapping2_0 javaElementCollectionMapping2_0 = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().attributes().next().getMapping();
- JavaCollectionTable2_0 javaCollectionTable = javaElementCollectionMapping2_0.getCollectionTable();
-
- javaCollectionTable.addUniqueConstraint(0).addColumnName(0, "FOO");
- javaCollectionTable.addUniqueConstraint(1).addColumnName(0, "BAR");
- javaCollectionTable.addUniqueConstraint(2).addColumnName(0, "BAZ");
-
- uniqueConstraints = (ListIterator<UniqueConstraint>) virtualCollectionTable.uniqueConstraints();
- assertTrue(uniqueConstraints.hasNext());
- assertEquals("FOO", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAR", uniqueConstraints.next().getColumnNames().iterator().next());
- assertEquals("BAZ", uniqueConstraints.next().getColumnNames().iterator().next());
- assertFalse(uniqueConstraints.hasNext());
-
- ormPersistentType.attributes().next().convertToSpecified();
-
- virtualElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.attributes().next().getMapping();
- assertEquals(0, virtualElementCollectionMapping.getCollectionTable().uniqueConstraintsSize());
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmContextModelTestCase.java
deleted file mode 100644
index c5828b93cb..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmContextModelTestCase.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.JpaFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProperties;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.operations.EclipseLinkOrmFileCreationOperation;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_0.EclipseLink2_0;
-import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.v2_0.context.EclipseLink2_0ContextModelTestCase;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-@SuppressWarnings("nls")
-public abstract class EclipseLink2_0OrmContextModelTestCase
- extends EclipseLink2_0ContextModelTestCase
-{
- protected JpaXmlResource eclipseLink2_0OrmXmlResource;
-
-
- protected EclipseLink2_0OrmContextModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.eclipseLink2_0OrmXmlResource = getJpaProject().getDefaultEclipseLinkOrmXmlResource();
- }
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- // don't create default orm.xml - instead build eclipselink-orm.xml
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.FALSE);
- return dataModel;
- }
-
- @Override
- protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild, IDataModel jpaConfig) throws Exception {
- TestJpaProject testJpaProject = super.buildJpaProject(projectName, autoBuild, jpaConfig);
-
- EclipseLinkOrmFileCreationOperation operation =
- new EclipseLinkOrmFileCreationOperation(buildEclipseLinkOrmConfig(testJpaProject));
- operation.execute(null, null);
-
- return testJpaProject;
- }
-
- protected IDataModel buildEclipseLinkOrmConfig(TestJpaProject testJpaProject) {
- IDataModel dataModel =
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider());
- dataModel.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
- testJpaProject.getProject().getFolder("src/META-INF").getFullPath());
- dataModel.setProperty(JpaFileCreationDataModelProperties.VERSION, EclipseLink2_0.SCHEMA_VERSION);
- dataModel.setProperty(OrmFileCreationDataModelProperties.ADD_TO_PERSISTENCE_UNIT, Boolean.TRUE);
- return dataModel;
- }
-
- @Override
- protected void tearDown() throws Exception {
- this.eclipseLink2_0OrmXmlResource = null;
- super.tearDown();
- }
-
- @Override
- protected JpaXmlResource getOrmXmlResource() {
- return this.eclipseLink2_0OrmXmlResource;
- }
-
- @Override
- protected XmlEntityMappings getXmlEntityMappings() {
- return (XmlEntityMappings) super.getXmlEntityMappings();
- }
-
- @Override
- protected EclipseLinkEntityMappings getEntityMappings() {
- return (EclipseLinkEntityMappings) super.getEntityMappings();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
deleted file mode 100644
index 2a541bc9c5..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmElementCollectionMappingTests.java
+++ /dev/null
@@ -1,1446 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn;
-import org.eclipse.jpt.jpa.core.context.TransientMapping;
-import org.eclipse.jpt.jpa.core.context.VersionMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-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.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlElementCollection;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlElementCollection_2_0;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmElementCollectionMappingTests extends EclipseLink2_0OrmContextModelTestCase
-{
- private static final String ATTRIBUTE_OVERRIDE_NAME = "city";
- private static final String ATTRIBUTE_OVERRIDE_COLUMN_NAME = "E_CITY";
-
- public EclipseLink2_0OrmElementCollectionMappingTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntityWithElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection(targetClass=String.class, fetch=FetchType.EAGER)");
- sb.append(CR);
- sb.append(" private java.util.Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- private void createTestTargetEmbeddableAddress() 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("import ");
- sb.append(JPA.ID);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.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 ICompilationUnit createTestEntityWithEmbeddableElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.FETCH_TYPE, JPA.ATTRIBUTE_OVERRIDE, JPA.COLUMN);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection");
- sb.append(CR);
- sb.append(" @AttributeOverride(name=\"" + ATTRIBUTE_OVERRIDE_NAME + "\", column=@Column(name=\"" + ATTRIBUTE_OVERRIDE_COLUMN_NAME + "\"))");
- sb.append(" private java.util.Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithNonGenericElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithGenericBasicElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection<String> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidMapElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- 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 name;").append(CR);
- sb.append(CR);
- sb.append(" private String abbr;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapElementCollectionMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA2_0.ELEMENT_COLLECTION, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private void createSelfReferentialElementCollection() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ELEMENT_COLLECTION);
- sb.append(";");
- sb.append(CR).append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Foo").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.List<Foo> elementCollection;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Foo.java", sourceWriter);
- }
-
- public void testUpdateName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertEquals("oneToOneMapping", ormElementCollectionMapping.getName());
- assertEquals("oneToOneMapping", elementCollection.getName());
-
- //set name in the resource model, verify context model updated
- elementCollection.setName("newName");
- assertEquals("newName", ormElementCollectionMapping.getName());
- assertEquals("newName", elementCollection.getName());
-
- //set name to null in the resource model
- elementCollection.setName(null);
- assertNull(ormElementCollectionMapping.getName());
- assertNull(elementCollection.getName());
- }
-
- public void testModifyName() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertEquals("oneToOneMapping", ormElementCollectionMapping.getName());
- assertEquals("oneToOneMapping", elementCollection.getName());
-
- //set name in the context model, verify resource model updated
- ormElementCollectionMapping.setName("newName");
- assertEquals("newName", ormElementCollectionMapping.getName());
- assertEquals("newName", elementCollection.getName());
-
- //set name to null in the context model
- ormElementCollectionMapping.setName(null);
- assertNull(ormElementCollectionMapping.getName());
- assertNull(elementCollection.getName());
- }
-
- public void testMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityWithElementCollectionMapping();
- createTestTargetEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- assertEquals("foo", ormElementCollectionMapping.getName());
-
- assertNull(ormElementCollectionMapping.getSpecifiedFetch());
- assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch());
- }
-
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityWithElementCollectionMapping();
- createTestTargetEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertEquals("address", virtualElementCollectionMapping.getName());
- assertEquals(FetchType.EAGER, virtualElementCollectionMapping.getSpecifiedFetch());
- assertEquals("String", virtualElementCollectionMapping.getSpecifiedTargetClass());
-
- ormPersistentAttribute.convertToSpecified();
- ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertEquals("address", ormElementCollectionMapping.getName());
- assertEquals(null, ormElementCollectionMapping.getSpecifiedFetch());
- assertEquals(FetchType.LAZY, ormElementCollectionMapping.getDefaultFetch());
- assertEquals(null, ormElementCollectionMapping.getSpecifiedTargetClass());
- assertEquals(PACKAGE_NAME + ".Address", ormElementCollectionMapping.getDefaultTargetClass());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityWithElementCollectionMapping();
- createTestTargetEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(3, ormPersistentType.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, ormPersistentAttribute.getMappingKey());
-
- ormPersistentAttribute.convertToSpecified(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertEquals("address", ormElementCollectionMapping.getName());
- assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch());
- }
-
- public void testSpecifiedMapping() throws Exception {
- createTestEntityWithElementCollectionMapping();
- createTestTargetEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "address");
- assertEquals(2, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- assertEquals("address", ormElementCollectionMapping.getName());
- assertNull(ormElementCollectionMapping.getSpecifiedFetch());
- assertEquals(FetchType.LAZY, ormElementCollectionMapping.getFetch());
- }
-
-
- public void testMorphToIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof IdMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testMorphToVersionMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof VersionMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testMorphToTransientMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof TransientMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testMorphToEmbeddedMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testMorphToEmbeddedIdMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof EmbeddedIdMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
- }
-
- public void testMorphToManyToManyMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToManyMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
-// assertEquals(FetchType.EAGER, ((ManyToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-
- public void testMorphToOneToManyMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof OneToManyMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
-// assertEquals(FetchType.EAGER, ((OneToManyMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-
- public void testMorphToManyToOneMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof ManyToOneMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
-// assertEquals(FetchType.EAGER, ((ManyToOneMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-
- public void testMorphToBasicMapping() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOne");
-
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- assertFalse(elementCollectionMapping.isDefault());
- elementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertFalse(elementCollectionMapping.isDefault());
-
- ormPersistentAttribute.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- assertEquals(1, ormPersistentType.specifiedAttributesSize());
- assertEquals(ormPersistentAttribute, ormPersistentType.specifiedAttributes().next());
- assertTrue(ormPersistentAttribute.getMapping() instanceof BasicMapping);
- assertEquals("oneToOne", ormPersistentAttribute.getMapping().getName());
-//TODO assertEquals(FetchType.EAGER, ((IBasicMapping) ormPersistentAttribute.getMapping()).getSpecifiedFetch());
- }
-
- public void testUpdateSpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertNull(ormElementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
-
- //set fetch in the resource model, verify context model updated
- elementCollection.setFetch(org.eclipse.jpt.jpa.core.resource.orm.FetchType.EAGER);
- assertEquals(FetchType.EAGER, ormElementCollectionMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.FetchType.EAGER, elementCollection.getFetch());
-
- elementCollection.setFetch(org.eclipse.jpt.jpa.core.resource.orm.FetchType.LAZY);
- assertEquals(FetchType.LAZY, ormElementCollectionMapping.getSpecifiedFetch());
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.FetchType.LAZY, elementCollection.getFetch());
-
- //set fetch to null in the resource model
- elementCollection.setFetch(null);
- assertNull(ormElementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
- }
-
- public void testModifySpecifiedFetch() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertNull(ormElementCollectionMapping.getSpecifiedFetch());
- assertNull(elementCollection.getFetch());
-
- //set fetch in the context model, verify resource model updated
- ormElementCollectionMapping.setSpecifiedFetch(FetchType.EAGER);
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.FetchType.EAGER, elementCollection.getFetch());
- assertEquals(FetchType.EAGER, ormElementCollectionMapping.getSpecifiedFetch());
-
- ormElementCollectionMapping.setSpecifiedFetch(FetchType.LAZY);
- assertEquals(org.eclipse.jpt.jpa.core.resource.orm.FetchType.LAZY, elementCollection.getFetch());
- assertEquals(FetchType.LAZY, ormElementCollectionMapping.getSpecifiedFetch());
-
- //set fetch to null in the context model
- ormElementCollectionMapping.setSpecifiedFetch(null);
- assertNull(elementCollection.getFetch());
- assertNull(ormElementCollectionMapping.getSpecifiedFetch());
- }
-
- public void testUpdateSpecifiedTargetClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollection.getTargetClass());
-
- //set target class in the resource model, verify context model updated
- elementCollection.setTargetClass("newTargetClass");
- assertEquals("newTargetClass", ormElementCollectionMapping.getSpecifiedTargetClass());
- assertEquals("newTargetClass", elementCollection.getTargetClass());
-
- //set target class to null in the resource model
- elementCollection.setTargetClass(null);
- assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollection.getTargetClass());
- }
-
- public void testModifySpecifiedTargetClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection_2_0 elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollection.getTargetClass());
-
- //set target class in the context model, verify resource model updated
- ormElementCollectionMapping.setSpecifiedTargetClass("newTargetClass");
- assertEquals("newTargetClass", ormElementCollectionMapping.getSpecifiedTargetClass());
- assertEquals("newTargetClass", elementCollection.getTargetClass());
-
- //set target class to null in the context model
- ormElementCollectionMapping.setSpecifiedTargetClass(null);
- assertNull(ormElementCollectionMapping.getSpecifiedTargetClass());
- assertNull(elementCollection.getTargetClass());
- }
-
-
- public void testGetValueTypeEmbeddable() throws Exception {
- createTestEntityWithEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "test.Address");
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
- }
-
- public void testGetValueTypeEntity() throws Exception {
- createTestEntityWithEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.Address");
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
- }
-
- public void testGetValueTypeNone() throws Exception {
- createTestEntityWithNonGenericElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "test.Address");
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.NO_TYPE, elementCollectionMapping.getValueType());
-
- elementCollectionMapping.setSpecifiedTargetClass("test.Address");
- assertEquals(ElementCollectionMapping2_0.Type.EMBEDDABLE_TYPE, elementCollectionMapping.getValueType());
- }
-
- public void testGetValueTypeBasic() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.Address");
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- assertEquals(ElementCollectionMapping2_0.Type.BASIC_TYPE, elementCollectionMapping.getValueType());
- }
-
-
- public void testUpdateMapKey() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNull(oneToMany.getMapKey());
-
- //set mapKey in the resource model, verify context model does not change
- oneToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNotNull(oneToMany.getMapKey());
-
- //set mapKey name in the resource model, verify context model updated
- oneToMany.getMapKey().setName("myMapKey");
- assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", oneToMany.getMapKey().getName());
-
- //set mapKey name to null in the resource model
- oneToMany.getMapKey().setName(null);
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNull(oneToMany.getMapKey().getName());
-
- oneToMany.getMapKey().setName("myMapKey");
- oneToMany.setMapKey(null);
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNull(oneToMany.getMapKey());
- }
-
- public void testUpdateVirtualMapKey() throws Exception {
- createTestEntityWithValidMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertNull(virtualElementCollectionMapping.getSpecifiedMapKey());
- assertNull(virtualElementCollectionMapping.getMapKey());
- assertFalse(virtualElementCollectionMapping.isPkMapKey());
- assertFalse(virtualElementCollectionMapping.isCustomMapKey());
- assertTrue(virtualElementCollectionMapping.isNoMapKey());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaElementCollectionMapping.setPkMapKey(true);
- assertEquals(null, virtualElementCollectionMapping.getMapKey());//no primary key on an embeddable
- assertTrue(virtualElementCollectionMapping.isPkMapKey());
- assertFalse(virtualElementCollectionMapping.isCustomMapKey());
- assertFalse(virtualElementCollectionMapping.isNoMapKey());
-
-
- //set custom specified mapKey in the java, verify virtual orm mapping updates
- javaElementCollectionMapping.setCustomMapKey(true);
- javaElementCollectionMapping.setSpecifiedMapKey("city");
- assertEquals("city", virtualElementCollectionMapping.getSpecifiedMapKey());
- assertEquals("city", virtualElementCollectionMapping.getMapKey());
- assertFalse(virtualElementCollectionMapping.isPkMapKey());
- assertTrue(virtualElementCollectionMapping.isCustomMapKey());
- assertFalse(virtualElementCollectionMapping.isNoMapKey());
- }
-
- public void testModifyMapKey() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- XmlOneToMany xmlOneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNull(xmlOneToMany.getMapKey());
-
- //set mapKey in the context model, verify resource model updated
- ormOneToManyMapping.setSpecifiedMapKey("myMapKey");
- assertEquals("myMapKey", ormOneToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", xmlOneToMany.getMapKey().getName());
-
- //set mapKey to null in the context model
- ormOneToManyMapping.setSpecifiedMapKey(null);
- assertNull(ormOneToManyMapping.getSpecifiedMapKey());
- assertNull(xmlOneToMany.getMapKey().getName());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames =
- virtualElementCollectionMapping.candidateMapKeyNames();
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
- OrmReadOnlyPersistentAttribute attribute = ormPersistentType.getAttributeNamed("addresses");
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) attribute.getMapping();
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames = virtualElementCollectionMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- javaElementCollectionMapping.setSpecifiedTargetClass("test.Address");
- mapKeyNames = virtualElementCollectionMapping.candidateMapKeyNames();
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- attribute.convertToSpecified();
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
- mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- ormElementCollectionMapping.setSpecifiedTargetClass("test.Address");
- mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- ormElementCollectionMapping.setSpecifiedTargetClass("String");
- mapKeyNames = ormElementCollectionMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
- }
-
- public void testUpdateMapKeyClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(elementCollection.getMapKeyClass());
-
- //set mapKey in the resource model, verify context model does not change
- elementCollection.setMapKeyClass(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertNotNull(elementCollection.getMapKeyClass());
-
- //set mapKey name in the resource model, verify context model updated
- elementCollection.getMapKeyClass().setClassName("String");
- assertEquals("String", ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertEquals("String", elementCollection.getMapKeyClass().getClassName());
-
- //set mapKey name to null in the resource model
- elementCollection.getMapKeyClass().setClassName(null);
- assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(elementCollection.getMapKeyClass().getClassName());
-
- elementCollection.getMapKeyClass().setClassName("String");
- elementCollection.setMapKeyClass(null);
- assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(elementCollection.getMapKeyClass());
- }
-
- public void testUpdateVirtualMapKeyClass() throws Exception {
- createTestEntityWithValidMapElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertNull(virtualElementCollectionMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualElementCollectionMapping.getMapKeyClass());
- assertEquals("java.lang.String", virtualElementCollectionMapping.getDefaultMapKeyClass());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaElementCollectionMapping.setSpecifiedMapKeyClass("Integer");
- assertEquals("Integer", virtualElementCollectionMapping.getMapKeyClass());
- assertEquals("Integer", virtualElementCollectionMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualElementCollectionMapping.getDefaultMapKeyClass());
- }
-
- public void testModifyMapKeyClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- XmlElementCollection elementCollection = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(elementCollection.getMapKeyClass());
-
- //set mapKey in the context model, verify resource model updated
- ormElementCollectionMapping.setSpecifiedMapKeyClass("String");
- assertEquals("String", ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertEquals("String", elementCollection.getMapKeyClass().getClassName());
-
- //set mapKey to null in the context model
- ormElementCollectionMapping.setSpecifiedMapKeyClass(null);
- assertNull(ormElementCollectionMapping.getSpecifiedMapKeyClass());
- assertNull(elementCollection.getMapKeyClass());
- }
- public void testOrderColumnDefaults() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- Orderable2_0 orderable = (Orderable2_0) elementCollectionMapping.getOrderable();
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- orderable.setOrderColumnOrdering(true);
- OrderColumn2_0 orderColumn = orderable.getOrderColumn();
- assertEquals(true, orderable.isOrderColumnOrdering());
- assertEquals(null, orderColumn.getSpecifiedName());
- assertEquals("addresses_ORDER", orderColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_addresses", orderColumn.getTable());
-
- orderColumn.setSpecifiedName("FOO");
- assertEquals("FOO", orderColumn.getSpecifiedName());
- assertEquals("addresses_ORDER", orderColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_addresses", orderColumn.getTable());
- }
-
- public void testVirtualOrderColumn() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- OrmElementCollectionMapping2_0 elementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
-
- Orderable2_0 orderable = (Orderable2_0) elementCollectionMapping.getOrderable();
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentAttribute.getJavaPersistentAttribute().getMapping();
- ((Orderable2_0) javaElementCollectionMapping.getOrderable()).setOrderColumnOrdering(true);
-
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("addresses");
- ElementCollectionMapping2_0 virtualElementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute2.getMapping();
- orderable = (Orderable2_0) virtualElementCollectionMapping.getOrderable();
- assertEquals(true, orderable.isOrderColumnOrdering());
- assertEquals(false, orderable.isNoOrdering());
- assertEquals(TYPE_NAME + "_addresses", orderable.getOrderColumn().getTable());
- assertEquals("addresses_ORDER", orderable.getOrderColumn().getName());
-
- ((Orderable2_0) javaElementCollectionMapping.getOrderable()).getOrderColumn().setSpecifiedName("FOO");
- assertEquals(TYPE_NAME + "_addresses", orderable.getOrderColumn().getTable());
- assertEquals("FOO", orderable.getOrderColumn().getName());
- }
-
- public void testVirtualValueColumnDefaults() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- //virtual attrubte in orm.xml, java attribute has no value Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ElementCollectionMapping2_0 addressesVirtualMapping = (ElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- Column virtualColumn = addressesVirtualMapping.getValueColumn();
- assertEquals("addresses", virtualColumn.getName());
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getTable());
- assertEquals(null, virtualColumn.getColumnDefinition());
- assertTrue(virtualColumn.isInsertable());
- assertTrue(virtualColumn.isUpdatable());
- assertTrue(virtualColumn.isNullable());
- assertFalse(virtualColumn.isUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale());
-
- //set Column annotation in Java
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaElementCollectionMapping.getValueColumn().setSpecifiedName("FOO");
- javaElementCollectionMapping.getValueColumn().setSpecifiedTable("FOO_TABLE");
- javaElementCollectionMapping.getValueColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaElementCollectionMapping.getValueColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedNullable(Boolean.FALSE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedUnique(Boolean.TRUE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedLength(Integer.valueOf(45));
- javaElementCollectionMapping.getValueColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaElementCollectionMapping.getValueColumn().setSpecifiedScale(Integer.valueOf(47));
-
- assertEquals("FOO", virtualColumn.getSpecifiedName());
- assertEquals("FOO_TABLE", virtualColumn.getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION", virtualColumn.getColumnDefinition());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, virtualColumn.getSpecifiedUnique());
- assertEquals(Integer.valueOf(45), virtualColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(46), virtualColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(47), virtualColumn.getSpecifiedScale());
-
-
- //set metadata-complete, orm.xml virtual column ignores java column annotation
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- addressesPersistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- //no longer an element collection mapping
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, addressesPersistentAttribute.getMappingKey());
- }
-
- public void testNullColumnDefaults() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
-
- OrmElementCollectionMapping2_0 addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- OrmColumn ormColumn = addressesVirtualMapping.getValueColumn();
-
- //set Column annotation in Java
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaElementCollectionMapping.getValueColumn().setSpecifiedName("FOO");
- javaElementCollectionMapping.getValueColumn().setSpecifiedTable("FOO_TABLE");
- javaElementCollectionMapping.getValueColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaElementCollectionMapping.getValueColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedNullable(Boolean.FALSE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedUnique(Boolean.TRUE);
- javaElementCollectionMapping.getValueColumn().setSpecifiedLength(Integer.valueOf(45));
- javaElementCollectionMapping.getValueColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaElementCollectionMapping.getValueColumn().setSpecifiedScale(Integer.valueOf(47));
-
-
- assertEquals("addresses", ormColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_addresses", ormColumn.getDefaultTable());
- assertEquals(true, ormColumn.isDefaultInsertable());
- assertEquals(true, ormColumn.isDefaultUpdatable());
- assertEquals(true, ormColumn.isDefaultNullable());
- assertEquals(false, ormColumn.isDefaultUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getDefaultLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getDefaultPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getDefaultScale());
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualValueColumnTable() throws Exception {
- createTestEntityWithGenericBasicElementCollectionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- //virtual attribute in orm.xml, java attribute has no Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ElementCollectionMapping2_0 addressesVirtualMapping = (ElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- Column virtualColumn = addressesVirtualMapping.getValueColumn();
-
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getTable());
-
- //entity table should have no affect on the collection table default name
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE");
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getTable());
-
- //set Column table element in Java
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaElementCollectionMapping.getCollectionTable().setSpecifiedName("JAVA_COLLECTION_TABLE");
- assertEquals("JAVA_COLLECTION_TABLE", virtualColumn.getTable());
- javaElementCollectionMapping.getValueColumn().setSpecifiedTable("JAVA_TABLE");
- assertEquals("JAVA_TABLE", virtualColumn.getTable());
-
- //make name persistent attribute not virtual
- addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- virtualColumn = addressesVirtualMapping.getValueColumn();
- assertNull(virtualColumn.getSpecifiedTable());
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getDefaultTable());
- }
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- OrmAttributeOverrideContainer attributeOverrideContainer = ormElementCollectionMapping.getValueAttributeOverrideContainer();
- XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- elementCollectionResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
- elementCollectionResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
- elementCollectionResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
-
- elementCollectionResource.getAttributeOverrides().get(0).setName("FOO");
- elementCollectionResource.getAttributeOverrides().get(1).setName("BAR");
- elementCollectionResource.getAttributeOverrides().get(2).setName("BAZ");
-
- assertEquals(3, elementCollectionResource.getAttributeOverrides().size());
-
- attributeOverrideContainer.moveSpecifiedOverride(2, 0);
- ListIterator<OrmAttributeOverride> attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
-
- assertEquals("BAR", elementCollectionResource.getAttributeOverrides().get(0).getName());
- assertEquals("BAZ", elementCollectionResource.getAttributeOverrides().get(1).getName());
- assertEquals("FOO", elementCollectionResource.getAttributeOverrides().get(2).getName());
-
-
- attributeOverrideContainer.moveSpecifiedOverride(0, 1);
- attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
-
- assertEquals("BAZ", elementCollectionResource.getAttributeOverrides().get(0).getName());
- assertEquals("BAR", elementCollectionResource.getAttributeOverrides().get(1).getName());
- assertEquals("FOO", elementCollectionResource.getAttributeOverrides().get(2).getName());
- }
-
- public void testUpdateAttributeOverrides() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "elementCollectionMapping");
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- OrmAttributeOverrideContainer attributeOverrideContainer = ormElementCollectionMapping.getValueAttributeOverrideContainer();
- XmlElementCollection_2_0 elementCollectionResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getElementCollections().get(0);
-
- elementCollectionResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
- elementCollectionResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
- elementCollectionResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
-
- elementCollectionResource.getAttributeOverrides().get(0).setName("FOO");
- elementCollectionResource.getAttributeOverrides().get(1).setName("BAR");
- elementCollectionResource.getAttributeOverrides().get(2).setName("BAZ");
-
- ListIterator<OrmAttributeOverride> attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("FOO", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- elementCollectionResource.getAttributeOverrides().move(2, 0);
- attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- elementCollectionResource.getAttributeOverrides().move(0, 1);
- attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- elementCollectionResource.getAttributeOverrides().remove(1);
- attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- elementCollectionResource.getAttributeOverrides().remove(1);
- attributeOverrides = attributeOverrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- elementCollectionResource.getAttributeOverrides().remove(0);
- assertFalse(attributeOverrideContainer.specifiedOverrides().hasNext());
- }
-
- public void testElementCollectionMappingNoUnderylingJavaAttribute() throws Exception {
- createTestEntityWithEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "foo");
- assertEquals(3, ormPersistentType.virtualAttributesSize());
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
- OrmElementCollectionMapping2_0 ormElementCollectionMapping = (OrmElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- OrmAttributeOverrideContainer attributeOverrideContainer = ormElementCollectionMapping.getValueAttributeOverrideContainer();
-
- assertEquals("foo", ormElementCollectionMapping.getName());
-
-
- assertFalse(attributeOverrideContainer.specifiedOverrides().hasNext());
- assertFalse(attributeOverrideContainer.virtualOverrides().hasNext());
- }
-
- public void testVirtualAttributeOverrides() throws Exception {
- createTestEntityWithEmbeddableElementCollectionMapping();
- createTestTargetEmbeddableAddress();
- createTestEmbeddableState();
-
- OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType persistentType2 = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- OrmPersistentType persistentType3 = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- //embedded mapping is virtual, specified attribute overrides should exist
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = persistentType.getAttributeNamed("addresses");
- ElementCollectionMapping2_0 elementCollectionMapping = (ElementCollectionMapping2_0) ormPersistentAttribute.getMapping();
- AttributeOverrideContainer attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- assertEquals(4, attributeOverrideContainer.overridesSize());
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
- assertEquals(1, attributeOverrideContainer.specifiedOverridesSize());
- ListIterator<AttributeOverride> specifiedAttributeOverrides = (ListIterator<AttributeOverride>) attributeOverrideContainer.specifiedOverrides();
- ReadOnlyAttributeOverride attributeOverride = specifiedAttributeOverrides.next();
- assertEquals("city", attributeOverride.getName());
- ListIterator<AttributeOverride> virtualAttributeOverrides = (ListIterator<AttributeOverride>) attributeOverrideContainer.virtualOverrides();
- attributeOverride = virtualAttributeOverrides.next();
- assertEquals("state.name", attributeOverride.getName());
- attributeOverride = virtualAttributeOverrides.next();
- assertEquals("state.abbr", attributeOverride.getName());
- attributeOverride = virtualAttributeOverrides.next();
- assertEquals("zip", attributeOverride.getName());
-
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentAttribute.getJavaPersistentAttribute().getMapping();
- Column javaAttributeOverrideColumn = javaElementCollectionMapping.getValueAttributeOverrideContainer().specifiedOverrides().next().getColumn();
-
- javaAttributeOverrideColumn.setSpecifiedName("FOO_COLUMN");
- javaAttributeOverrideColumn.setSpecifiedTable("FOO_TABLE");
- javaAttributeOverrideColumn.setColumnDefinition("COLUMN_DEF");
- javaAttributeOverrideColumn.setSpecifiedInsertable(Boolean.FALSE);
- javaAttributeOverrideColumn.setSpecifiedUpdatable(Boolean.FALSE);
- javaAttributeOverrideColumn.setSpecifiedUnique(Boolean.TRUE);
- javaAttributeOverrideColumn.setSpecifiedNullable(Boolean.FALSE);
- javaAttributeOverrideColumn.setSpecifiedLength(Integer.valueOf(5));
- javaAttributeOverrideColumn.setSpecifiedPrecision(Integer.valueOf(6));
- javaAttributeOverrideColumn.setSpecifiedScale(Integer.valueOf(7));
-
- JavaBasicMapping javaBasicMapping = (JavaBasicMapping) persistentType3.getJavaPersistentType().getAttributeNamed("name").getMapping();
- javaBasicMapping.getColumn().setSpecifiedName("MY_STATE_COLUMN");
- assertEquals(4, attributeOverrideContainer.overridesSize());
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
- assertEquals(1, attributeOverrideContainer.specifiedOverridesSize());
- virtualAttributeOverrides = (ListIterator<AttributeOverride>) attributeOverrideContainer.specifiedOverrides();
- attributeOverride = virtualAttributeOverrides.next();
- assertEquals("city", attributeOverride.getName());
- assertEquals("FOO_COLUMN", attributeOverride.getColumn().getSpecifiedName());
- assertEquals("FOO_TABLE", attributeOverride.getColumn().getSpecifiedTable());
- assertEquals("COLUMN_DEF", attributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, attributeOverride.getColumn().isInsertable());
- assertEquals(false, attributeOverride.getColumn().isUpdatable());
- assertEquals(true, attributeOverride.getColumn().isUnique());
- assertEquals(false, attributeOverride.getColumn().isNullable());
- assertEquals(5, attributeOverride.getColumn().getLength());
- assertEquals(6, attributeOverride.getColumn().getPrecision());
- assertEquals(7, attributeOverride.getColumn().getScale());
-
- specifiedAttributeOverrides = (ListIterator<AttributeOverride>) attributeOverrideContainer.virtualOverrides();
- attributeOverride = specifiedAttributeOverrides.next();
- assertEquals("state.name", attributeOverride.getName());
- assertEquals("MY_STATE_COLUMN", attributeOverride.getColumn().getSpecifiedName());
- attributeOverride = specifiedAttributeOverrides.next();
- assertEquals("state.abbr", attributeOverride.getName());
- attributeOverride = specifiedAttributeOverrides.next();
- assertEquals("zip", attributeOverride.getName());
-
-
-
- //embedded mapping is specified, virtual attribute overrides should exist
- persistentType.getAttributeNamed("addresses").convertToSpecified();
- elementCollectionMapping = (OrmElementCollectionMapping2_0) persistentType.getAttributeNamed("addresses").getMapping();
- attributeOverrideContainer = elementCollectionMapping.getValueAttributeOverrideContainer();
- assertEquals(4, attributeOverrideContainer.overridesSize());
- assertEquals(4, attributeOverrideContainer.virtualOverridesSize());
- assertEquals(0, attributeOverrideContainer.specifiedOverridesSize());
- virtualAttributeOverrides = (ListIterator<AttributeOverride>) attributeOverrideContainer.virtualOverrides();
- ReadOnlyAttributeOverride virtualOverride = virtualAttributeOverrides.next();
- assertEquals("city", virtualOverride.getName());
- virtualOverride = virtualAttributeOverrides.next();
- assertEquals("state.name", virtualOverride.getName());
- assertEquals("MY_STATE_COLUMN", virtualOverride.getColumn().getName());
- assertEquals(TYPE_NAME + "_addresses", virtualOverride.getColumn().getTable());
- assertEquals(null, virtualOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualOverride.getColumn().isInsertable());
- assertEquals(true, virtualOverride.getColumn().isUpdatable());
- assertEquals(false, virtualOverride.getColumn().isUnique());
- assertEquals(true, virtualOverride.getColumn().isNullable());
- assertEquals(255, virtualOverride.getColumn().getLength());
- assertEquals(0, virtualOverride.getColumn().getPrecision());
- assertEquals(0, virtualOverride.getColumn().getScale());
- virtualOverride = virtualAttributeOverrides.next();
- assertEquals("state.abbr", virtualOverride.getName());
- assertEquals(TYPE_NAME + "_addresses", virtualOverride.getColumn().getDefaultTable());
- virtualOverride = virtualAttributeOverrides.next();
- assertEquals("zip", virtualOverride.getName());
-
- //set one of the virtual attribute overrides to specified, verify others are still virtual
- attributeOverrideContainer.virtualOverrides().next().convertToSpecified();
-
- assertEquals(4, attributeOverrideContainer.overridesSize());
- assertEquals(1, attributeOverrideContainer.specifiedOverridesSize());
- assertEquals(3, attributeOverrideContainer.virtualOverridesSize());
- assertEquals("city", attributeOverrideContainer.specifiedOverrides().next().getName());
- virtualAttributeOverrides = (ListIterator<AttributeOverride>) attributeOverrideContainer.virtualOverrides();
- virtualOverride = virtualAttributeOverrides.next();
- assertEquals("state.name", virtualOverride.getName());
- virtualOverride = virtualAttributeOverrides.next();
- assertEquals("state.abbr", virtualOverride.getName());
- virtualOverride = virtualAttributeOverrides.next();
- assertEquals("zip", virtualOverride.getName());
- }
- public void testVirtualMapKeyColumnDefaults() throws Exception {
- createTestEntityWithValidMapElementCollectionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- //virtual attribute in orm.xml, java attribute has no value Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ElementCollectionMapping2_0 addressesVirtualMapping = (ElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- Column virtualColumn = addressesVirtualMapping.getMapKeyColumn();
- assertEquals("addresses_KEY", virtualColumn.getName());
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getTable());
- assertEquals(null, virtualColumn.getColumnDefinition());
- assertTrue(virtualColumn.isInsertable());
- assertTrue(virtualColumn.isUpdatable());
- assertTrue(virtualColumn.isNullable());
- assertFalse(virtualColumn.isUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale());
-
- //set Column annotation in Java
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedName("FOO");
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedTable("FOO_TABLE");
- javaElementCollectionMapping.getMapKeyColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedNullable(Boolean.FALSE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedUnique(Boolean.TRUE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedLength(Integer.valueOf(45));
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedScale(Integer.valueOf(47));
-
- assertEquals("FOO", virtualColumn.getSpecifiedName());
- assertEquals("FOO_TABLE", virtualColumn.getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION", virtualColumn.getColumnDefinition());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, virtualColumn.getSpecifiedUnique());
- assertEquals(Integer.valueOf(45), virtualColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(46), virtualColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(47), virtualColumn.getSpecifiedScale());
-
-
- //set metadata-complete, orm.xml virtual column ignores java column annotation
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- addressesPersistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- //no longer an element collection mapping
- assertEquals(MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY, addressesPersistentAttribute.getMappingKey());
- }
-
- public void testNullMapKeyColumnDefaults() throws Exception {
- createTestEntityWithValidMapElementCollectionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
-
- OrmElementCollectionMapping2_0 addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- Column ormColumn = addressesVirtualMapping.getMapKeyColumn();
-
- //set Column annotation in Java
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedName("FOO");
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedTable("FOO_TABLE");
- javaElementCollectionMapping.getMapKeyColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedNullable(Boolean.FALSE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedUnique(Boolean.TRUE);
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedLength(Integer.valueOf(45));
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedScale(Integer.valueOf(47));
-
-
- assertEquals("addresses_KEY", ormColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_addresses", ormColumn.getDefaultTable());
- assertEquals(true, ormColumn.isDefaultInsertable());
- assertEquals(true, ormColumn.isDefaultUpdatable());
- assertEquals(true, ormColumn.isDefaultNullable());
- assertEquals(false, ormColumn.isDefaultUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getDefaultLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getDefaultPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getDefaultScale());
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualMapKeyColumnTable() throws Exception {
- createTestEntityWithValidMapElementCollectionMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- //virtual attribute in orm.xml, java attribute has no Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ElementCollectionMapping2_0 addressesVirtualMapping = (ElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- Column virtualColumn = addressesVirtualMapping.getMapKeyColumn();
-
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getTable());
-
- //entity table should have no affect on the collection table default name
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE");
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getTable());
-
- //set Column table element in Java
- JavaElementCollectionMapping2_0 javaElementCollectionMapping = (JavaElementCollectionMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaElementCollectionMapping.getCollectionTable().setSpecifiedName("JAVA_COLLECTION_TABLE");
- assertEquals("JAVA_COLLECTION_TABLE", virtualColumn.getTable());
- javaElementCollectionMapping.getMapKeyColumn().setSpecifiedTable("JAVA_TABLE");
- assertEquals("JAVA_TABLE", virtualColumn.getTable());
-
- //make name persistent attribute not virtual
- addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, "addresses");
- addressesVirtualMapping = (OrmElementCollectionMapping2_0) addressesPersistentAttribute.getMapping();
- virtualColumn = addressesVirtualMapping.getMapKeyColumn();
- assertNull(virtualColumn.getSpecifiedTable());
- assertEquals(TYPE_NAME + "_addresses", virtualColumn.getDefaultTable());
- }
-
- public void testSelfReferentialElementCollectionMapping() throws Exception {
- createSelfReferentialElementCollection();
- OrmPersistentType persistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Foo");
-
- ElementCollectionMapping2_0 mapping = (ElementCollectionMapping2_0) persistentType.getAttributeNamed("elementCollection").getMapping();
- assertFalse(mapping.allOverridableAttributeMappingNames().hasNext());
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmEntityTests.java
deleted file mode 100644
index c2043847d1..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmEntityTests.java
+++ /dev/null
@@ -1,1806 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase.DefaultAnnotationWriter;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AssociationOverride;
-import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BasicMapping;
-import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.InheritanceType;
-import org.eclipse.jpt.jpa.core.context.VirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmEntityTests extends EclipseLink2_0OrmContextModelTestCase
-{
- protected static final String SUB_TYPE_NAME = "AnnotationTestTypeChild";
- protected static final String FULLY_QUALIFIED_SUB_TYPE_NAME = PACKAGE_NAME + "." + SUB_TYPE_NAME;
-
-
- public EclipseLink2_0OrmEntityTests(String name) {
- super(name);
- }
-
- private ICompilationUnit createTestEntity() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, JPA.ONE_TO_ONE, JPA.MANY_TO_ONE, JPA.ONE_TO_MANY, JPA.MANY_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("private String foo;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToOne");
- sb.append(CR);
- sb.append(" private int address2;").append(CR);
- sb.append(CR);
- sb.append(" @OneToMany");
- sb.append(CR);
- sb.append(" private int address3;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToMany");
- sb.append(CR);
- sb.append(" private int address4;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private ICompilationUnit createTestAbstractEntityTablePerClass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.INHERITANCE, JPA.INHERITANCE_TYPE, JPA.ONE_TO_ONE, JPA.MANY_TO_ONE, JPA.ONE_TO_MANY, JPA.MANY_TO_MANY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- sb.append("@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)");
- sb.append("abstract");
- }
-
- @Override
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {
- sb.append("private String foo;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne");
- sb.append(CR);
- sb.append(" private int address;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToOne");
- sb.append(CR);
- sb.append(" private int address2;").append(CR);
- sb.append(CR);
- sb.append(" @OneToMany");
- sb.append(CR);
- sb.append(" private int address3;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToMany");
- sb.append(CR);
- sb.append(" private int address4;").append(CR);
- sb.append(CR);
- sb.append(" ");
- }
- });
- }
-
- private void createTestSubType() 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("@Entity");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- private void createTestMappedSuperclassCustomer() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.MAPPED_SUPERCLASS);
- 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(CR);
- sb.append("@MappedSuperclass");
- sb.append(CR);
- sb.append("public class ").append("Customer ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String id;").append(CR);
- sb.append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @Embedded").append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Customer.java", sourceWriter);
- }
-
- private void createTestMappedSuperclassCustomerWithElementCollection() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.MAPPED_SUPERCLASS);
- 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(CR);
- sb.append("@MappedSuperclass");
- sb.append(CR);
- sb.append("public class ").append("Customer ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String id;").append(CR);
- sb.append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @ElementCollection").append(CR);
- sb.append(" private java.util.Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Customer.java", sourceWriter);
- }
-
- private void createTestEntityLongTimeCustomer() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- 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(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("LongTimeCustomer extends Customer ");
- sb.append("{}");
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "LongTimeCustomer.java", sourceWriter);
- }
-
-
- private void createTestEmbeddableAddress() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.EMBEDDED);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.ONE_TO_ONE);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("Address").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private String street;").append(CR);
- sb.append(CR);
- sb.append(" private String city;").append(CR);
- sb.append(CR);
- sb.append(" @OneToOne").append(CR);
- sb.append(" private State state;").append(CR);
- sb.append(CR);
- sb.append(" @Embedded").append(CR);
- sb.append(" private ZipCode zipCode;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "Address.java", sourceWriter);
- }
-
- private void createTestEmbeddableZipCode() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append("import ");
- sb.append(JPA.EMBEDDABLE);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Embeddable");
- sb.append(CR);
- sb.append("public class ").append("ZipCode").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" private String zip;").append(CR);
- sb.append(CR);
- sb.append(" private String plusfour;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "ZipCode.java", sourceWriter);
- }
-
- public void testAttributeMappingKeyAllowed() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- OrmEntity entity = (OrmEntity) ormPersistentType.getMapping();
-
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- assertTrue(entity.attributeMappingKeyAllowed(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY));
- }
-
- public void testOverridableAttributes() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity entity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAttributes = entity.overridableAttributeNames();
- assertFalse(overridableAttributes.hasNext());
-
-
- entity.setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
-
- overridableAttributes = entity.overridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testOverridableAttributeNames() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity entity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAttributeNames = entity.overridableAttributeNames();
- assertFalse(overridableAttributeNames.hasNext());
-
-
- entity.setSpecifiedInheritanceStrategy(InheritanceType.TABLE_PER_CLASS);
-
- overridableAttributeNames = entity.overridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testAllOverridableAttributes() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
-
- Iterator<String> overridableAttributes = getJavaEntity().allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAttributesTablePerClass() throws Exception {
- createTestAbstractEntityTablePerClass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAttributes = ormEntity.allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
-
-
- OrmEntity abstractEntity = (OrmEntity) ormEntity.getParentEntity();
- overridableAttributes = abstractEntity.allOverridableAttributeNames();
- assertEquals("id", overridableAttributes.next());
- assertEquals("name", overridableAttributes.next());
- assertEquals("foo", overridableAttributes.next());
- assertFalse(overridableAttributes.hasNext());
- }
-
- public void testAllOverridableAssociationsTablePerClass() throws Exception {
- createTestAbstractEntityTablePerClass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAssociations = ormEntity.allOverridableAssociationNames();
- assertEquals("address", overridableAssociations.next());
- assertEquals("address2", overridableAssociations.next());
- assertEquals("address3", overridableAssociations.next());
- assertEquals("address4", overridableAssociations.next());
- assertFalse(overridableAssociations.hasNext());
-
-
- OrmEntity abstractEntity = (OrmEntity) ormEntity.getParentEntity();
- overridableAssociations = abstractEntity.allOverridableAssociationNames();
- assertEquals("address", overridableAssociations.next());
- assertEquals("address2", overridableAssociations.next());
- assertEquals("address3", overridableAssociations.next());
- assertEquals("address4", overridableAssociations.next());
- assertFalse(overridableAssociations.hasNext());
- }
-//TODO
-// public void testAllOverridableAttributesMappedSuperclassInOrmXml() throws Exception {
-// createTestMappedSuperclass();
-// createTestSubType();
-// addXmlClassRef(PACKAGE_NAME + ".AnnotationTestTypeChild");
-// getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-//
-// Iterator<PersistentAttribute> overridableAttributes = getJavaEntity().allOverridableAttributes();
-// assertEquals("id", overridableAttributes.next().getName());
-// assertEquals("name", overridableAttributes.next().getName());
-// assertEquals("foo", overridableAttributes.next().getName());
-// assertFalse(overridableAttributes.hasNext());
-// }
-
- public void testAllOverridableAttributeNames() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAttributeNames = ormEntity.allOverridableAttributeNames();
- assertEquals("id", overridableAttributeNames.next());
- assertEquals("name", overridableAttributeNames.next());
- assertEquals("foo", overridableAttributeNames.next());
- assertFalse(overridableAttributeNames.hasNext());
- }
-
- public void testSpecifiedAttributeOverrides() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity entity = (OrmEntity) ormPersistentType.getMapping();
- OrmAttributeOverrideContainer overrideContainer = entity.getAttributeOverrideContainer();
-
- ListIterator<OrmAttributeOverride> specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- //add an annotation to the resource model and verify the context model is updated
- entityResource.getAttributeOverrides().add(0, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(0).setName("FOO");
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().add(1, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(1).setName("BAR");
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
-
- entityResource.getAttributeOverrides().add(0, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(0).setName("BAZ");
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- entityResource.getAttributeOverrides().move(1, 0);
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAttributeOverrides.next().getName());
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(0);
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAttributeOverrides.next().getName());
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(0);
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAttributeOverrides.next().getName());
- assertFalse(specifiedAttributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(0);
- specifiedAttributeOverrides = overrideContainer.specifiedOverrides();
- assertFalse(specifiedAttributeOverrides.hasNext());
- }
-
- public void testDefaultAttributeOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(0, entityResource.getAttributeOverrides().size());
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- VirtualAttributeOverride virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
-
- OrmMappedSuperclass mappedSuperclass = (OrmMappedSuperclass) ormEntity.getPersistentType().getSuperPersistentType().getMapping();
-
- mappedSuperclass.getPersistentType().getAttributeNamed("id").convertToSpecified();
- BasicMapping idMapping = (BasicMapping) mappedSuperclass.getPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(0, entityResource.getAttributeOverrides().size());
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("FOO", virtualAttributeOverride.getColumn().getName());
- assertEquals("BAR", virtualAttributeOverride.getColumn().getTable());
-
- idMapping.getColumn().setSpecifiedName(null);
- idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(0, entityResource.getAttributeOverrides().size());
-
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
- virtualAttributeOverride.convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
- }
-
- public void testDefaultAttributeOverridesEntityHierachy() throws Exception {
- createTestAbstractEntityTablePerClass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(0, entityResource.getAttributeOverrides().size());
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- VirtualAttributeOverride virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
-
- OrmEntity superclass = (OrmEntity) ormEntity.getParentEntity();
-
- superclass.getPersistentType().getAttributeNamed("id").convertToSpecified();
- BasicMapping idMapping = (BasicMapping) superclass.getPersistentType().getAttributeNamed("id").getMapping();
- idMapping.getColumn().setSpecifiedName("FOO");
- idMapping.getColumn().setSpecifiedTable("BAR");
-
- assertEquals(0, entityResource.getAttributeOverrides().size());
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("FOO", virtualAttributeOverride.getColumn().getName());
- assertEquals("BAR", virtualAttributeOverride.getColumn().getTable());
-
- idMapping.getColumn().setSpecifiedName(null);
- idMapping.getColumn().setSpecifiedTable(null);
- assertEquals(0, entityResource.getAttributeOverrides().size());
-
- virtualAttributeOverride = overrideContainer.virtualOverrides().next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertEquals("id", virtualAttributeOverride.getColumn().getName());
- assertEquals(SUB_TYPE_NAME, virtualAttributeOverride.getColumn().getTable());
-
- virtualAttributeOverride.convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
- }
-
- public void testSpecifiedAttributeOverridesSize() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- assertEquals(0, overrideContainer.specifiedOverridesSize());
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- //add an annotation to the resource model and verify the context model is updated
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(0).setName("FOO");
- entityResource.getAttributeOverrides().add(OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(0).setName("BAR");
-
- assertEquals(2, overrideContainer.specifiedOverridesSize());
- }
-
- public void testDefaultAttributeOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- assertEquals(3, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(1, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(0, overrideContainer.virtualOverridesSize());
- }
-
- public void testAttributeOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- assertEquals(3, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(3, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(3, overrideContainer.overridesSize());
-
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- entityResource.getAttributeOverrides().add(0, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(0).setName("bar");
- assertEquals(4, overrideContainer.overridesSize());
- }
-
- public void testAttributeOverrideSetVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- assertEquals("id", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("name", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals(2, entityResource.getAttributeOverrides().size());
- }
-
- public void testAttributeOverrideSetVirtual2() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- ListIterator<OrmVirtualAttributeOverride> virtualAttributeOverrides = overrideContainer.virtualOverrides();
- virtualAttributeOverrides.next();
- virtualAttributeOverrides.next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- assertEquals("name", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("id", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals(2, entityResource.getAttributeOverrides().size());
- }
-
- public void testAttributeOverrideSetVirtualTrue() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(3, entityResource.getAttributeOverrides().size());
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
-
- assertEquals("name", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("foo", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals(2, entityResource.getAttributeOverrides().size());
-
- Iterator<OrmAttributeOverride> attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("foo", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
- assertEquals("foo", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals(1, entityResource.getAttributeOverrides().size());
-
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("foo", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
- assertEquals(0, entityResource.getAttributeOverrides().size());
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testMoveSpecifiedAttributeOverride() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(3, entityResource.getAttributeOverrides().size());
-
-
- overrideContainer.moveSpecifiedOverride(2, 0);
- ListIterator<OrmAttributeOverride> attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("foo", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
-
- assertEquals("name", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("foo", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals("id", entityResource.getAttributeOverrides().get(2).getName());
-
-
- overrideContainer.moveSpecifiedOverride(0, 1);
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("foo", attributeOverrides.next().getName());
- assertEquals("name", attributeOverrides.next().getName());
- assertEquals("id", attributeOverrides.next().getName());
-
- assertEquals("foo", entityResource.getAttributeOverrides().get(0).getName());
- assertEquals("name", entityResource.getAttributeOverrides().get(1).getName());
- assertEquals("id", entityResource.getAttributeOverrides().get(2).getName());
- }
-
- public void testUpdateSpecifiedAttributeOverrides() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- entityResource.getAttributeOverrides().add(0, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(0).setName("FOO");
- entityResource.getAttributeOverrides().add(1, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(1).setName("BAR");
- entityResource.getAttributeOverrides().add(2, OrmFactory.eINSTANCE.createXmlAttributeOverride());
- entityResource.getAttributeOverrides().get(2).setName("BAZ");
-
- ListIterator<OrmAttributeOverride> attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().move(2, 0);
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().move(0, 1);
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("BAR", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(1);
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertEquals("FOO", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(1);
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", attributeOverrides.next().getName());
- assertFalse(attributeOverrides.hasNext());
-
- entityResource.getAttributeOverrides().remove(0);
- attributeOverrides = overrideContainer.specifiedOverrides();
- assertFalse(attributeOverrides.hasNext());
- }
-
- public void testAttributeOverrideIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAttributeOverrideContainer overrideContainer = ormEntity.getAttributeOverrideContainer();
-
- ListIterator<OrmVirtualAttributeOverride> virtualAttributeOverrides = overrideContainer.virtualOverrides();
- OrmVirtualAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("foo", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
- assertFalse(virtualAttributeOverrides.hasNext());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- AttributeOverride specifiedAttributeOverride = overrideContainer.specifiedOverrides().next();
- assertFalse(specifiedAttributeOverride.isVirtual());
-
-
- virtualAttributeOverrides = overrideContainer.virtualOverrides();
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
-
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("foo", virtualAttributeOverride.getName());
- assertTrue(virtualAttributeOverride.isVirtual());
- assertFalse(virtualAttributeOverrides.hasNext());
- }
-
- public void testOverridableAssociationNames() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- OrmEntity entity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAssociationNames = entity.overridableAssociationNames();
- assertFalse(overridableAssociationNames.hasNext());
- }
-
-// //TODO add all mapping types to the mapped superclass to test which ones are overridable
- public void testAllOverridableAssociationNames() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAssociationNames = ormEntity.allOverridableAssociationNames();
- assertEquals("address", overridableAssociationNames.next());
- assertEquals("address2", overridableAssociationNames.next());
- assertEquals("address3", overridableAssociationNames.next());
- assertEquals("address4", overridableAssociationNames.next());
- assertFalse(overridableAssociationNames.hasNext());
- }
-
- public void testAllOverridableAssociations() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
-
- Iterator<String> overridableAssociations = ormEntity.allOverridableAssociationNames();
- assertEquals("address", overridableAssociations.next());
- assertEquals("address2", overridableAssociations.next());
- assertEquals("address3", overridableAssociations.next());
- assertEquals("address4", overridableAssociations.next());
- assertFalse(overridableAssociations.hasNext());
- }
-
- public void testSpecifiedAssociationOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- ListIterator<OrmAssociationOverride> specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
-
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- //add an annotation to the resource model and verify the context model is updated
- XmlAssociationOverride xmlAssociationOverride = OrmFactory.eINSTANCE.createXmlAssociationOverride();
- entityResource.getAssociationOverrides().add(0, xmlAssociationOverride);
- xmlAssociationOverride.setName("FOO");
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- xmlAssociationOverride = OrmFactory.eINSTANCE.createXmlAssociationOverride();
- entityResource.getAssociationOverrides().add(1, xmlAssociationOverride);
- xmlAssociationOverride.setName("BAR");
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
-
- xmlAssociationOverride = OrmFactory.eINSTANCE.createXmlAssociationOverride();
- entityResource.getAssociationOverrides().add(0, xmlAssociationOverride);
- xmlAssociationOverride.setName("BAZ");
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- //move an annotation to the resource model and verify the context model is updated
- entityResource.getAssociationOverrides().move(1, 0);
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", specifiedAssociationOverrides.next().getName());
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(0);
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", specifiedAssociationOverrides.next().getName());
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(0);
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAR", specifiedAssociationOverrides.next().getName());
- assertFalse(specifiedAssociationOverrides.hasNext());
-
-
- entityResource.getAssociationOverrides().remove(0);
- specifiedAssociationOverrides = overrideContainer.specifiedOverrides();
- assertFalse(specifiedAssociationOverrides.hasNext());
- }
-
- public void testDefaultAssociationOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(FULLY_QUALIFIED_SUB_TYPE_NAME, entityResource.getClassName());
- assertTrue(entityResource.getAssociationOverrides().isEmpty());
-
- assertEquals(4, overrideContainer.virtualOverridesSize());
- OrmVirtualAssociationOverride virtualAssociationOverride = overrideContainer.virtualOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
-//
-// //MappedSuperclass mappedSuperclass = (MappedSuperclass) javaPersistentType().getMapping();
-// //BasicMapping idMapping = (BasicMapping) mappedSuperclass.persistentType().attributeNamed("id").getMapping();
-// //idMapping.getColumn().setSpecifiedName("FOO");
-// //idMapping.getColumn().setSpecifiedTable("BAR");
-//
-// assertEquals(SUB_TYPE_NAME, entityResource.getName());
-// assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
-// assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- assertEquals(4, overrideContainer.virtualOverridesSize());
- virtualAssociationOverride = overrideContainer.virtualOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
-// //idMapping.getColumn().setSpecifiedName(null);
-// //idMapping.getColumn().setSpecifiedTable(null);
-// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-// assertNull(typeResource.getAnnotation(AssociationOverrideAnnotation.ANNOTATION_NAME));
-// assertNull(typeResource.getAnnotation(AssociationOverridesAnnotation.ANNOTATION_NAME));
-
- virtualAssociationOverride = overrideContainer.virtualOverrides().next();
- assertEquals("address", virtualAssociationOverride.getName());
-
- virtualAssociationOverride.convertToSpecified();
- assertEquals(3, overrideContainer.virtualOverridesSize());
-
-
-
-// //TODO joinColumns for default association overrides
-//// IJoinColumn defaultJoinColumn = defaultAssociationOverride.joinColumns().next();
-//// assertEquals("address", defaultJoinColumn.getName());
-//// assertEquals("address", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals(SUB_TYPE_NAME, defaultJoinColumn.getTable());
-////
-////
-//// IMappedSuperclass mappedSuperclass = (IMappedSuperclass) javaPersistentType().getMapping();
-////
-//// IOneToOneMapping addressMapping = (IOneToOneMapping) mappedSuperclass.persistentType().attributeNamed("address").getMapping();
-//// IJoinColumn joinColumn = addressMapping.addSpecifiedJoinColumn(0);
-//// joinColumn.setSpecifiedName("FOO");
-//// joinColumn.setSpecifiedReferencedColumnName("BAR");
-//// joinColumn.setSpecifiedTable("BAZ");
-////
-//// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-//// assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME));
-//// assertNull(typeResource.annotation(AssociationOverrides.ANNOTATION_NAME));
-////
-//// assertEquals(1, CollectionTools.size(javaEntity.defaultAssociationOverrides()));
-//// defaultAssociationOverride = javaEntity.defaultAssociationOverrides().next();
-//// assertEquals("address", defaultAssociationOverride.getName());
-//// assertEquals("FOO", defaultJoinColumn.getName());
-//// assertEquals("BAR", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals("BAZ", defaultJoinColumn.getTable());
-////
-//// joinColumn.setSpecifiedName(null);
-//// joinColumn.setSpecifiedReferencedColumnName(null);
-//// joinColumn.setSpecifiedTable(null);
-//// assertEquals(SUB_TYPE_NAME, typeResource.getName());
-//// assertNull(typeResource.annotation(AssociationOverride.ANNOTATION_NAME));
-//// assertNull(typeResource.annotation(AssociationOverrides.ANNOTATION_NAME));
-////
-//// defaultAssociationOverride = javaEntity.defaultAssociationOverrides().next();
-//// assertEquals("address", defaultJoinColumn.getName());
-//// assertEquals("address", defaultJoinColumn.getReferencedColumnName());
-//// assertEquals(SUB_TYPE_NAME, defaultJoinColumn.getTable());
-////
-//// javaEntity.addSpecifiedAssociationOverride(0).setName("address");
-//// assertEquals(0, CollectionTools.size(javaEntity.defaultAssociationOverrides()));
-
- }
-
- public void testSpecifiedAssociationOverridesSize() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- assertEquals(0, overrideContainer.specifiedOverridesSize());
-
- //add to the resource model and verify the context model is updated
- entityResource.getAssociationOverrides().add(OrmFactory.eINSTANCE.createXmlAssociationOverride());
- entityResource.getAssociationOverrides().get(0).setName("FOO");
- entityResource.getAssociationOverrides().add(0, OrmFactory.eINSTANCE.createXmlAssociationOverride());
- entityResource.getAssociationOverrides().get(0).setName("BAR");
-
- assertEquals(2, overrideContainer.specifiedOverridesSize());
- }
-
- public void testDefaultAssociationOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- assertEquals(4, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(3, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(2, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(1, overrideContainer.virtualOverridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(0, overrideContainer.virtualOverridesSize());
- }
-
- public void testAssociationOverridesSize() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- assertEquals(4, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(4, overrideContainer.overridesSize());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- assertEquals(4, overrideContainer.overridesSize());
-
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- entityResource.getAssociationOverrides().add(0, OrmFactory.eINSTANCE.createXmlAssociationOverride());
- entityResource.getAssociationOverrides().get(0).setName("bar");
- assertEquals(5, overrideContainer.overridesSize());
- }
-
- public void testAssociationOverrideSetVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- AssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- assertEquals("address", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals("address2", entityResource.getAssociationOverrides().get(1).getName());
- assertEquals(2, entityResource.getAssociationOverrides().size());
- }
-
- public void testAssociationOverrideSetVirtual2() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- ListIterator<OrmVirtualAssociationOverride> virtualAssociationOverrides = overrideContainer.virtualOverrides();
- virtualAssociationOverrides.next();
- virtualAssociationOverrides.next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- assertEquals("address2", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals("address", entityResource.getAssociationOverrides().get(1).getName());
- assertEquals(2, entityResource.getAssociationOverrides().size());
- }
-
- public void testAssociationOverrideSetVirtualTrue() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(2, entityResource.getAssociationOverrides().size());
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
-
- assertEquals("address2", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals(1, entityResource.getAssociationOverrides().size());
-
- Iterator<OrmAssociationOverride> associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("address2", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
-
- overrideContainer.specifiedOverrides().next().convertToVirtual();
- assertEquals(0, entityResource.getAssociationOverrides().size());
- associationOverrides = overrideContainer.specifiedOverrides();
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testMoveSpecifiedAssociationOverride() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- overrideContainer.virtualOverrides().next().convertToSpecified();
-
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(2, entityResource.getAssociationOverrides().size());
-
-
- overrideContainer.moveSpecifiedOverride(1, 0);
- ListIterator<OrmAssociationOverride> associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("address2", associationOverrides.next().getName());
- assertEquals("address", associationOverrides.next().getName());
-
- assertEquals("address2", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals("address", entityResource.getAssociationOverrides().get(1).getName());
-
-
- overrideContainer.moveSpecifiedOverride(0, 1);
- associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("address", associationOverrides.next().getName());
- assertEquals("address2", associationOverrides.next().getName());
-
- assertEquals("address", entityResource.getAssociationOverrides().get(0).getName());
- assertEquals("address2", entityResource.getAssociationOverrides().get(1).getName());
- }
-
- public void testUpdateSpecifiedAssociationOverrides() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
-
- entityResource.getAssociationOverrides().add(0, OrmFactory.eINSTANCE.createXmlAssociationOverride());
- entityResource.getAssociationOverrides().get(0).setName("FOO");
- entityResource.getAssociationOverrides().add(1, OrmFactory.eINSTANCE.createXmlAssociationOverride());
- entityResource.getAssociationOverrides().get(1).setName("BAR");
- entityResource.getAssociationOverrides().add(2, OrmFactory.eINSTANCE.createXmlAssociationOverride());
- entityResource.getAssociationOverrides().get(2).setName("BAZ");
-
- ListIterator<OrmAssociationOverride> associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("FOO", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().move(2, 0);
- associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().move(0, 1);
- associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("BAR", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(1);
- associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertEquals("FOO", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(1);
- associationOverrides = overrideContainer.specifiedOverrides();
- assertEquals("BAZ", associationOverrides.next().getName());
- assertFalse(associationOverrides.hasNext());
-
- entityResource.getAssociationOverrides().remove(0);
- associationOverrides = overrideContainer.specifiedOverrides();
- assertFalse(associationOverrides.hasNext());
- }
-
- public void testAssociationOverrideIsVirtual() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "test.AnnotationTestTypeChild");
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
- OrmAssociationOverrideContainer overrideContainer = ormEntity.getAssociationOverrideContainer();
-
- ListIterator<OrmVirtualAssociationOverride> virtualAssociationOverrides = overrideContainer.virtualOverrides();
- OrmVirtualAssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address2", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address3", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address4", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
- assertFalse(virtualAssociationOverrides.hasNext());
-
- overrideContainer.virtualOverrides().next().convertToSpecified();
- AssociationOverride specifiedAssociationOverride = overrideContainer.specifiedOverrides().next();
- assertFalse(specifiedAssociationOverride.isVirtual());
-
-
- virtualAssociationOverrides = overrideContainer.virtualOverrides();
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address2", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address3", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
-
- virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address4", virtualAssociationOverride.getName());
- assertTrue(virtualAssociationOverride.isVirtual());
- assertFalse(virtualAssociationOverrides.hasNext());
- }
-
- public void testNestedVirtualAttributeOverrides() throws Exception {
- createTestMappedSuperclassCustomer();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- OrmPersistentType customerPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Customer");
- OrmPersistentType longTimeCustomerPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".LongTimeCustomer");
- OrmPersistentType addressPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- OrmPersistentType zipCodePersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".ZipCode");
-
- OrmAttributeOverrideContainer attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
-
- assertEquals(6, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<OrmVirtualAttributeOverride> virtualAttributeOverrides = attributeOverrideContainer.virtualOverrides();
- OrmVirtualAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.street", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.city", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.zip", virtualAttributeOverride.getName());
- assertEquals("zip", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("plusfour", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- assertEquals(null, virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
-
- zipCodePersistentType.getAttributeNamed("plusfour").convertToSpecified();
- BasicMapping plusFourMapping = (BasicMapping) zipCodePersistentType.getAttributeNamed("plusfour").getMapping();
- plusFourMapping.getColumn().setSpecifiedName("BLAH");
- plusFourMapping.getColumn().setSpecifiedTable("BLAH_TABLE");
- plusFourMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- plusFourMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- plusFourMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- plusFourMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- plusFourMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- //check the top-level embedded (Customer.address) attribute override to verify it is getting settings from the specified column on Zipcode.plusfour
- virtualAttributeOverride = (OrmVirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(false, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(5, virtualAttributeOverride.getColumn().getLength());
- assertEquals(6, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(7, virtualAttributeOverride.getColumn().getScale());
-
- //set an attribute override on Address.zipCode embedded mapping
- addressPersistentType.getAttributeNamed("zipCode").convertToSpecified();
- AttributeOverride specifiedAttributeOverride = ((VirtualAttributeOverride) ((EmbeddedMapping) addressPersistentType.getAttributeNamed("zipCode").getMapping()).getAttributeOverrideContainer().getOverrideNamed("plusfour")).convertToSpecified();
- specifiedAttributeOverride.getColumn().setSpecifiedName("BLAH_OVERRIDE");
- specifiedAttributeOverride.getColumn().setSpecifiedTable("BLAH_TABLE_OVERRIDE");
- specifiedAttributeOverride.getColumn().setColumnDefinition("COLUMN_DEFINITION_OVERRIDE");
-
-
- attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- virtualAttributeOverride = (OrmVirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH_OVERRIDE", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE_OVERRIDE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
- specifiedAttributeOverride = virtualAttributeOverride.convertToSpecified();
- assertEquals(false, specifiedAttributeOverride.isVirtual());
- assertEquals("address.zipCode.plusfour", specifiedAttributeOverride.getName());
- //TODO I have the default wrong in this case, but this was wrong before as well. Need to fix this later
-// assertEquals("plusfour", specifiedAttributeOverride.getColumn().getDefaultName());
- assertEquals("BLAH_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedName());
-// assertEquals("Customer", specifiedAttributeOverride.getColumn().getDefaultTable());
- assertEquals("BLAH_TABLE_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", specifiedAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, specifiedAttributeOverride.getColumn().isInsertable());
- assertEquals(true, specifiedAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, specifiedAttributeOverride.getColumn().isUnique());
- assertEquals(true, specifiedAttributeOverride.getColumn().isNullable());
- assertEquals(255, specifiedAttributeOverride.getColumn().getLength());
- assertEquals(0, specifiedAttributeOverride.getColumn().getPrecision());
- assertEquals(0, specifiedAttributeOverride.getColumn().getScale());
- }
-
- public void testNestedVirtualAttributeOverridesElementCollection() throws Exception {
- createTestMappedSuperclassCustomerWithElementCollection();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- OrmPersistentType customerPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Customer");
- OrmPersistentType longTimeCustomerPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".LongTimeCustomer");
- OrmPersistentType addressPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- OrmPersistentType zipCodePersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".ZipCode");
-
- customerPersistentType.getJavaPersistentType().getAttributeNamed("address").setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- OrmAttributeOverrideContainer attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
-
- assertEquals(6, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<OrmVirtualAttributeOverride> virtualAttributeOverrides = attributeOverrideContainer.virtualOverrides();
- OrmVirtualAttributeOverride virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("id", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("name", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.street", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.city", virtualAttributeOverride.getName());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.zip", virtualAttributeOverride.getName());
- assertEquals("zip", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- virtualAttributeOverride = virtualAttributeOverrides.next();
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("plusfour", virtualAttributeOverride.getColumn().getName());
- assertEquals("LongTimeCustomer", virtualAttributeOverride.getColumn().getTable());
- assertEquals(null, virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
-
- zipCodePersistentType.getAttributeNamed("plusfour").convertToSpecified();
- BasicMapping plusFourMapping = (BasicMapping) zipCodePersistentType.getAttributeNamed("plusfour").getMapping();
- plusFourMapping.getColumn().setSpecifiedName("BLAH");
- plusFourMapping.getColumn().setSpecifiedTable("BLAH_TABLE");
- plusFourMapping.getColumn().setColumnDefinition("COLUMN_DEFINITION");
- plusFourMapping.getColumn().setSpecifiedInsertable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUpdatable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedUnique(Boolean.TRUE);
- plusFourMapping.getColumn().setSpecifiedNullable(Boolean.FALSE);
- plusFourMapping.getColumn().setSpecifiedLength(Integer.valueOf(5));
- plusFourMapping.getColumn().setSpecifiedPrecision(Integer.valueOf(6));
- plusFourMapping.getColumn().setSpecifiedScale(Integer.valueOf(7));
-
- attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- //check the top-level embedded (Customer.address) attribute override to verify it is getting settings from the specified column on Zipcode.plusfour
- virtualAttributeOverride = (OrmVirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(false, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(false, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(5, virtualAttributeOverride.getColumn().getLength());
- assertEquals(6, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(7, virtualAttributeOverride.getColumn().getScale());
-
- //set an attribute override on Address.zipCode embedded mapping
- addressPersistentType.getAttributeNamed("zipCode").convertToSpecified();
- AttributeOverride specifiedAttributeOverride = ((VirtualAttributeOverride) ((EmbeddedMapping) addressPersistentType.getAttributeNamed("zipCode").getMapping()).getAttributeOverrideContainer().getOverrideNamed("plusfour")).convertToSpecified();
- specifiedAttributeOverride.getColumn().setSpecifiedName("BLAH_OVERRIDE");
- specifiedAttributeOverride.getColumn().setSpecifiedTable("BLAH_TABLE_OVERRIDE");
- specifiedAttributeOverride.getColumn().setColumnDefinition("COLUMN_DEFINITION_OVERRIDE");
-
-
- attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAttributeOverrideContainer();
- virtualAttributeOverride = (OrmVirtualAttributeOverride) attributeOverrideContainer.getOverrideNamed("address.zipCode.plusfour");
- assertEquals("address.zipCode.plusfour", virtualAttributeOverride.getName());
- assertEquals("BLAH_OVERRIDE", virtualAttributeOverride.getColumn().getName());
- assertEquals("BLAH_TABLE_OVERRIDE", virtualAttributeOverride.getColumn().getTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", virtualAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, virtualAttributeOverride.getColumn().isInsertable());
- assertEquals(true, virtualAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, virtualAttributeOverride.getColumn().isUnique());
- assertEquals(true, virtualAttributeOverride.getColumn().isNullable());
- assertEquals(255, virtualAttributeOverride.getColumn().getLength());
- assertEquals(0, virtualAttributeOverride.getColumn().getPrecision());
- assertEquals(0, virtualAttributeOverride.getColumn().getScale());
-
- specifiedAttributeOverride = virtualAttributeOverride.convertToSpecified();
- assertEquals(false, specifiedAttributeOverride.isVirtual());
- assertEquals("address.zipCode.plusfour", specifiedAttributeOverride.getName());
- //TODO I have the default wrong in this case, but this was wrong before as well. Need to fix this later
-// assertEquals("plusfour", specifiedAttributeOverride.getColumn().getDefaultName());
- assertEquals("BLAH_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedName());
-// assertEquals("Customer", specifiedAttributeOverride.getColumn().getDefaultTable());
- assertEquals("BLAH_TABLE_OVERRIDE", specifiedAttributeOverride.getColumn().getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION_OVERRIDE", specifiedAttributeOverride.getColumn().getColumnDefinition());
- assertEquals(true, specifiedAttributeOverride.getColumn().isInsertable());
- assertEquals(true, specifiedAttributeOverride.getColumn().isUpdatable());
- assertEquals(false, specifiedAttributeOverride.getColumn().isUnique());
- assertEquals(true, specifiedAttributeOverride.getColumn().isNullable());
- assertEquals(255, specifiedAttributeOverride.getColumn().getLength());
- assertEquals(0, specifiedAttributeOverride.getColumn().getPrecision());
- assertEquals(0, specifiedAttributeOverride.getColumn().getScale());
- }
- public void testNestedVirtualAssociationOverrides() throws Exception {
- createTestMappedSuperclassCustomer();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Customer");
- OrmPersistentType longTimeCustomerPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".LongTimeCustomer");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".ZipCode");
-
- OrmAssociationOverrideContainer attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAssociationOverrideContainer();
-
- assertEquals(1, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<OrmVirtualAssociationOverride> virtualAssociationOverrides = attributeOverrideContainer.virtualOverrides();
- OrmVirtualAssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address.state", virtualAssociationOverride.getName());
- }
-
- public void testNestedVirtualAssociationOverridesElementCollection() throws Exception {
- createTestMappedSuperclassCustomerWithElementCollection();
- createTestEntityLongTimeCustomer();
- createTestEmbeddableAddress();
- createTestEmbeddableZipCode();
-
- getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Customer");
- OrmPersistentType longTimeCustomerPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".LongTimeCustomer");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".ZipCode");
-
- OrmAssociationOverrideContainer attributeOverrideContainer = ((OrmEntity) longTimeCustomerPersistentType.getMapping()).getAssociationOverrideContainer();
-
- assertEquals(1, attributeOverrideContainer.virtualOverridesSize());
- ListIterator<OrmVirtualAssociationOverride> virtualAssociationOverrides = attributeOverrideContainer.virtualOverrides();
- OrmVirtualAssociationOverride virtualAssociationOverride = virtualAssociationOverrides.next();
- assertEquals("address.state", virtualAssociationOverride.getName());
- }
-
- public void testSetSpecifiedCacheable() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable2_0 = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(null, cacheable2_0.getSpecifiedCacheable());
- assertEquals(null, entityResource.getCacheable());
-
- cacheable2_0.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cacheable2_0.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, entityResource.getCacheable());
-
- cacheable2_0.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, cacheable2_0.getSpecifiedCacheable());
- assertEquals(Boolean.TRUE, entityResource.getCacheable());
-
- cacheable2_0.setSpecifiedCacheable(null);
- assertEquals(null, cacheable2_0.getSpecifiedCacheable());
- assertEquals(null, entityResource.getCacheable());
- }
-
- public void testGetSpecifiedCacheable() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
- XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, entityResource.getCacheable());
-
- entityResource.setCacheable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.TRUE, entityResource.getCacheable());
-
- entityResource.setCacheable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, entityResource.getCacheable());
-
- entityResource.setCacheable(null);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, entityResource.getCacheable());
- }
-
- public void testIsDefaultCacheable() throws Exception {
- createTestEntity();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- assertEquals(SharedCacheMode.DISABLE_SELECTIVE, persistenceUnit2_0.getSharedCacheMode());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ALL);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.UNSPECIFIED);
- assertEquals(true, cacheable.isDefaultCacheable());
- }
-
- public void testIsDefaultCacheableFromSuperType() throws Exception {
- createTestEntity();
- createTestSubType();
- OrmPersistentType subOrmPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_SUB_TYPE_NAME);
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity subEntity = (EclipseLinkEntity) subOrmPersistentType.getMapping();
- EclipseLinkEntity entity = (EclipseLinkEntity) ormPersistentType.getMapping();
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) subEntity).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) entity).getCacheable();
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(null);
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
- }
-
- public void testIsDefaultCacheableFromJava() throws Exception {
- createTestEntity();
- createTestSubType();
- OrmPersistentType subOrmPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_SUB_TYPE_NAME);
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) subOrmPersistentType.getMapping()).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
-
- Cacheable2_0 javaCacheable = ((CacheableHolder2_0) ormPersistentType.getJavaPersistentType().getMapping()).getCacheable();
- javaCacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- javaCacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- javaCacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- javaCacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
- }
-
- public void testIsDefaultCacheableFromMappedSuperClass() throws Exception {
- createTestMappedSuperclass();
- createTestSubType();
- OrmPersistentType subOrmPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_SUB_TYPE_NAME);
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkEntity subEntity = (EclipseLinkEntity) subOrmPersistentType.getMapping();
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) subEntity).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) mappedSuperclass).getCacheable();
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(null);
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java
deleted file mode 100644
index c41b1c3e48..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmManyToManyMappingTests.java
+++ /dev/null
@@ -1,963 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-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.Cascade2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkManyToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmManyToManyMappingTests
- extends EclipseLink2_0OrmContextModelTestCase
-{
- public EclipseLink2_0OrmManyToManyMappingTests(String name) {
- super(name);
- }
-
-
- 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(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(" 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 ICompilationUnit createTestEntityWithValidManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private java.util.Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidMapManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- 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);
- }
-
- private ICompilationUnit createTestEntityManyToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_MANY, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, JPA.ORDER_BY, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToMany(fetch=FetchType.EAGER, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH, CascadeType.DETACH})");
- sb.append(CR);
- sb.append(" @OrderBy(\"city\"");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" private java.util.Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- public void testCandidateMappedByAttributeNames() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
- ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames =
- manyToManyMapping.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());
-
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- attributeNames =
- manyToManyMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- attributeNames =
- manyToManyMapping.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 = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
- assertEquals("foo", stateFooMapping.getName());
- }
-
- public void testCandidateMappedByAttributeNamesElementCollection() throws Exception {
- createTestEntityWithValidManyToManyMapping();
- createTestTargetEntityAddressWithElementCollection();
- createTestEmbeddableState();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
- ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.attributes().next();
- ManyToManyMapping manyToManyMapping = (ManyToManyMapping) persistentAttribute.getMapping();
-
- Iterator<String> attributeNames =
- manyToManyMapping.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());
-
- manyToManyMapping.setSpecifiedTargetEntity("foo");
- attributeNames =
- manyToManyMapping.getRelationship().getMappedByStrategy().candidateMappedByAttributeNames();
- assertFalse(attributeNames.hasNext());
-
- manyToManyMapping.setSpecifiedTargetEntity(null);
- attributeNames =
- manyToManyMapping.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 = manyToManyMapping.getResolvedTargetEntity().resolveAttributeMapping("state.foo");
- assertEquals("foo", stateFooMapping.getName());
- }
-
- public void testUpdateMapKey() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedMapKey());
- assertNull(manyToMany.getMapKey());
-
- //set mapKey in the resource model, verify context model does not change
- manyToMany.setMapKey(OrmFactory.eINSTANCE.createMapKey());
- assertNull(ormManyToManyMapping.getSpecifiedMapKey());
- assertNotNull(manyToMany.getMapKey());
-
- //set mapKey name in the resource model, verify context model updated
- manyToMany.getMapKey().setName("myMapKey");
- assertEquals("myMapKey", ormManyToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", manyToMany.getMapKey().getName());
-
- //set mapKey name to null in the resource model
- manyToMany.getMapKey().setName(null);
- assertNull(ormManyToManyMapping.getSpecifiedMapKey());
- assertNull(manyToMany.getMapKey().getName());
-
- manyToMany.getMapKey().setName("myMapKey");
- manyToMany.setMapKey(null);
- assertNull(ormManyToManyMapping.getSpecifiedMapKey());
- assertNull(manyToMany.getMapKey());
- }
-
- public void testUpdateVirtualMapKey() throws Exception {
- createTestEntityWithValidMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertNull(virtualManyToManyMapping.getSpecifiedMapKey());
- assertNull(virtualManyToManyMapping.getMapKey());
- assertFalse(virtualManyToManyMapping.isPkMapKey());
- assertFalse(virtualManyToManyMapping.isCustomMapKey());
- assertTrue(virtualManyToManyMapping.isNoMapKey());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaManyToManyMapping.setPkMapKey(true);
- assertEquals("id", virtualManyToManyMapping.getMapKey());
- assertTrue(virtualManyToManyMapping.isPkMapKey());
- assertFalse(virtualManyToManyMapping.isCustomMapKey());
- assertFalse(virtualManyToManyMapping.isNoMapKey());
-
-
- //set custom specified mapKey in the java, verify virtual orm mapping updates
- javaManyToManyMapping.setCustomMapKey(true);
- javaManyToManyMapping.setSpecifiedMapKey("city");
- assertEquals("city", virtualManyToManyMapping.getSpecifiedMapKey());
- assertEquals("city", virtualManyToManyMapping.getMapKey());
- assertFalse(virtualManyToManyMapping.isPkMapKey());
- assertTrue(virtualManyToManyMapping.isCustomMapKey());
- assertFalse(virtualManyToManyMapping.isNoMapKey());
- }
-
- public void testModifyMapKey() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping ormManyToManyMapping = (OrmManyToManyMapping) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedMapKey());
- assertNull(manyToMany.getMapKey());
-
- //set mapKey in the context model, verify resource model updated
- ormManyToManyMapping.setSpecifiedMapKey("myMapKey");
- assertEquals("myMapKey", ormManyToManyMapping.getSpecifiedMapKey());
- assertEquals("myMapKey", manyToMany.getMapKey().getName());
-
- //set mapKey to null in the context model
- ormManyToManyMapping.setSpecifiedMapKey(null);
- assertNull(ormManyToManyMapping.getSpecifiedMapKey());
- assertNull(manyToMany.getMapKey().getName());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames =
- virtualManyToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaManyToManyMapping javaManyToManyMapping = (JavaManyToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames = virtualManyToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- javaManyToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = virtualManyToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- ormPersistentType.getAttributeNamed("addresses").convertToSpecified();
- OrmManyToManyMapping specifiedManyToManyMapping = (OrmManyToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- mapKeyNames = specifiedManyToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- specifiedManyToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = specifiedManyToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.foo", mapKeyNames.next());
- assertEquals("state.address", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- specifiedManyToManyMapping.setSpecifiedTargetEntity("String");
- mapKeyNames = specifiedManyToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
- }
-
- public void testUpdateMapKeyClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(manyToMany.getMapKeyClass());
-
- //set mapKey in the resource model, verify context model does not change
- manyToMany.setMapKeyClass(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertNotNull(manyToMany.getMapKeyClass());
-
- //set mapKey name in the resource model, verify context model updated
- manyToMany.getMapKeyClass().setClassName("String");
- assertEquals("String", ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("String", manyToMany.getMapKeyClass().getClassName());
-
- //set mapKey name to null in the resource model
- manyToMany.getMapKeyClass().setClassName(null);
- assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(manyToMany.getMapKeyClass().getClassName());
-
- manyToMany.getMapKeyClass().setClassName("String");
- manyToMany.setMapKeyClass(null);
- assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(manyToMany.getMapKeyClass());
- }
-
- public void testUpdateVirtualMapKeyClass() throws Exception {
- createTestEntityWithValidMapManyToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- ManyToManyMapping2_0 virtualManyToManyMapping = (ManyToManyMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaManyToManyMapping2_0 javaManyToManyMapping = (JavaManyToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertEquals("java.lang.String", virtualManyToManyMapping.getMapKeyClass());
- assertNull(virtualManyToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualManyToManyMapping.getDefaultMapKeyClass());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaManyToManyMapping.setSpecifiedMapKeyClass("Integer");
- assertEquals("Integer", virtualManyToManyMapping.getMapKeyClass());
- assertEquals("Integer", virtualManyToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualManyToManyMapping.getDefaultMapKeyClass());
- }
-
- public void testModifyMapKeyClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "manyToManyMapping");
- OrmManyToManyMapping2_0 ormManyToManyMapping = (OrmManyToManyMapping2_0) ormPersistentAttribute.getMapping();
- XmlManyToMany manyToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getManyToManys().get(0);
-
- assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(manyToMany.getMapKeyClass());
-
- //set mapKey in the context model, verify resource model updated
- ormManyToManyMapping.setSpecifiedMapKeyClass("String");
- assertEquals("String", ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("String", manyToMany.getMapKeyClass().getClassName());
-
- //set mapKey to null in the context model
- ormManyToManyMapping.setSpecifiedMapKeyClass(null);
- assertNull(ormManyToManyMapping.getSpecifiedMapKeyClass());
- assertNull(manyToMany.getMapKeyClass());
- }
-
- public void testOrderColumnDefaults() throws Exception {
- createTestEntityPrintQueue();
- createTestEntityPrintJob();
-
- OrmPersistentType printQueuePersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue");
- OrmPersistentAttribute jobsPersistentAttribute = printQueuePersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs");
- OrmManyToManyMapping jobsMapping = (OrmManyToManyMapping) jobsPersistentAttribute.getMapping();
- jobsMapping.getRelationship().setStrategyToMappedBy();
- jobsMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("queues");
-
- OrmPersistentType printJobPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob");
- OrmPersistentAttribute queuesPersistentAttribute = printJobPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "queues");
- OrmManyToManyMapping queuesMapping = (OrmManyToManyMapping) queuesPersistentAttribute.getMapping();
-
- getOrmXmlResource().save(null);
- Orderable2_0 jobsOrderable = ((Orderable2_0) jobsMapping.getOrderable());
- OrderColumn2_0 jobsOrderColumn = jobsOrderable.getOrderColumn();
- assertEquals(false, jobsOrderable.isOrderColumnOrdering());
- assertEquals(true, jobsOrderable.isNoOrdering());
- Orderable2_0 queuesOrderable = ((Orderable2_0) queuesMapping.getOrderable());
- OrderColumn2_0 queuesOrderColumn = queuesOrderable.getOrderColumn();
- assertEquals(false, queuesOrderable.isOrderColumnOrdering());
- assertEquals(true, queuesOrderable.isNoOrdering());
-
-
- jobsOrderable.setOrderColumnOrdering(true);
- jobsOrderColumn = jobsOrderable.getOrderColumn();
- assertEquals(true, jobsOrderable.isOrderColumnOrdering());
- assertEquals(null, jobsOrderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", jobsOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", jobsOrderColumn.getTable());
- queuesOrderable.setOrderColumnOrdering(true);
- queuesOrderColumn = queuesOrderable.getOrderColumn();
- assertEquals(true, queuesOrderable.isOrderColumnOrdering());
- assertEquals(null, queuesOrderColumn.getSpecifiedName());
- assertEquals("queues_ORDER", queuesOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", queuesOrderColumn.getTable());
-
- jobsOrderColumn.setSpecifiedName("FOO");
- assertEquals("FOO", jobsOrderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", jobsOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", jobsOrderColumn.getTable());
- queuesOrderColumn.setSpecifiedName("BAR");
- assertEquals("BAR", queuesOrderColumn.getSpecifiedName());
- assertEquals("queues_ORDER", queuesOrderColumn.getDefaultName());
- assertEquals("PrintJob_PrintQueue", queuesOrderColumn.getTable());
-
-
- ((Entity) printJobPersistentType.getMapping()).getTable().setSpecifiedName("MY_TABLE");
- assertEquals("MY_TABLE_PrintQueue", jobsOrderColumn.getTable());
- assertEquals("MY_TABLE_PrintQueue", queuesOrderColumn.getTable());
-
- ((Entity) printQueuePersistentType.getMapping()).getTable().setSpecifiedName("OTHER_TABLE");
- assertEquals("MY_TABLE_OTHER_TABLE", jobsOrderColumn.getTable());
- assertEquals("MY_TABLE_OTHER_TABLE", queuesOrderColumn.getTable());
-
- queuesMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("MY_JOIN_TABLE");
- assertEquals("MY_JOIN_TABLE", jobsOrderColumn.getTable());
- assertEquals("MY_JOIN_TABLE", queuesOrderColumn.getTable());
- }
-
- public void testVirtualOrderColumn() throws Exception {
- createTestEntityPrintQueue();
- createTestEntityPrintJob();
-
- OrmPersistentType printQueuePersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue");
- OrmPersistentAttribute jobsPersistentAttribute = printQueuePersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs");
- OrmManyToManyMapping jobsMapping = (OrmManyToManyMapping) jobsPersistentAttribute.getMapping();
-
- OrmPersistentType printJobPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob");
- OrmPersistentAttribute queuesPersistentAttribute = printJobPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "queues");
- OrmManyToManyMapping queuesMapping = (OrmManyToManyMapping) queuesPersistentAttribute.getMapping();
-
- Orderable2_0 jobsOrderable = ((Orderable2_0) jobsMapping.getOrderable());
- assertEquals(false, jobsOrderable.isOrderColumnOrdering());
- assertEquals(true, jobsOrderable.isNoOrdering());
- Orderable2_0 queuesOrderable = ((Orderable2_0) queuesMapping.getOrderable());
- assertEquals(false, queuesOrderable.isOrderColumnOrdering());
- assertEquals(true, queuesOrderable.isNoOrdering());
-
- JavaManyToManyMapping javaJobsManyToManyMapping = (JavaManyToManyMapping) jobsPersistentAttribute.getJavaPersistentAttribute().getMapping();
- ((Orderable2_0) javaJobsManyToManyMapping.getOrderable()).setOrderColumnOrdering(true);
-
- assertEquals(false, jobsOrderable.isOrderColumnOrdering());
- assertEquals(true, jobsOrderable.isNoOrdering());
- assertEquals(false, queuesOrderable.isOrderColumnOrdering());
- assertEquals(true, queuesOrderable.isNoOrdering());
-
- jobsPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute jobsPersistentAttribute2 = printQueuePersistentType.getAttributeNamed("jobs");
- ManyToManyMapping virtualJobsMapping = (ManyToManyMapping) jobsPersistentAttribute2.getMapping();
- jobsOrderable = ((Orderable2_0) virtualJobsMapping.getOrderable());
- assertEquals(true, jobsOrderable.isOrderColumnOrdering());
- assertEquals(false, jobsOrderable.isNoOrdering());
- assertEquals("PrintJob_PrintQueue", jobsOrderable.getOrderColumn().getTable());
- assertEquals("jobs_ORDER", jobsOrderable.getOrderColumn().getName());
- queuesPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute queuesPersistentAttribute2 = printJobPersistentType.getAttributeNamed("queues");
- ManyToManyMapping virtualQueuesMapping = (ManyToManyMapping) queuesPersistentAttribute2.getMapping();
- queuesOrderable = ((Orderable2_0) virtualQueuesMapping.getOrderable());
- assertEquals(true, queuesOrderable.isOrderColumnOrdering());
- assertEquals(false, queuesOrderable.isNoOrdering());
- assertEquals("PrintJob_PrintQueue", queuesOrderable.getOrderColumn().getTable());
- assertEquals("queues_ORDER", queuesOrderable.getOrderColumn().getName());
-
- ((Orderable2_0) javaJobsManyToManyMapping.getOrderable()).getOrderColumn().setSpecifiedName("FOO");
- assertEquals("PrintJob_PrintQueue", jobsOrderable.getOrderColumn().getTable());
- assertEquals("FOO", jobsOrderable.getOrderColumn().getName());
- assertEquals("PrintJob_PrintQueue", queuesOrderable.getOrderColumn().getTable());
- assertEquals("queues_ORDER", queuesOrderable.getOrderColumn().getName());
-
- JavaManyToManyMapping javaQueuesManyToManyMapping = (JavaManyToManyMapping) queuesPersistentAttribute2.getJavaPersistentAttribute().getMapping();
- javaQueuesManyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("JOIN_TABLE");
- assertEquals("JOIN_TABLE", jobsOrderable.getOrderColumn().getTable());
- assertEquals("FOO", jobsOrderable.getOrderColumn().getName());
- assertEquals("JOIN_TABLE", queuesOrderable.getOrderColumn().getTable());
- assertEquals("queues_ORDER", queuesOrderable.getOrderColumn().getName());
- }
-
- private void createTestEntityPrintQueue() 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.MANY_TO_MANY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ORDER_COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintQueue").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @ManyToMany(mappedBy=\"queues\")").append(CR);
- sb.append(" @OrderColumn").append(CR);
- sb.append(" private java.util.List<test.PrintJob> jobs;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintQueue.java", sourceWriter);
- }
-
- private void createTestEntityPrintJob() 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.MANY_TO_MANY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ORDER_COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintJob").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(" @ManyToMany").append(CR);
- sb.append(" @OrderColumn").append(CR);
- sb.append(" private java.util.List<test.PrintQueue> queues;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintJob.java", sourceWriter);
- }
-
- public void testVirtualMapKeyColumnDefaults() throws Exception {
- createTestEntityWithValidMapManyToManyMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //virtual attribute in orm.xml, java attribute has no value Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ManyToManyMapping2_0 addressesVirtualMapping = (ManyToManyMapping2_0) addressesPersistentAttribute.getMapping();
- Column virtualColumn = addressesVirtualMapping.getMapKeyColumn();
- assertEquals("addresses_KEY", virtualColumn.getName());
- assertEquals(TYPE_NAME + "_Address", virtualColumn.getTable());
- assertEquals(null, virtualColumn.getColumnDefinition());
- assertTrue(virtualColumn.isInsertable());
- assertTrue(virtualColumn.isUpdatable());
- assertTrue(virtualColumn.isNullable());
- assertFalse(virtualColumn.isUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale());
-
- //set Column annotation in Java
- JavaManyToManyMapping2_0 javaManyToManyMapping = (JavaManyToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedName("FOO");
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedTable("FOO_TABLE");
- javaManyToManyMapping.getMapKeyColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedNullable(Boolean.FALSE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedUnique(Boolean.TRUE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedLength(Integer.valueOf(45));
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedScale(Integer.valueOf(47));
-
- assertEquals("FOO", virtualColumn.getSpecifiedName());
- assertEquals("FOO_TABLE", virtualColumn.getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION", virtualColumn.getColumnDefinition());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, virtualColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, virtualColumn.getSpecifiedUnique());
- assertEquals(Integer.valueOf(45), virtualColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(46), virtualColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(47), virtualColumn.getSpecifiedScale());
-
-
- //set metadata-complete, orm.xml virtual column ignores java column annotation
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- addressesPersistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- //becomes a 1-m by default
- OneToManyMapping2_0 addressesMapping = (OneToManyMapping2_0) addressesPersistentAttribute.getMapping();
- virtualColumn = addressesMapping.getMapKeyColumn();
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, addressesPersistentAttribute.getMappingKey());
-
- assertEquals("addresses_KEY", virtualColumn.getName());
- assertEquals(TYPE_NAME + "_Address", virtualColumn.getTable());
- assertEquals(null, virtualColumn.getColumnDefinition());
- assertTrue(virtualColumn.isInsertable());
- assertTrue(virtualColumn.isUpdatable());
- assertTrue(virtualColumn.isNullable());
- assertFalse(virtualColumn.isUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, virtualColumn.getLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, virtualColumn.getPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, virtualColumn.getScale());
- }
-
- public void testNullMapKeyColumnDefaults() throws Exception {
- createTestEntityWithValidMapManyToManyMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
-
- OrmManyToManyMapping2_0 addressesVirtualMapping = (OrmManyToManyMapping2_0) addressesPersistentAttribute.getMapping();
- Column ormColumn = addressesVirtualMapping.getMapKeyColumn();
-
- //set Column annotation in Java
- JavaManyToManyMapping2_0 javaManyToManyMapping = (JavaManyToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedName("FOO");
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedTable("FOO_TABLE");
- javaManyToManyMapping.getMapKeyColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedNullable(Boolean.FALSE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedUnique(Boolean.TRUE);
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedLength(Integer.valueOf(45));
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedScale(Integer.valueOf(47));
-
-
- assertEquals("addresses_KEY", ormColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_Address", ormColumn.getDefaultTable());
- assertEquals(true, ormColumn.isDefaultInsertable());
- assertEquals(true, ormColumn.isDefaultUpdatable());
- assertEquals(true, ormColumn.isDefaultNullable());
- assertEquals(false, ormColumn.isDefaultUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getDefaultLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getDefaultPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getDefaultScale());
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualMapKeyColumnTable() throws Exception {
- createTestEntityWithValidMapManyToManyMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //virtual attribute in orm.xml, java attribute has no Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- ManyToManyMapping2_0 addressesVirtualMapping = (ManyToManyMapping2_0) addressesPersistentAttribute.getMapping();
- Column ormColumn = addressesVirtualMapping.getMapKeyColumn();
-
- assertEquals(TYPE_NAME + "_Address", ormColumn.getTable());
-
- //entity table changes the join table default name
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE");
- assertEquals("ORM_TABLE_Address", ormColumn.getTable());
-
- //set Column table element in Java
- JavaManyToManyMapping2_0 javaManyToManyMapping = (JavaManyToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaManyToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("JAVA_JOIN_TABLE");
- assertEquals("JAVA_JOIN_TABLE", ormColumn.getTable());
- javaManyToManyMapping.getMapKeyColumn().setSpecifiedTable("JAVA_TABLE");
- assertEquals("JAVA_TABLE", ormColumn.getTable());
-
- //make name persistent attribute not virtual
- addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
- addressesVirtualMapping = (OrmManyToManyMapping2_0) addressesPersistentAttribute.getMapping();
- ormColumn = addressesVirtualMapping.getMapKeyColumn();
- assertNull(ormColumn.getSpecifiedTable());
- assertEquals("ORM_TABLE_Address", ormColumn.getDefaultTable());
- }
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityManyToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- ManyToManyMapping virtualManyToManyMapping = (ManyToManyMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualManyToManyMapping.getName());
- assertEquals(FetchType.EAGER, virtualManyToManyMapping.getSpecifiedFetch());
- assertEquals("Address", virtualManyToManyMapping.getSpecifiedTargetEntity());
- assertNull(virtualManyToManyMapping.getRelationship().
- getMappedByStrategy().getMappedByAttribute());
-
- Cascade2_0 cascade = (Cascade2_0) virtualManyToManyMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
- assertTrue(cascade.isDetach());
-
- assertTrue(virtualManyToManyMapping.getOrderable().isCustomOrdering());
- assertEquals("city", virtualManyToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertEquals(EclipseLinkJoinFetchType.INNER, ((EclipseLinkJoinFetchMapping) virtualManyToManyMapping).getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityManyToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
- assertTrue(virtualPersistentAttribute.isVirtual());
-
- virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- OrmPersistentAttribute ormPersistentAttribute= ormPersistentType.specifiedAttributes().next();
-
- OrmEclipseLinkManyToManyMapping ormManyToManyMapping = (OrmEclipseLinkManyToManyMapping) ormPersistentAttribute.getMapping();
- assertEquals("address", ormManyToManyMapping.getName());
- assertEquals(FetchType.LAZY, ormManyToManyMapping.getFetch());
- assertEquals("test.Address", ormManyToManyMapping.getTargetEntity());
- assertNull(ormManyToManyMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
-
- Cascade2_0 cascade = (Cascade2_0) ormManyToManyMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- assertFalse(cascade.isDetach());
-
- assertTrue(ormManyToManyMapping.getOrderable().isNoOrdering());
- assertEquals(null, ormManyToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertEquals(null, ormManyToManyMapping.getJoinFetch().getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java
deleted file mode 100644
index 9ca25b4a95..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java
+++ /dev/null
@@ -1,2375 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheCoordinationType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCacheType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkExistenceType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkCaching;
-import org.eclipse.jpt.jpa.eclipselink.core.context.java.JavaEclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlChangeTrackingType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmMappedSuperclassTests extends EclipseLink2_0OrmContextModelTestCase
-{
- protected static final String SUB_TYPE_NAME = "AnnotationTestTypeChild";
- protected static final String FULLY_QUALIFIED_SUB_TYPE_NAME = PACKAGE_NAME + "." + SUB_TYPE_NAME;
-
- public EclipseLink2_0OrmMappedSuperclassTests(String name) {
- super(name);
- }
-
-
- private ICompilationUnit createTestMappedSuperclassForReadOnly() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.READ_ONLY);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForCustomizer() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CUSTOMIZER);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForChangeTracking() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS, EclipseLink.CHANGE_TRACKING);
- }
-
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclass() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private void createTestMappedSuperclassSubType() throws Exception {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA.MAPPED_SUPERCLASS);
- sb.append(";");
- sb.append(CR);
- sb.append("@MappedSuperclass");
- sb.append(CR);
- sb.append("public class ").append("AnnotationTestTypeChild").append(" ");
- sb.append("extends " + TYPE_NAME + " ");
- sb.append("{}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "AnnotationTestTypeChild.java", sourceWriter);
- }
-
- private ICompilationUnit createTestMappedSuperclassForConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForObjectTypeConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestMappedSuperclassForStructConverters() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.MAPPED_SUPERCLASS);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@MappedSuperclass").append(CR);
- }
- });
- }
-
- public void testUpdateReadOnly() throws Exception {
- createTestMappedSuperclassForReadOnly();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkMappedSuperclass javaContextMappedSuperclass = (JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to false, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // clear xml read only, set java read only to true, check defaults
-
- resourceMappedSuperclass.setReadOnly(null);
- javaContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- // set xml read only to false, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertTrue(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // clear xml read only, set java read only to false, check defaults
-
- resourceMappedSuperclass.setReadOnly(null);
- javaContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.FALSE);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to false, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set xml read only to true, check override
-
- resourceMappedSuperclass.setReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertFalse(javaContextMappedSuperclass.getReadOnly().isReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
- }
-
- public void testModifyReadOnly() throws Exception {
- createTestMappedSuperclassForReadOnly();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to true, check resource
-
- ormContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getReadOnly());
- assertTrue(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.TRUE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to false, check resource
-
- ormContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertEquals(Boolean.FALSE, ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
-
- // set context read only to null, check resource
-
- ormContextMappedSuperclass.getReadOnly().setSpecifiedReadOnly(null);
-
- assertNull(resourceMappedSuperclass.getReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isReadOnly());
- assertFalse(ormContextMappedSuperclass.getReadOnly().isDefaultReadOnly());
- assertNull(ormContextMappedSuperclass.getReadOnly().getSpecifiedReadOnly());
- }
-
- public void testUpdateCustomizerClass() throws Exception {
- createTestMappedSuperclassForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkMappedSuperclass javaContextMappedSuperclass = (JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set xml customizer, check defaults
- resourceMappedSuperclass.setCustomizer(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(resourceMappedSuperclass.getCustomizer().getClassName());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
-
- // set xml customizer class, check override
-
- resourceMappedSuperclass.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceMappedSuperclass.getCustomizer().getClassName());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // clear xml customizer class, set java customizer class, check defaults
-
- resourceMappedSuperclass.getCustomizer().setClassName(null);
- javaContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass("bar");
-
- assertNull(resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("bar", javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("bar", javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- // set xml customizer class, check override
-
- resourceMappedSuperclass.getCustomizer().setClassName("foo");
-
- assertEquals("foo", resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("bar", javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertEquals("bar", ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- //set xml customizer null
- javaContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass(null);
- resourceMappedSuperclass.setCustomizer(null);
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(javaContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- }
-
- public void testModifyCustomizerClass() throws Exception {
- createTestMappedSuperclassForCustomizer();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer, check resource
-
- ormContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass("foo");
-
- assertEquals("foo", resourceMappedSuperclass.getCustomizer().getClassName());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertEquals("foo", ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
-
- // set context customizer to null, check resource
-
- ormContextMappedSuperclass.getCustomizer().setSpecifiedCustomizerClass(null);
-
- assertNull(resourceMappedSuperclass.getCustomizer());
- assertNull(ormContextMappedSuperclass.getCustomizer().getCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getDefaultCustomizerClass());
- assertNull(ormContextMappedSuperclass.getCustomizer().getSpecifiedCustomizerClass());
- }
-
- public void testUpdateChangeTracking() throws Exception {
- createTestMappedSuperclassForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkMappedSuperclass javaContextMappedSuperclass = (JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to ATTRIBUTE, check context
-
- resourceMappedSuperclass.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to OBJECT, check context
-
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to DEFERRED, check context
-
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set xml type to AUTO, check context
-
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // clear xml change tracking, set java change tracking, check defaults
-
- resourceMappedSuperclass.setChangeTracking(null);
- javaContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // unset metadataComplete, set xml change tracking to OBJECT, check context
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- resourceMappedSuperclass.setChangeTracking(EclipseLinkOrmFactory.eINSTANCE.createXmlChangeTracking());
- resourceMappedSuperclass.getChangeTracking().setType(XmlChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, javaContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
- }
-
- public void testModifyChangeTracking() throws Exception {
- createTestMappedSuperclassForChangeTracking();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to ATTRIBUTE, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.ATTRIBUTE);
-
- assertEquals(XmlChangeTrackingType.ATTRIBUTE, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.ATTRIBUTE, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to OBJECT, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.OBJECT);
-
- assertEquals(XmlChangeTrackingType.OBJECT, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.OBJECT, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to DEFERRED, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.DEFERRED);
-
- assertEquals(XmlChangeTrackingType.DEFERRED, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.DEFERRED, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to AUTO, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(EclipseLinkChangeTrackingType.AUTO);
-
- assertEquals(XmlChangeTrackingType.AUTO, resourceMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
-
- // set context change tracking to null, check resource
-
- ormContextMappedSuperclass.getChangeTracking().setSpecifiedType(null);
-
- assertNull(resourceMappedSuperclass.getChangeTracking());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getType());
- assertEquals(EclipseLinkChangeTrackingType.AUTO, ormContextMappedSuperclass.getChangeTracking().getDefaultType());
- assertNull(ormContextMappedSuperclass.getChangeTracking().getSpecifiedType());
- }
-
- public void testUpdateCacheType() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // set xml cache type, check settings
- resourceMappedSuperclass.getCache().setType(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getSpecifiedType());
-
-
- // set java cache type, check defaults
-
- javaContextCaching.setSpecifiedType(EclipseLinkCacheType.WEAK);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.FULL, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.FULL, ormContextCaching.getSpecifiedType());
-
- // clear xml cache type, check defaults
- resourceMappedSuperclass.getCache().setType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.WEAK, javaContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheType() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
-
- // set context cache type, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedType(EclipseLinkCacheType.HARD_WEAK);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheType.HARD_WEAK, resourceMappedSuperclass.getCache().getType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(EclipseLinkCacheType.HARD_WEAK, ormContextCaching.getSpecifiedType());
-
- // set context customizer to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getType());
- assertEquals(EclipseLinkCacheType.SOFT_WEAK, ormContextCaching.getDefaultType());
- assertEquals(null, ormContextCaching.getSpecifiedType());
- }
-
- public void testUpdateCacheCoordinationType() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set xml cache type, check settings
- resourceMappedSuperclass.getCache().setCoordinationType(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set java cache type, check defaults
-
- javaContextCaching.setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.INVALIDATE_CHANGED_OBJECTS, ormContextCaching.getSpecifiedCoordinationType());
-
- // clear xml cache type, check defaults
- resourceMappedSuperclass.getCache().setCoordinationType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, javaContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheCoordinationType() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
-
- // set context cache coordination type, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedCoordinationType(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, resourceMappedSuperclass.getCache().getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES, ormContextCaching.getSpecifiedCoordinationType());
-
- // set context coordination type to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedCoordinationType(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getCoordinationType());
- assertEquals(EclipseLinkCacheCoordinationType.SEND_OBJECT_CHANGES, ormContextCaching.getDefaultCoordinationType());
- assertEquals(null, ormContextCaching.getSpecifiedCoordinationType());
- }
-
-
- public void testUpdateCacheSize() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass xmlMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, xmlMappedSuperclass.getCache());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- // set xml cache, check defaults
- xmlMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, xmlMappedSuperclass.getCache().getSize());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // set xml cache size, check settings
- xmlMappedSuperclass.getCache().setSize(new Integer(105));
- assertEquals(new Integer(105), xmlMappedSuperclass.getCache().getSize());
- assertEquals(100, javaContextCaching.getSize());
- assertEquals(105, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(105), ormContextCaching.getSpecifiedSize());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedSize(new Integer(50));
-
- assertEquals(new Integer(105), xmlMappedSuperclass.getCache().getSize());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(105, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(105), ormContextCaching.getSpecifiedSize());
-
- // clear xml cache size, check defaults
- xmlMappedSuperclass.getCache().setSize(null);
-
- assertEquals(null, xmlMappedSuperclass.getCache().getSize());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // clear xml cache, check defaults
- xmlMappedSuperclass.setCache(null);
-
- assertEquals(null, xmlMappedSuperclass.getCache());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(50, ormContextCaching.getSize());
- assertEquals(50, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, xmlMappedSuperclass.getCache());
- assertEquals(50, javaContextCaching.getSize());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyCacheSize() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedSize(new Integer(50));
- assertEquals(new Integer(50), resourceMappedSuperclass.getCache().getSize());
- assertEquals(50, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(new Integer(50), ormContextCaching.getSpecifiedSize());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedSize(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(100, ormContextCaching.getSize());
- assertEquals(100, ormContextCaching.getDefaultSize());
- assertEquals(null, ormContextCaching.getSpecifiedSize());
- }
-
- public void testUpdateCacheAlwaysRefresh() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set xml cache always refresh, check settings
- resourceMappedSuperclass.getCache().setAlwaysRefresh(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(false, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set java cache always refresh, check defaults
-
- javaContextCaching.setSpecifiedAlwaysRefresh(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setAlwaysRefresh(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setAlwaysRefresh(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(true, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- }
-
- public void testModifyCacheAlwaysRefresh() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedAlwaysRefresh(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getAlwaysRefresh());
- assertEquals(true, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedAlwaysRefresh());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedAlwaysRefresh(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isAlwaysRefresh());
- assertEquals(false, ormContextCaching.isDefaultAlwaysRefresh());
- assertEquals(null, ormContextCaching.getSpecifiedAlwaysRefresh());
- }
-
- public void testUpdateCacheRefreshOnlyIfNewer() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setRefreshOnlyIfNewer(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(false, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setRefreshOnlyIfNewer(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setRefreshOnlyIfNewer(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- }
-
- public void testModifyCacheRefreshOnlyIfNewer() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedRefreshOnlyIfNewer(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getRefreshOnlyIfNewer());
- assertEquals(true, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedRefreshOnlyIfNewer(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isRefreshOnlyIfNewer());
- assertEquals(false, ormContextCaching.isDefaultRefreshOnlyIfNewer());
- assertEquals(null, ormContextCaching.getSpecifiedRefreshOnlyIfNewer());
- }
-
- public void testUpdateCacheDisableHits() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setDisableHits(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(false, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedDisableHits(Boolean.TRUE);
-
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setDisableHits(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedDisableHits());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setDisableHits(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(true, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- }
-
- public void testModifyCacheDisableHits() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedDisableHits(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getDisableHits());
- assertEquals(true, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedDisableHits());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedDisableHits(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, ormContextCaching.isDisableHits());
- assertEquals(false, ormContextCaching.isDefaultDisableHits());
- assertEquals(null, ormContextCaching.getSpecifiedDisableHits());
- }
-
- public void testUpdateCacheShared() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
- // set xml cache, check defaults
- resourceMappedSuperclass.setCache(EclipseLinkOrmFactory.eINSTANCE.createXmlCache());
- assertEquals(null, resourceMappedSuperclass.getCache().getShared());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set xml cache size, check settings
- resourceMappedSuperclass.getCache().setShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(true, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
-
- // set java cache size, check defaults
-
- javaContextCaching.setSpecifiedShared(Boolean.FALSE);
-
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
- // set xml cache always refresh to false
- resourceMappedSuperclass.getCache().setShared(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.TRUE, ormContextCaching.getSpecifiedShared());
-
- // clear xml cache always refresh, check defaults
- resourceMappedSuperclass.getCache().setShared(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // clear xml cache, check defaults
- resourceMappedSuperclass.setCache(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(false, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
-
- // set metadataComplete back to null, check defaults from java
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(false, javaContextCaching.isShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(false, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
- }
-
- public void testModifyCacheShared() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
-
- // set context cache size, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedShared(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMappedSuperclass.getCache().getShared());
- assertEquals(false, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(Boolean.FALSE, ormContextCaching.getSpecifiedShared());
-
- // set context cache size to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedShared(null);
-
- assertEquals(null, resourceMappedSuperclass.getCache());
- assertEquals(true, ormContextCaching.isShared());
- assertEquals(true, ormContextCaching.isDefaultShared());
- assertEquals(null, ormContextCaching.getSpecifiedShared());
- }
-
- public void testUpdateExistenceChecking() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- JavaEclipseLinkCaching javaContextCaching = ((JavaEclipseLinkMappedSuperclass) ormPersistentType.getJavaPersistentType().getMapping()).getCaching();
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set xml existence checking, check settings
- resourceMappedSuperclass.setExistenceChecking(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
-
- // set java cache existence checking, check defaults
-
- javaContextCaching.setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE);
-
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- // clear xml existence checking, check defaults
- resourceMappedSuperclass.setExistenceChecking(null);
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set metadataComplete to True, check defaults not from java
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(Boolean.TRUE);
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_NON_EXISTENCE, javaContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- ormContextMappedSuperclass.setSpecifiedMetadataComplete(null);
- }
-
- public void testModifyExistenceChecking() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- EclipseLinkCaching ormContextCaching = ormContextMappedSuperclass.getCaching();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- // check defaults
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
-
- // set context cache existence checking, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedExistenceType(EclipseLinkExistenceType.ASSUME_EXISTENCE);
- assertEquals(org.eclipse.jpt.jpa.eclipselink.core.resource.orm.ExistenceType.ASSUME_EXISTENCE, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(EclipseLinkExistenceType.ASSUME_EXISTENCE, ormContextCaching.getSpecifiedExistenceType());
-
- // set context existence checking to null, check resource
-
- ormContextMappedSuperclass.getCaching().setSpecifiedExistenceType(null);
-
- assertEquals(null, resourceMappedSuperclass.getExistenceChecking());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getExistenceType());
- assertEquals(EclipseLinkExistenceType.CHECK_DATABASE, ormContextCaching.getDefaultExistenceType());
- assertEquals(null, ormContextCaching.getSpecifiedExistenceType());
- }
- public void testUpdateCustomConverters() throws Exception {
- createTestMappedSuperclassForConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceMappedSuperclass.getConverters().add(resourceConverter);
- resourceConverter.setClassName("Foo");
- resourceConverter.setName("myConverter");
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlConverter resourceConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- resourceMappedSuperclass.getConverters().add(0, resourceConverter2);
- resourceConverter2.setClassName("Foo2");
- resourceConverter2.setName("myConverter2");
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getConverters().remove(resourceConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyCustomConverters() throws Exception {
- createTestMappedSuperclassForConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter(0);
- contextConverter.setConverterClass("Foo");
- contextConverter.setName("myConverter");
-
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ListIterator<EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.customConverters();
- EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter(0);
- contextConverter2.setConverterClass("Foo2");
- contextConverter2.setName("myConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getConverters().get(1).getClassName());
- assertEquals("myConverter", resourceMappedSuperclass.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveCustomConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getConverters().get(1).getClassName());
- assertEquals("myConverter2", resourceMappedSuperclass.getConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo", ormContextConverter.getConverterClass());
- assertEquals("myConverter", ormContextConverter.getName());
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getConverters().get(0).getClassName());
- assertEquals("myConverter2", resourceMappedSuperclass.getConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.customConvertersSize());
- ormContextConverters = ormContextConverterHolder.customConverters();
- ormContextConverter = ormContextConverters.next();
- assertEquals("Foo2", ormContextConverter.getConverterClass());
- assertEquals("myConverter2", ormContextConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeCustomConverter(contextConverter2);
-
- assertEquals(0, ormContextConverterHolder.customConvertersSize());
- assertFalse(ormContextConverterHolder.customConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateTypeConverters() throws Exception {
- createTestMappedSuperclassForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceMappedSuperclass.getTypeConverters().add(resourceTypeConverter);
- resourceTypeConverter.setDataType("Foo");
- resourceTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlTypeConverter resourceTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- resourceMappedSuperclass.getTypeConverters().add(0, resourceTypeConverter2);
- resourceTypeConverter2.setDataType("Foo2");
- resourceTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getTypeConverters().remove(resourceTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyTypeConverters() throws Exception {
- createTestMappedSuperclassForTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter.setDataType("Foo");
- contextTypeConverter.setName("myTypeConverter");
-
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ListIterator<EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter(0);
- contextTypeConverter2.setDataType("Foo2");
- contextTypeConverter2.setName("myTypeConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter", resourceMappedSuperclass.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveTypeConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(1).getDataType());
- assertEquals("myTypeConverter2", resourceMappedSuperclass.getTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter", ormContextTypeConverter.getName());
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
- assertEquals("myTypeConverter2", resourceMappedSuperclass.getTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.typeConvertersSize());
- ormContextTypeConverters = ormContextConverterHolder.typeConverters();
- ormContextTypeConverter = ormContextTypeConverters.next();
- assertEquals("Foo2", ormContextTypeConverter.getDataType());
- assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeTypeConverter(contextTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.typeConvertersSize());
- assertFalse(ormContextConverterHolder.typeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateObjectTypeConverters() throws Exception {
- createTestMappedSuperclassForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceMappedSuperclass.getObjectTypeConverters().add(resourceObjectTypeConverter);
- resourceObjectTypeConverter.setDataType("Foo");
- resourceObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlObjectTypeConverter resourceObjectTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- resourceMappedSuperclass.getObjectTypeConverters().add(0, resourceObjectTypeConverter2);
- resourceObjectTypeConverter2.setDataType("Foo2");
- resourceObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getObjectTypeConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getObjectTypeConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getObjectTypeConverters().remove(resourceObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyObjectTypeConverters() throws Exception {
- createTestMappedSuperclassForObjectTypeConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter.setDataType("Foo");
- contextObjectTypeConverter.setName("myObjectTypeConverter");
-
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ListIterator<EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter(0);
- contextObjectTypeConverter2.setDataType("Foo2");
- contextObjectTypeConverter2.setName("myObjectTypeConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter", resourceMappedSuperclass.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveObjectTypeConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(1).getDataType());
- assertEquals("myObjectTypeConverter2", resourceMappedSuperclass.getObjectTypeConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
- assertEquals("myObjectTypeConverter2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.objectTypeConvertersSize());
- ormContextObjectTypeConverters = ormContextConverterHolder.objectTypeConverters();
- ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
- assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
- assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeObjectTypeConverter(contextObjectTypeConverter2);
-
- assertEquals(0, ormContextConverterHolder.objectTypeConvertersSize());
- assertFalse(ormContextConverterHolder.objectTypeConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getObjectTypeConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testUpdateStructConverters() throws Exception {
- createTestMappedSuperclassForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the resource model, check context model
- XmlStructConverter resourceStructConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceMappedSuperclass.getStructConverters().add(resourceStructConverter);
- resourceStructConverter.setConverter("Foo");
- resourceStructConverter.setName("myStructConverter");
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the resource model, check context model
- XmlStructConverter resourceStructConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- resourceMappedSuperclass.getStructConverters().add(0, resourceStructConverter2);
- resourceStructConverter2.setConverter("Foo2");
- resourceStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the resource model, check context model
- resourceMappedSuperclass.getStructConverters().move(0, 1);
-
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getStructConverters().remove(0);
-
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the resource model, check context model
- resourceMappedSuperclass.getStructConverters().remove(resourceStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testModifyStructConverters() throws Exception {
- createTestMappedSuperclassForStructConverters();
- EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmEclipseLinkMappedSuperclass ormContextMappedSuperclass = (OrmEclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- OrmEclipseLinkConverterContainer ormContextConverterHolder = ormContextMappedSuperclass.getConverterContainer();
- XmlMappedSuperclass resourceMappedSuperclass = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add a converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter.setConverterClass("Foo");
- contextStructConverter.setName("myStructConverter");
-
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ListIterator<EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.structConverters();
- EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //add another converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter(0);
- contextStructConverter2.setConverterClass("Foo2");
- contextStructConverter2.setName("myStructConverter2");
-
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter", resourceMappedSuperclass.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //move a converter in the context model, check resource model
- ormContextConverterHolder.moveStructConverter(0, 1);
-
- assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(1).getConverter());
- assertEquals("myStructConverter2", resourceMappedSuperclass.getStructConverters().get(1).getName());
- assertEquals(2, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter", ormContextStructConverter.getName());
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(2, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(0);
-
- assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
- assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
- assertEquals("myStructConverter2", resourceMappedSuperclass.getStructConverters().get(0).getName());
- assertEquals(1, ormContextConverterHolder.structConvertersSize());
- ormContextStructConverters = ormContextConverterHolder.structConverters();
- ormContextStructConverter = ormContextStructConverters.next();
- assertEquals("Foo2", ormContextStructConverter.getConverterClass());
- assertEquals("myStructConverter2", ormContextStructConverter.getName());
- assertEquals(1, CollectionTools.size(persistenceUnit.allConverters()));
-
- //remove a converter from the context model, check resource model
- ormContextConverterHolder.removeStructConverter(contextStructConverter2);
-
- assertEquals(0, ormContextConverterHolder.structConvertersSize());
- assertFalse(ormContextConverterHolder.structConverters().hasNext());
- assertEquals(0, resourceMappedSuperclass.getStructConverters().size());
- assertEquals(0, CollectionTools.size(persistenceUnit.allConverters()));
- }
-
- public void testSetSpecifiedCacheable() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable2_0 = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
- XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
- assertEquals(null, cacheable2_0.getSpecifiedCacheable());
- assertEquals(null, mappedSuperclassResource.getCacheable());
-
- cacheable2_0.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cacheable2_0.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, mappedSuperclassResource.getCacheable());
-
- cacheable2_0.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, cacheable2_0.getSpecifiedCacheable());
- assertEquals(Boolean.TRUE, mappedSuperclassResource.getCacheable());
-
- cacheable2_0.setSpecifiedCacheable(null);
- assertEquals(null, cacheable2_0.getSpecifiedCacheable());
- assertEquals(null, mappedSuperclassResource.getCacheable());
- }
-
- public void testGetSpecifiedCacheable() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
- XmlMappedSuperclass mappedSuperclassResource = (XmlMappedSuperclass) getXmlEntityMappings().getMappedSuperclasses().get(0);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, mappedSuperclassResource.getCacheable());
-
- mappedSuperclassResource.setCacheable(Boolean.TRUE);
- assertEquals(Boolean.TRUE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.TRUE, mappedSuperclassResource.getCacheable());
-
- mappedSuperclassResource.setCacheable(Boolean.FALSE);
- assertEquals(Boolean.FALSE, cacheable.getSpecifiedCacheable());
- assertEquals(Boolean.FALSE, mappedSuperclassResource.getCacheable());
-
- mappedSuperclassResource.setCacheable(null);
- assertEquals(null, cacheable.getSpecifiedCacheable());
- assertEquals(null, mappedSuperclassResource.getCacheable());
- }
-
- public void testIsDefaultCacheable() throws Exception {
- createTestMappedSuperclass();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 cacheable = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- assertEquals(SharedCacheMode.DISABLE_SELECTIVE, persistenceUnit2_0.getSharedCacheMode());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ALL);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.UNSPECIFIED);
- assertEquals(true, cacheable.isDefaultCacheable());
- }
-
- public void testIsDefaultCacheableFromSuperType() throws Exception {
- createTestMappedSuperclass();
- createTestMappedSuperclassSubType();
- OrmPersistentType subOrmPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_SUB_TYPE_NAME);
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass subMappedSuperclass = (EclipseLinkMappedSuperclass) subOrmPersistentType.getMapping();
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) subMappedSuperclass).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) mappedSuperclass).getCacheable();
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(null);
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
- }
-
- public void testIsDefaultCacheableFromJava() throws Exception {
- createTestMappedSuperclass();
- createTestMappedSuperclassSubType();
- OrmPersistentType subOrmPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_SUB_TYPE_NAME);
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) subOrmPersistentType.getMapping()).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) ormPersistentType.getMapping()).getCacheable();
-
- Cacheable2_0 javaCacheable = ((CacheableHolder2_0) ormPersistentType.getJavaPersistentType().getMapping()).getCacheable();
- javaCacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- javaCacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- javaCacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- javaCacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
- }
-
- public void testIsDefaultCacheableFromMappedSuperClass() throws Exception {
- createTestMappedSuperclass();
- createTestMappedSuperclassSubType();
- OrmPersistentType subOrmPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_SUB_TYPE_NAME);
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- EclipseLinkMappedSuperclass subMappedSuperclass = (EclipseLinkMappedSuperclass) subOrmPersistentType.getMapping();
- EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) ormPersistentType.getMapping();
- Cacheable2_0 subCacheable = ((CacheableHolder2_0) subMappedSuperclass).getCacheable();
- Cacheable2_0 cacheable = ((CacheableHolder2_0) mappedSuperclass).getCacheable();
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- PersistenceUnit2_0 persistenceUnit2_0 = getPersistenceUnit();
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(null);
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.DISABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.FALSE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(true, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
- assertEquals(false, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- cacheable.setSpecifiedCacheable(Boolean.TRUE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
-
- persistenceUnit2_0.setSpecifiedSharedCacheMode(SharedCacheMode.NONE);
- assertEquals(true, subCacheable.isDefaultCacheable());
- assertEquals(false, cacheable.isDefaultCacheable());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java
deleted file mode 100644
index 5a08c3a858..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToManyMappingTests.java
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*******************************************************************************
-* 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-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.Cascade2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OneToManyRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.OrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_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.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkOneToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkOneToManyMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.EclipseLinkOneToManyRelationship2_0;
-
-/**
- * EclipseLink2_0OrmOneToManyMappingTests
- */
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmOneToManyMappingTests
- extends EclipseLink2_0OrmContextModelTestCase
-{
- public EclipseLink2_0OrmOneToManyMappingTests(String name) {
- super(name);
- }
- 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(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(" 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 createTestEntityWithValidOneToManyMapping() throws Exception {
- this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Collection<Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").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 createTestEntityWithValidMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityWithValidNonGenericMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- 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 name;").append(CR);
- sb.append(CR);
- sb.append(" private String abbr;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "State.java", sourceWriter);
- }
-
- private ICompilationUnit createTestEntityWithValidGenericMapOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.ID);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany").append(CR);
- sb.append(" private java.util.Map<String, Address> addresses;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- private ICompilationUnit createTestEntityOneToManyMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_MANY, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, JPA.ORDER_BY, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToMany(fetch=FetchType.EAGER, targetEntity=Address.class, orphanRemoval = true, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH, CascadeType.DETACH})");
- sb.append(CR);
- sb.append(" @OrderBy(\"city\"");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" private java.util.Collection<Address> address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- private OrmOrphanRemovable2_0 getOrphanRemovalOf(OneToManyMapping2_0 oneToManyMapping) {
- return ((OrmOrphanRemovalHolder2_0) oneToManyMapping).getOrphanRemoval();
- }
-
- public void testUpdateSpecifiedOrphanRemoval() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping2_0 oneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping();
- OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
- XmlOneToMany oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertEquals(null, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(null, oneToManyResource.getOrphanRemoval());
-
- //set enumerated in the resource model, verify context model updated
- oneToManyResource.setOrphanRemoval(Boolean.TRUE);
- assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(Boolean.TRUE, oneToManyResource.getOrphanRemoval());
-
- oneToManyResource.setOrphanRemoval(Boolean.FALSE);
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(Boolean.FALSE, oneToManyResource.getOrphanRemoval());
- }
-
- public void testModifySpecifiedOrphanRemoval() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping2_0 oneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping();
- OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(oneToManyMapping);
- XmlOneToMany oneToManyResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertEquals(null, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(null, oneToManyResource.getOrphanRemoval());
-
- //set enumerated in the context model, verify resource model updated
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE);
- assertEquals(Boolean.TRUE, oneToManyResource.getOrphanRemoval());
- assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.FALSE);
- assertEquals(Boolean.FALSE, oneToManyResource.getOrphanRemoval());
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- }
- public void testUpdateVirtualMapKey() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME_ + "Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME_ + "State");
-
- OneToManyMapping virtualOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertNull(virtualOneToManyMapping.getSpecifiedMapKey());
- assertNull(virtualOneToManyMapping.getMapKey());
- assertFalse(virtualOneToManyMapping.isPkMapKey());
- assertFalse(virtualOneToManyMapping.isCustomMapKey());
- assertTrue(virtualOneToManyMapping.isNoMapKey());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaOneToManyMapping.setPkMapKey(true);
- assertEquals("id", virtualOneToManyMapping.getMapKey());
- assertTrue(virtualOneToManyMapping.isPkMapKey());
- assertFalse(virtualOneToManyMapping.isCustomMapKey());
- assertFalse(virtualOneToManyMapping.isNoMapKey());
-
-
- //set custom specified mapKey in the java, verify virtual orm mapping updates
- javaOneToManyMapping.setCustomMapKey(true);
- javaOneToManyMapping.setSpecifiedMapKey("city");
- assertEquals("city", virtualOneToManyMapping.getSpecifiedMapKey());
- assertEquals("city", virtualOneToManyMapping.getMapKey());
- assertFalse(virtualOneToManyMapping.isPkMapKey());
- assertTrue(virtualOneToManyMapping.isCustomMapKey());
- assertFalse(virtualOneToManyMapping.isNoMapKey());
-
- //set metadata complete and verify that the orm model ignores the java annotations
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- virtualOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- assertEquals(null, virtualOneToManyMapping.getSpecifiedMapKey());
- assertEquals(null, virtualOneToManyMapping.getMapKey());
- assertFalse(virtualOneToManyMapping.isPkMapKey());
- assertFalse(virtualOneToManyMapping.isCustomMapKey());
- assertTrue(virtualOneToManyMapping.isNoMapKey());
- }
-
- public void testCandidateMapKeyNames() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- OneToManyMapping virtualOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames =
- virtualOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
- }
-
- public void testCandidateMapKeyNames2() throws Exception {
- createTestEntityWithValidNonGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- OneToManyMapping virtualOneToManyMapping = (OneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
-
- Iterator<String> mapKeyNames = virtualOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- javaOneToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = virtualOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- ormPersistentType.getAttributeNamed("addresses").convertToSpecified();
- OrmOneToManyMapping ormOneToManyMapping = (OrmOneToManyMapping) ormPersistentType.getAttributeNamed("addresses").getMapping();
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
-
- ormOneToManyMapping.setSpecifiedTargetEntity("test.Address");
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals("id", mapKeyNames.next());
- assertEquals("city", mapKeyNames.next());
- assertEquals("state", mapKeyNames.next());
- assertEquals("state.name", mapKeyNames.next());
- assertEquals("state.abbr", mapKeyNames.next());
- assertEquals("zip", mapKeyNames.next());
- assertFalse(mapKeyNames.hasNext());
-
- ormOneToManyMapping.setSpecifiedTargetEntity("String");
- mapKeyNames = ormOneToManyMapping.candidateMapKeyNames();
- assertEquals(false, mapKeyNames.hasNext());
- }
-
- public void testUpdateMapKeyClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(oneToMany.getMapKeyClass());
-
- //set mapKey in the resource model, verify context model does not change
- oneToMany.setMapKeyClass(OrmFactory.eINSTANCE.createXmlClassReference());
- assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertNotNull(oneToMany.getMapKeyClass());
-
- //set mapKey name in the resource model, verify context model updated
- oneToMany.getMapKeyClass().setClassName("String");
- assertEquals("String", ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("String", oneToMany.getMapKeyClass().getClassName());
-
- //set mapKey name to null in the resource model
- oneToMany.getMapKeyClass().setClassName(null);
- assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(oneToMany.getMapKeyClass().getClassName());
-
- oneToMany.getMapKeyClass().setClassName("String");
- oneToMany.setMapKeyClass(null);
- assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(oneToMany.getMapKeyClass());
- }
-
- public void testUpdateVirtualMapKeyClass() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
-
- OneToManyMapping2_0 virtualOneToManyMapping = (OneToManyMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- assertNull(virtualOneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualOneToManyMapping.getMapKeyClass());
- assertEquals("java.lang.String", virtualOneToManyMapping.getDefaultMapKeyClass());
-
- //set pk mapKey in the java, verify virtual orm mapping updates
- javaOneToManyMapping.setSpecifiedMapKeyClass("Integer");
- assertEquals("Integer", virtualOneToManyMapping.getMapKeyClass());
- assertEquals("Integer", virtualOneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualOneToManyMapping.getDefaultMapKeyClass());
-
-
- //set custom specified mapKey in the java, verify virtual orm mapping updates
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- virtualOneToManyMapping = (OneToManyMapping2_0) ormPersistentType.getAttributeNamed("addresses").getMapping();
- assertEquals(null, virtualOneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("java.lang.String", virtualOneToManyMapping.getMapKeyClass());
- assertEquals("java.lang.String", virtualOneToManyMapping.getDefaultMapKeyClass());
- }
-
- public void testModifyMapKeyClass() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "oneToManyMapping");
- OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) ormPersistentAttribute.getMapping();
- XmlOneToMany oneToMany = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToManys().get(0);
-
- assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(oneToMany.getMapKeyClass());
-
- //set mapKey in the context model, verify resource model updated
- ormOneToManyMapping.setSpecifiedMapKeyClass("String");
- assertEquals("String", ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertEquals("String", oneToMany.getMapKeyClass().getClassName());
-
- //set mapKey to null in the context model
- ormOneToManyMapping.setSpecifiedMapKeyClass(null);
- assertNull(ormOneToManyMapping.getSpecifiedMapKeyClass());
- assertNull(oneToMany.getMapKeyClass());
- }
-
- public void testOrderColumnDefaults() throws Exception {
- createTestEntityPrintQueue();
- createTestEntityPrintJob();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs");
- OrmOneToManyMapping oneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
- oneToManyMapping.getRelationship().setStrategyToMappedBy();
- oneToManyMapping.getRelationship().getMappedByStrategy().setMappedByAttribute("queue");
-
- Orderable2_0 orderable = ((Orderable2_0) oneToManyMapping.getOrderable());
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- orderable.setOrderColumnOrdering(true);
- OrderColumn2_0 orderColumn = orderable.getOrderColumn();
- assertEquals(true, orderable.isOrderColumnOrdering());
- assertEquals(null, orderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", orderColumn.getDefaultName());
- assertEquals("PrintJob", orderColumn.getTable());
-
- orderColumn.setSpecifiedName("FOO");
- assertEquals("FOO", orderColumn.getSpecifiedName());
- assertEquals("jobs_ORDER", orderColumn.getDefaultName());
- assertEquals("PrintJob", orderColumn.getTable());
-
- OrmPersistentType printJobPersistentType = (OrmPersistentType) getPersistenceUnit().getPersistentType("test.PrintJob");
- ((Entity) printJobPersistentType.getMapping()).getTable().setSpecifiedName("MY_TABLE");
-
- assertEquals("MY_TABLE", orderColumn.getTable());
- }
-
- public void testVirtualOrderColumn() throws Exception {
- createTestEntityPrintQueue();
- createTestEntityPrintJob();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintQueue");
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".PrintJob");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "jobs");
- OrmOneToManyMapping oneToManyMapping = (OrmOneToManyMapping) ormPersistentAttribute.getMapping();
-
- Orderable2_0 orderable = ((Orderable2_0) oneToManyMapping.getOrderable());
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- JavaOneToManyMapping javaOneToManyMapping = (JavaOneToManyMapping) ormPersistentAttribute.getJavaPersistentAttribute().getMapping();
- ((Orderable2_0) javaOneToManyMapping.getOrderable()).setOrderColumnOrdering(true);
-
- assertEquals(false, orderable.isOrderColumnOrdering());
- assertEquals(true, orderable.isNoOrdering());
-
- ormPersistentAttribute.convertToVirtual();
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("jobs");
- OneToManyMapping virtualOneToManyMapping = (OneToManyMapping) ormPersistentAttribute2.getMapping();
- orderable = ((Orderable2_0) virtualOneToManyMapping.getOrderable());
- assertEquals(true, orderable.isOrderColumnOrdering());
- assertEquals(false, orderable.isNoOrdering());
- assertEquals("PrintJob", orderable.getOrderColumn().getTable());
- assertEquals("jobs_ORDER", orderable.getOrderColumn().getName());
-
- ((Orderable2_0) javaOneToManyMapping.getOrderable()).getOrderColumn().setSpecifiedName("FOO");
- assertEquals("PrintJob", orderable.getOrderColumn().getTable());
- assertEquals("FOO", orderable.getOrderColumn().getName());
- }
-
-
- private void createTestEntityPrintQueue() 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.ONE_TO_MANY);
- sb.append(";");
- sb.append(CR);
- sb.append("import ");
- sb.append(JPA2_0.ORDER_COLUMN);
- sb.append(";");
- sb.append(CR);
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintQueue").append(" ");
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" @OneToMany(mappedBy=\"queue\")").append(CR);
- sb.append(" @OrderColumn").append(CR);
- sb.append(" private java.util.List<PrintJob> jobs;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintQueue.java", sourceWriter);
- }
-
- private void createTestEntityPrintJob() 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.MANY_TO_ONE);
- sb.append(";");
- sb.append(CR);
- sb.append("@Entity");
- sb.append(CR);
- sb.append("public class ").append("PrintJob").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(" @ManyToOne").append(CR);
- sb.append(" private PrintQueue queue;").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- }
- };
- this.javaProject.createCompilationUnit(PACKAGE_NAME, "PrintJob.java", sourceWriter);
- }
-
- public void testVirtualMapKeyColumnDefaults() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //virtual attribute in orm.xml, java attribute has no value Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- OneToManyMapping2_0 addressesVirtualMapping = (OneToManyMapping2_0) addressesPersistentAttribute.getMapping();
- Column ormColumn = addressesVirtualMapping.getMapKeyColumn();
- assertEquals("addresses_KEY", ormColumn.getName());
- assertEquals(TYPE_NAME + "_Address", ormColumn.getTable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertTrue(ormColumn.isInsertable());
- assertTrue(ormColumn.isUpdatable());
- assertTrue(ormColumn.isNullable());
- assertFalse(ormColumn.isUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getScale());
-
- //set Column annotation in Java
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedName("FOO");
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedTable("FOO_TABLE");
- javaOneToManyMapping.getMapKeyColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedNullable(Boolean.FALSE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedUnique(Boolean.TRUE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedLength(Integer.valueOf(45));
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedScale(Integer.valueOf(47));
-
- assertEquals("FOO", ormColumn.getSpecifiedName());
- assertEquals("FOO_TABLE", ormColumn.getSpecifiedTable());
- assertEquals("COLUMN_DEFINITION", ormColumn.getColumnDefinition());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedUpdatable());
- assertEquals(Boolean.FALSE, ormColumn.getSpecifiedNullable());
- assertEquals(Boolean.TRUE, ormColumn.getSpecifiedUnique());
- assertEquals(Integer.valueOf(45), ormColumn.getSpecifiedLength());
- assertEquals(Integer.valueOf(46), ormColumn.getSpecifiedPrecision());
- assertEquals(Integer.valueOf(47), ormColumn.getSpecifiedScale());
-
-
- //set metadata-complete, orm.xml virtual column ignores java column annotation
- ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- OneToManyMapping2_0 addressesMapping = (OneToManyMapping2_0) addressesPersistentAttribute.getMapping();
- ormColumn = addressesMapping.getMapKeyColumn();
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, addressesPersistentAttribute.getMappingKey());
-
- assertEquals("addresses_KEY", ormColumn.getName());
- assertEquals(TYPE_NAME + "_Address", ormColumn.getTable());
- assertEquals(null, ormColumn.getColumnDefinition());
- assertTrue(ormColumn.isInsertable());
- assertTrue(ormColumn.isUpdatable());
- assertTrue(ormColumn.isNullable());
- assertFalse(ormColumn.isUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getScale());
- }
-
- public void testNullMapKeyColumnDefaults() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- OrmPersistentAttribute addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
-
- OrmOneToManyMapping2_0 addressesVirtualMapping = (OrmOneToManyMapping2_0) addressesPersistentAttribute.getMapping();
- Column ormColumn = addressesVirtualMapping.getMapKeyColumn();
-
- //set Column annotation in Java
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedName("FOO");
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedTable("FOO_TABLE");
- javaOneToManyMapping.getMapKeyColumn().setColumnDefinition("COLUMN_DEFINITION");
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedInsertable(Boolean.FALSE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedUpdatable(Boolean.FALSE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedNullable(Boolean.FALSE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedUnique(Boolean.TRUE);
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedLength(Integer.valueOf(45));
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedPrecision(Integer.valueOf(46));
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedScale(Integer.valueOf(47));
-
-
- assertEquals("addresses_KEY", ormColumn.getDefaultName());
- assertEquals(TYPE_NAME + "_Address", ormColumn.getDefaultTable());
- assertEquals(true, ormColumn.isDefaultInsertable());
- assertEquals(true, ormColumn.isDefaultUpdatable());
- assertEquals(true, ormColumn.isDefaultNullable());
- assertEquals(false, ormColumn.isDefaultUnique());
- assertEquals(ReadOnlyColumn.DEFAULT_LENGTH, ormColumn.getDefaultLength());
- assertEquals(ReadOnlyColumn.DEFAULT_PRECISION, ormColumn.getDefaultPrecision());
- assertEquals(ReadOnlyColumn.DEFAULT_SCALE, ormColumn.getDefaultScale());
- assertNull(ormColumn.getSpecifiedName());
- assertNull(ormColumn.getSpecifiedTable());
- assertNull(ormColumn.getColumnDefinition());
- assertNull(ormColumn.getSpecifiedInsertable());
- assertNull(ormColumn.getSpecifiedUpdatable());
- assertNull(ormColumn.getSpecifiedNullable());
- assertNull(ormColumn.getSpecifiedUnique());
- assertNull(ormColumn.getSpecifiedLength());
- assertNull(ormColumn.getSpecifiedPrecision());
- assertNull(ormColumn.getSpecifiedScale());
- }
-
- public void testVirtualMapKeyColumnTable() throws Exception {
- createTestEntityWithValidMapOneToManyMapping();
- createTestTargetEntityAddress();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //virtual attribute in orm.xml, java attribute has no Column annotation
- OrmReadOnlyPersistentAttribute addressesPersistentAttribute = ormPersistentType.virtualAttributes().next();
- OneToManyMapping2_0 addressesVirtualMapping = (OneToManyMapping2_0) addressesPersistentAttribute.getMapping();
- Column ormColumn = addressesVirtualMapping.getMapKeyColumn();
-
- assertEquals(TYPE_NAME + "_Address", ormColumn.getTable());
-
- //entity table changes the join table default name
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE");
- assertEquals("ORM_TABLE_Address", ormColumn.getTable());
-
- //set Column table element in Java
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("addresses").getMapping();
- javaOneToManyMapping.getRelationship().getJoinTableStrategy().getJoinTable().setSpecifiedName("JAVA_JOIN_TABLE");
- assertEquals("JAVA_JOIN_TABLE", ormColumn.getTable());
- javaOneToManyMapping.getMapKeyColumn().setSpecifiedTable("JAVA_TABLE");
- assertEquals("JAVA_TABLE", ormColumn.getTable());
-
- //make name persistent attribute not virtual
- addressesPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, "addresses");
- OrmOneToManyMapping2_0 addressesMapping = (OrmOneToManyMapping2_0) addressesPersistentAttribute.getMapping();
- ormColumn = addressesMapping.getMapKeyColumn();
- assertNull(ormColumn.getSpecifiedTable());
- assertEquals("ORM_TABLE_Address", ormColumn.getDefaultTable());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntityWithValidOneToManyMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("addresses");
- OrmEclipseLinkOneToManyMapping contextMapping = (OrmEclipseLinkOneToManyMapping) contextAttribute.getMapping();
- EclipseLinkOneToManyRelationship2_0 rel = contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlOneToMany resourceMapping = resourceEntity.getAttributes().getOneToManys().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinColumn();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- rel.setStrategyToMappedBy();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- rel.setStrategyToJoinTable();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntityWithValidOneToManyMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("addresses");
- OrmEclipseLinkOneToManyMapping contextMapping = (OrmEclipseLinkOneToManyMapping) contextAttribute.getMapping();
- EclipseLinkOneToManyRelationship2_0 rel = contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlOneToMany resourceMapping = resourceEntity.getAttributes().getOneToManys().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceMapping.setMappedBy("foo");
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceMapping.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTable());
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceMapping.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertNotNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertTrue(rel.strategyIsMappedBy());
-
- resourceMapping.setMappedBy(null);
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceMapping.setJoinTable(null);
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
-
- resourceMapping.getJoinColumns().clear();
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertNull(resourceMapping.getMappedBy());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- assertFalse(rel.strategyIsMappedBy());
- }
-
- public void testTargetForeignKeyJoinColumnStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType ormTargetPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //test virtual orm mapping, setting the join column on the java mapping
- OrmReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- OneToManyMapping2_0 virtualOneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) persistentAttribute.getJavaPersistentAttribute().getMapping();
- ((OneToManyRelationship2_0) javaOneToManyMapping.getRelationship()).setStrategyToJoinColumn();
-
- JoinColumn joinColumn = ((OneToManyRelationship2_0) virtualOneToManyMapping.getRelationship()).getJoinColumnStrategy().specifiedJoinColumns().next();
- assertTrue(persistentAttribute.isVirtual());
- assertEquals("addresses_id", joinColumn.getDefaultName());
- assertEquals("Address", joinColumn.getDefaultTable());//target table name
-
- JavaEntity addressEntity = (JavaEntity) ormTargetPersistentType.getJavaPersistentType().getMapping();
- addressEntity.getTable().setSpecifiedName("ADDRESS_PRIMARY_TABLE");
- assertEquals("ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable());
-
- //override the mapping in orm.xml
- persistentAttribute.convertToSpecified();
- persistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) persistentAttribute.getMapping();
- assertFalse(persistentAttribute.isVirtual());
- assertFalse(((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).strategyIsJoinColumn());
-
- ((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).setStrategyToJoinColumn();
- joinColumn = ((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).getJoinColumnStrategy().specifiedJoinColumns().next();
- assertFalse(persistentAttribute.isVirtual());
- assertEquals("addresses_id", joinColumn.getDefaultName());
- assertEquals("ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable());//target table name
-
- OrmEntity ormAddressEntity = (OrmEntity) ormTargetPersistentType.getMapping();
- ormAddressEntity.getTable().setSpecifiedName("ORM_ADDRESS_PRIMARY_TABLE");
- assertEquals("ORM_ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable());
-
- joinColumn.setSpecifiedName("FOO");
- assertEquals("addresses_id", joinColumn.getDefaultName());
- assertEquals("FOO", joinColumn.getSpecifiedName());
- assertEquals("ORM_ADDRESS_PRIMARY_TABLE", joinColumn.getDefaultTable());
- }
-
- //target foreign key case
- public void testGetMapKeyColumnJoinColumnStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType ormTargetPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //test virtual orm mapping, setting the join column on the java mapping
- OrmReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- OneToManyMapping2_0 virtualOneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) persistentAttribute.getJavaPersistentAttribute().getMapping();
- ((OneToManyRelationship2_0) javaOneToManyMapping.getRelationship()).setStrategyToJoinColumn();
-
- assertTrue(persistentAttribute.isVirtual());
- assertEquals("addresses_KEY", virtualOneToManyMapping.getMapKeyColumn().getName());
- assertEquals("Address", virtualOneToManyMapping.getMapKeyColumn().getTable());//target table name
-
- JavaEntity addressEntity = (JavaEntity) ormTargetPersistentType.getJavaPersistentType().getMapping();
- addressEntity.getTable().setSpecifiedName("ADDRESS_PRIMARY_TABLE");
- assertEquals("ADDRESS_PRIMARY_TABLE", virtualOneToManyMapping.getMapKeyColumn().getTable());
-
- JavaResourcePersistentType typeResource = getJpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
- JavaResourcePersistentAttribute attributeResource = typeResource.persistableAttributes().next();
- MapKeyColumn2_0Annotation column = (MapKeyColumn2_0Annotation) attributeResource.addAnnotation(JPA2_0.MAP_KEY_COLUMN);
- column.setName("foo");
- getJpaProject().synchronizeContextModel();
-
- assertEquals("foo", virtualOneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("foo", virtualOneToManyMapping.getMapKeyColumn().getName());
- assertEquals("addresses_KEY", virtualOneToManyMapping.getMapKeyColumn().getDefaultName());
- assertEquals("ADDRESS_PRIMARY_TABLE", virtualOneToManyMapping.getMapKeyColumn().getDefaultTable());
-
- //override the mapping in orm.xml
- persistentAttribute.convertToSpecified();
- persistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) persistentAttribute.getMapping();
- assertFalse(persistentAttribute.isVirtual());
- assertFalse(((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).strategyIsJoinColumn());
-
- ((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).setStrategyToJoinColumn();
- assertEquals("addresses_KEY", ormOneToManyMapping.getMapKeyColumn().getName());
- assertEquals("ADDRESS_PRIMARY_TABLE", ormOneToManyMapping.getMapKeyColumn().getTable());//target table name
-
- OrmEntity ormAddressEntity = (OrmEntity) ormTargetPersistentType.getMapping();
- ormAddressEntity.getTable().setSpecifiedName("ORM_ADDRESS_PRIMARY_TABLE");
- assertEquals("addresses_KEY", ormOneToManyMapping.getMapKeyColumn().getName());
- assertEquals("ORM_ADDRESS_PRIMARY_TABLE", ormOneToManyMapping.getMapKeyColumn().getTable());//target table name
-
- ormOneToManyMapping.getMapKeyColumn().setSpecifiedName("FOO");
- assertEquals("addresses_KEY", ormOneToManyMapping.getMapKeyColumn().getDefaultName());
- assertEquals("FOO", ormOneToManyMapping.getMapKeyColumn().getSpecifiedName());
- assertEquals("ORM_ADDRESS_PRIMARY_TABLE", ormOneToManyMapping.getMapKeyColumn().getDefaultTable());
- }
-
- //target foreign key case
- public void testOrderColumnDefaultsJoinColumnStrategy() throws Exception {
- createTestEntityWithValidGenericMapOneToManyMapping();
- createTestTargetEntityAddress();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentType ormTargetPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- //test virtual orm mapping, setting the join column on the java mapping
- OrmReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- OneToManyMapping2_0 virtualOneToManyMapping = (OneToManyMapping2_0) persistentAttribute.getMapping();
- JavaOneToManyMapping2_0 javaOneToManyMapping = (JavaOneToManyMapping2_0) persistentAttribute.getJavaPersistentAttribute().getMapping();
- ((OneToManyRelationship2_0) javaOneToManyMapping.getRelationship()).setStrategyToJoinColumn();
- ((Orderable2_0) javaOneToManyMapping.getOrderable()).setOrderColumnOrdering(true);
- OrderColumn2_0 orderColumn = ((Orderable2_0) virtualOneToManyMapping.getOrderable()).getOrderColumn();
-
- assertEquals("addresses_ORDER", orderColumn.getName());
- assertEquals("Address", orderColumn.getTable());//target table name
-
- JavaEntity addressEntity = (JavaEntity) ormTargetPersistentType.getJavaPersistentType().getMapping();
- addressEntity.getTable().setSpecifiedName("ADDRESS_PRIMARY_TABLE");
- assertEquals("ADDRESS_PRIMARY_TABLE", orderColumn.getTable());
-
- //override the mapping in orm.xml
- persistentAttribute.convertToSpecified();
- persistentAttribute = ormPersistentType.getAttributeNamed("addresses");
- OrmOneToManyMapping2_0 ormOneToManyMapping = (OrmOneToManyMapping2_0) persistentAttribute.getMapping();
- assertFalse(persistentAttribute.isVirtual());
- assertFalse(((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).strategyIsJoinColumn());
-
- ((OneToManyRelationship2_0) ormOneToManyMapping.getRelationship()).setStrategyToJoinColumn();
- assertFalse(((Orderable2_0) ormOneToManyMapping.getOrderable()).isOrderColumnOrdering());
- ((Orderable2_0) ormOneToManyMapping.getOrderable()).setOrderColumnOrdering(true);
- orderColumn = ((Orderable2_0) ormOneToManyMapping.getOrderable()).getOrderColumn();
-
- assertNull(orderColumn.getSpecifiedName());
- assertEquals("addresses_ORDER", orderColumn.getName());
- assertEquals("ADDRESS_PRIMARY_TABLE", orderColumn.getTable());//target table name
-
- OrmEntity ormAddressEntity = (OrmEntity) ormTargetPersistentType.getMapping();
- ormAddressEntity.getTable().setSpecifiedName("ORM_ADDRESS_PRIMARY_TABLE");
- assertEquals("addresses_ORDER", orderColumn.getName());
- assertEquals("ORM_ADDRESS_PRIMARY_TABLE", orderColumn.getTable());//target table name
- }
-
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityOneToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- EclipseLinkOneToManyMapping virtualOneToManyMapping = (EclipseLinkOneToManyMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualOneToManyMapping.getName());
- assertEquals(FetchType.EAGER, virtualOneToManyMapping.getSpecifiedFetch());
- assertEquals("Address", virtualOneToManyMapping.getSpecifiedTargetEntity());
- assertNull(virtualOneToManyMapping.getRelationship().
- getMappedByStrategy().getMappedByAttribute());
-
- Cascade2_0 cascade = (Cascade2_0) virtualOneToManyMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
- assertTrue(cascade.isDetach());
-
- assertTrue(virtualOneToManyMapping.getOrderable().isCustomOrdering());
- assertEquals("city", virtualOneToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertTrue(((OrphanRemovalHolder2_0) virtualOneToManyMapping).getOrphanRemoval().isOrphanRemoval());
- assertEquals(EclipseLinkJoinFetchType.INNER, virtualOneToManyMapping.getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityOneToManyMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
-
- EclipseLinkOneToManyMapping virtualOneToManyMapping = (EclipseLinkOneToManyMapping) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualOneToManyMapping.getName());
- assertEquals(FetchType.LAZY, virtualOneToManyMapping.getFetch());
- assertEquals("test.Address", virtualOneToManyMapping.getTargetEntity());
- assertNull(virtualOneToManyMapping.getRelationship().getMappedByStrategy().getMappedByAttribute());
-
- Cascade2_0 cascade = (Cascade2_0) virtualOneToManyMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- assertFalse(cascade.isDetach());
-
- assertTrue(virtualOneToManyMapping.getOrderable().isNoOrdering());
- assertEquals(null, virtualOneToManyMapping.getOrderable().getSpecifiedOrderBy());
-
- assertFalse(((OrphanRemovalHolder2_0) virtualOneToManyMapping).getOrphanRemoval().isOrphanRemoval());
- assertEquals(null, virtualOneToManyMapping.getJoinFetch().getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToOneMappingTests.java
deleted file mode 100644
index a21b53daef..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/EclipseLink2_0OrmOneToOneMappingTests.java
+++ /dev/null
@@ -1,910 +0,0 @@
-/*******************************************************************************
-* 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-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.Cascade2_0;
-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.OrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlDerivedId_2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlMapsId_2_0;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.EclipseLinkOneToOneMapping2_0;
-
-@SuppressWarnings("nls")
-public class EclipseLink2_0OrmOneToOneMappingTests
- extends EclipseLink2_0OrmContextModelTestCase
-{
- public EclipseLink2_0OrmOneToOneMappingTests(String name) {
- super(name);
- }
-
-
- private void createTestEntityWithIdDerivedIdentity() throws Exception {
- 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);
- }
- });
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- for (OrmReadOnlyPersistentAttribute each : CollectionTools.iterable(ormPersistentType.attributes())) {
- each.convertToSpecified();
- }
- }
-
- 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 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(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(" 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 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 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);
- }
-
- private void createTestEntityWithOneToOneMapping() 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").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@OneToOne").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 createTestEntityOneToOneMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.ONE_TO_ONE, JPA.JOIN_COLUMN, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE, EclipseLink.PRIVATE_OWNED);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @OneToOne(fetch=FetchType.LAZY, optional=false, targetEntity=Address.class, orphanRemoval = true, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH, CascadeType.DETACH})");
- sb.append(CR);
- sb.append(" @JoinColumn(name=\"MY_COLUMN\", referencedColumnName=\"MY_REFERENCED_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\")");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" @PrivateOwned)");
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- public void testUpdateDerivedId() throws Exception {
- createTestEntityWithIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
- OrmOneToOneMapping2_0 contextMapping = (OrmOneToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlDerivedId_2_0 resourceMapping = resourceEntity.getAttributes().getOneToOnes().get(0);
-
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- resourceMapping.setId(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- resourceMapping.setId(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMapping.getId());
- assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- resourceMapping.setId(null);
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- }
-
- public void testSetDerivedId() throws Exception {
- createTestEntityWithIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
- OrmOneToOneMapping2_0 contextMapping = (OrmOneToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlDerivedId_2_0 resourceMapping = resourceEntity.getAttributes().getOneToOnes().get(0);
-
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(true);
- assertEquals(Boolean.TRUE, resourceMapping.getId());
- assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(false);
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- }
-
- public void testUpdateMapsId() throws Exception {
- createTestEntityWithMapsIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
- OrmOneToOneMapping2_0 contextMapping = (OrmOneToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlMapsId_2_0 resourceMapping = resourceEntity.getAttributes().getOneToOnes().get(0);
-
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- resourceMapping.setMapsId("foo");
- assertEquals("foo", resourceMapping.getMapsId());
- assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- resourceMapping.setMapsId("bar");
- assertEquals("bar", resourceMapping.getMapsId());
- assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- resourceMapping.setMapsId(null);
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
- }
-
- public void testSetMapsId() throws Exception {
- createTestEntityWithMapsIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("oneToOne");
- OrmOneToOneMapping2_0 contextMapping = (OrmOneToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlMapsId_2_0 resourceMapping = resourceEntity.getAttributes().getOneToOnes().get(0);
-
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue("foo");
- assertEquals("foo", resourceMapping.getMapsId());
- assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue("bar");
- assertEquals("bar", resourceMapping.getMapsId());
- assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue(null);
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
- }
-
- public void testMorphMapping() throws Exception {
- createTestEntityWithMapsIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute contextAttribute = (OrmPersistentAttribute) contextType.getAttributeNamed("oneToOne");
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
-
- XmlOneToOne resourceOneToOne = resourceEntity.getAttributes().getOneToOnes().get(0);
- resourceOneToOne.setMapsId("foo");
- assertNull(resourceOneToOne.getId());
- assertFalse(((OrmOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertEquals("foo", resourceOneToOne.getMapsId());
- assertEquals("foo", ((OrmOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- XmlManyToOne resourceManyToOne = resourceEntity.getAttributes().getManyToOnes().get(0);
- assertNull(resourceManyToOne.getId());
- assertFalse(((OrmManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertEquals("foo", resourceManyToOne.getMapsId());
- assertEquals("foo", ((OrmManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- resourceOneToOne = resourceEntity.getAttributes().getOneToOnes().get(0);
- assertNull(resourceOneToOne.getId());
- assertFalse(((OrmOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertEquals("foo", resourceOneToOne.getMapsId());
- assertEquals("foo", ((OrmOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
- }
-
- public void testCandidateMappedByAttributeNames() throws Exception {
- createTestEntityWithValidOneToOneMapping();
- createTestTargetEntityAddress();
- createTestEmbeddableState();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.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();
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, PACKAGE_NAME + ".State");
- ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
-
- addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
- addXmlClassRef(PACKAGE_NAME + ".Address");
- addXmlClassRef(PACKAGE_NAME + ".State");
-
- ReadOnlyPersistentAttribute persistentAttribute = ormPersistentType.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 OrmOrphanRemovable2_0 getOrphanRemovalOf(OneToOneMapping2_0 oneToOneMapping) {
- return ((OrmOrphanRemovalHolder2_0) oneToOneMapping).getOrphanRemoval();
- }
-
- public void testUpdateSpecifiedOrphanRemoval() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping2_0 ormOneToOneMapping = (OrmOneToOneMapping2_0) ormPersistentAttribute.getMapping();
- OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(ormOneToOneMapping);
- XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertEquals(null, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(null, oneToOneResource.getOrphanRemoval());
-
- //set enumerated in the resource model, verify context model updated
- oneToOneResource.setOrphanRemoval(Boolean.TRUE);
- assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(Boolean.TRUE, oneToOneResource.getOrphanRemoval());
-
- oneToOneResource.setOrphanRemoval(Boolean.FALSE);
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(Boolean.FALSE, oneToOneResource.getOrphanRemoval());
- }
-
- public void testModifySpecifiedOrphanRemoval() throws Exception {
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "oneToOneMapping");
- OrmOneToOneMapping2_0 ormOneToOneMapping = (OrmOneToOneMapping2_0) ormPersistentAttribute.getMapping();
- OrmOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(ormOneToOneMapping);
- XmlOneToOne oneToOneResource = getXmlEntityMappings().getEntities().get(0).getAttributes().getOneToOnes().get(0);
-
- assertEquals(null, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- assertEquals(null, oneToOneResource.getOrphanRemoval());
-
- //set enumerated in the context model, verify resource model updated
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.TRUE);
- assertEquals(Boolean.TRUE, oneToOneResource.getOrphanRemoval());
- assertEquals(Boolean.TRUE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
-
- mappingsOrphanRemoval.setSpecifiedOrphanRemoval(Boolean.FALSE);
- assertEquals(Boolean.FALSE, oneToOneResource.getOrphanRemoval());
- assertEquals(Boolean.FALSE, mappingsOrphanRemoval.getSpecifiedOrphanRemoval());
- }
-
- public void testVirtualJoinTable() throws Exception {
- createTestEntityWithValidOneToOneMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address");
- JavaOneToOneMapping2_0 javaOneToOneMapping = ((JavaOneToOneMapping2_0) ormPersistentAttribute.getJavaPersistentAttribute().getMapping());
- OneToOneMapping2_0 virtualOneToOneMapping = (OneToOneMapping2_0) ormPersistentAttribute.getMapping();
- ((OneToOneRelationship2_0) javaOneToOneMapping.getRelationship()).setStrategyToJoinTable();
- JoinTable virtualJoinTable = ((OneToOneRelationship2_0) virtualOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
-
- assertTrue(ormPersistentAttribute.isVirtual());
- assertEquals(null, virtualJoinTable.getSpecifiedName());
-
- createTestTargetEntityAddress();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- assertEquals(TYPE_NAME + "_Address", virtualJoinTable.getName());
- assertNull(virtualJoinTable.getSpecifiedCatalog());
- assertNull(virtualJoinTable.getSpecifiedSchema());
- assertEquals(0, virtualJoinTable.specifiedJoinColumnsSize());
- assertEquals(0, virtualJoinTable.specifiedInverseJoinColumnsSize());
- JoinColumn virtualJoinColumn = virtualJoinTable.getDefaultJoinColumn();
- assertEquals(TYPE_NAME + "_Address", virtualJoinColumn.getDefaultTable());
- assertEquals(TYPE_NAME + "_id", virtualJoinColumn.getDefaultName());
- assertEquals("id", virtualJoinColumn.getDefaultReferencedColumnName());
- JoinColumn virtualInverseOrmJoinColumn = virtualJoinTable.getDefaultInverseJoinColumn();
- assertEquals(TYPE_NAME + "_Address", virtualInverseOrmJoinColumn.getDefaultTable());
- assertEquals("address_id", virtualInverseOrmJoinColumn.getDefaultName());
- assertEquals("id", virtualInverseOrmJoinColumn.getDefaultReferencedColumnName());
-
- JavaJoinTable javaJoinTable = ((JavaOneToOneRelationship2_0) javaOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- javaJoinTable.setSpecifiedName("FOO");
- javaJoinTable.setSpecifiedCatalog("CATALOG");
- javaJoinTable.setSpecifiedSchema("SCHEMA");
- JavaJoinColumn javaJoinColumn = javaJoinTable.addSpecifiedJoinColumn(0);
- javaJoinColumn.setSpecifiedName("NAME");
- javaJoinColumn.setSpecifiedReferencedColumnName("REFERENCED_NAME");
- JavaJoinColumn inverseJavaJoinColumn = javaJoinTable.addSpecifiedInverseJoinColumn(0);
- inverseJavaJoinColumn.setSpecifiedName("INVERSE_NAME");
- inverseJavaJoinColumn.setSpecifiedReferencedColumnName("INVERSE_REFERENCED_NAME");
-
- assertEquals("FOO", virtualJoinTable.getSpecifiedName());
- assertEquals("CATALOG", virtualJoinTable.getSpecifiedCatalog());
- assertEquals("SCHEMA", virtualJoinTable.getSpecifiedSchema());
- assertEquals(1, virtualJoinTable.specifiedJoinColumnsSize());
- assertEquals(1, virtualJoinTable.specifiedInverseJoinColumnsSize());
- virtualJoinColumn = virtualJoinTable.specifiedJoinColumns().next();
- assertEquals("NAME", virtualJoinColumn.getSpecifiedName());
- assertEquals("REFERENCED_NAME", virtualJoinColumn.getSpecifiedReferencedColumnName());
- virtualInverseOrmJoinColumn = virtualJoinTable.specifiedInverseJoinColumns().next();
- assertEquals("INVERSE_NAME", virtualInverseOrmJoinColumn.getSpecifiedName());
- assertEquals("INVERSE_REFERENCED_NAME", virtualInverseOrmJoinColumn.getSpecifiedReferencedColumnName());
- }
-
- public void testUpdateDefaultNameFromJavaTable() throws Exception {
- createTestEntityWithValidOneToOneMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
- OrmOneToOneMapping2_0 ormOneToOneMapping = (OrmOneToOneMapping2_0) ormPersistentAttribute.getMapping();
- ((OneToOneRelationship2_0) ormOneToOneMapping.getRelationship()).setStrategyToJoinTable();
- OrmJoinTable ormJoinTable = ((OrmOneToOneRelationship2_0) ormOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertEquals(null, ormJoinTable.getDefaultName());
-
- createTestTargetEntityAddress();
- OrmPersistentType targetPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- assertEquals(TYPE_NAME + "_Address", ormJoinTable.getDefaultName());
-
-
- ((JavaEntity) targetPersistentType.getJavaPersistentType().getMapping()).getTable().setSpecifiedName("FOO");
- assertEquals(TYPE_NAME + "_FOO", ormJoinTable.getDefaultName());
-
- ((JavaEntity) ormPersistentType.getJavaPersistentType().getMapping()).getTable().setSpecifiedName("BAR");
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
- JavaOneToOneMapping2_0 javaOneToOneMapping = (JavaOneToOneMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("address").getMapping();
- ((OneToOneRelationship2_0) javaOneToOneMapping.getRelationship()).setStrategyToJoinTable();
- ((OneToOneRelationship2_0) javaOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable().setSpecifiedName("JAVA_JOIN_TABLE");
-
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
-
- //set metadata-complete to true, will ignore java annotation settings
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(TYPE_NAME + "_Address", ormJoinTable.getDefaultName());
-
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- //remove m-m mapping from the orm.xml file
- ormPersistentAttribute.convertToVirtual();
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null);
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("address");
- OneToOneMapping2_0 virtualOneToOneMapping = (OneToOneMapping2_0) ormPersistentAttribute2.getMapping();
- JoinTable virtualJoinTable = ((OneToOneRelationship2_0) virtualOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertTrue(ormPersistentAttribute2.isVirtual());
- assertEquals("JAVA_JOIN_TABLE", virtualJoinTable.getSpecifiedName());//specifiedName since this is a virtual mapping now
-
- ((OneToOneRelationship2_0) javaOneToOneMapping.getRelationship()).getJoinTableStrategy().removeStrategy();
- virtualJoinTable = ((OneToOneRelationship2_0) virtualOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertNull(virtualJoinTable);
- ((OneToOneRelationship2_0) javaOneToOneMapping.getRelationship()).setStrategyToJoinTable();
- virtualJoinTable = ((OneToOneRelationship2_0) virtualOneToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertEquals("BAR_FOO", virtualJoinTable.getName());
- assertEquals("BAR_FOO", virtualJoinTable.getDefaultName());
-
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE_NAME");
- assertEquals("ORM_TABLE_NAME_FOO", virtualJoinTable.getDefaultName());
-
- ((OrmEntity) targetPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TARGET");
- assertEquals("ORM_TABLE_NAME_ORM_TARGET", virtualJoinTable.getDefaultName());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntityWithOneToOneMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("id");
- OrmOneToOneMapping2_0 contextMapping = (OrmOneToOneMapping2_0) contextAttribute.getMapping();
- OrmOneToOneRelationship2_0 rel = (OrmOneToOneRelationship2_0) contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlOneToOne resourceMapping = resourceEntity.getAttributes().getOneToOnes().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToMappedBy();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertTrue(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToPrimaryKeyJoinColumn();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertFalse(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinTable();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertTrue(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinColumn();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntityWithOneToOneMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("id");
- OrmOneToOneMapping2_0 contextMapping = (OrmOneToOneMapping2_0) contextAttribute.getMapping();
- OrmOneToOneRelationship2_0 rel = (OrmOneToOneRelationship2_0) contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlOneToOne resourceMapping = resourceEntity.getAttributes().getOneToOnes().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.getPrimaryKeyJoinColumns().add(OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn());
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertFalse(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertFalse(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.setMappedBy("foo");
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertFalse(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertTrue(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTable());
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertFalse(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getMappedBy());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertTrue(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.getPrimaryKeyJoinColumns().clear();
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getMappedBy());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertTrue(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.getJoinColumns().clear();
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getMappedBy());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertTrue(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.setMappedBy(null);
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertTrue(rel.strategyIsJoinTable());
-
- resourceMapping.setJoinTable(null);
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertTrue(resourceMapping.getPrimaryKeyJoinColumns().isEmpty());
- assertNull(resourceMapping.getMappedBy());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsPrimaryKeyJoinColumn());
- assertFalse(rel.strategyIsMappedBy());
- assertFalse(rel.strategyIsJoinTable());
- }
-
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- EclipseLinkOneToOneMapping2_0 virtualOneToOneMapping = (EclipseLinkOneToOneMapping2_0) 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());
-
- JoinColumn ormJoinColumn =
- virtualOneToOneMapping.getRelationship().getJoinColumnStrategy().specifiedJoinColumns().next();
- assertEquals("MY_COLUMN", ormJoinColumn.getSpecifiedName());
- assertEquals("MY_REFERENCED_COLUMN", ormJoinColumn.getSpecifiedReferencedColumnName());
- assertEquals(Boolean.TRUE, ormJoinColumn.getSpecifiedUnique());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedNullable());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedInsertable());
- assertEquals(Boolean.FALSE, ormJoinColumn.getSpecifiedUpdatable());
- assertEquals("COLUMN_DEFINITION", ormJoinColumn.getColumnDefinition());
- assertEquals("MY_TABLE", ormJoinColumn.getSpecifiedTable());
-
- Cascade2_0 cascade = (Cascade2_0) virtualOneToOneMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
- assertTrue(cascade.isDetach());
-
- assertEquals(EclipseLinkJoinFetchType.INNER, virtualOneToOneMapping.getJoinFetch().getValue());
- assertTrue(virtualOneToOneMapping.getPrivateOwned().isPrivateOwned());
-
- assertTrue(((OrphanRemovalHolder2_0) virtualOneToOneMapping).getOrphanRemoval().isOrphanRemoval());
- }
-
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
- assertTrue(virtualPersistentAttribute.isVirtual());
-
- EclipseLinkOneToOneMapping2_0 ormOneToOneMapping = (EclipseLinkOneToOneMapping2_0) 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());
-
- Cascade2_0 cascade = (Cascade2_0) ormOneToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- assertFalse(cascade.isDetach());
-
- assertEquals(null, ormOneToOneMapping.getJoinFetch().getValue());
- assertFalse(ormOneToOneMapping.getPrivateOwned().isPrivateOwned());
-
- assertFalse(((OrphanRemovalHolder2_0) ormOneToOneMapping).getOrphanRemoval().isOrphanRemoval());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/Eclipselink2_0OrmManyToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/Eclipselink2_0OrmManyToOneMappingTests.java
deleted file mode 100644
index 3200bdf147..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/Eclipselink2_0OrmManyToOneMappingTests.java
+++ /dev/null
@@ -1,589 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-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.iterators.ArrayIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-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.Cascade2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlDerivedId_2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlMapsId_2_0;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchMapping;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkJoinFetchType;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.java.EclipseLink;
-
-@SuppressWarnings("nls")
-public class Eclipselink2_0OrmManyToOneMappingTests
- extends EclipseLink2_0OrmContextModelTestCase
-{
- public Eclipselink2_0OrmManyToOneMappingTests(String name) {
- super(name);
- }
-
-
- private void createTestEntityWithIdDerivedIdentity() throws Exception {
- createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_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(" @ManyToOne @Id").append(CR);
- sb.append(" private " + TYPE_NAME + " manyToOne;").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 void createTestEntityWithMapsIdDerivedIdentity() throws Exception {
- createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_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(" @ManyToOne @MapsId").append(CR);
- sb.append(" private " + TYPE_NAME + " manyToOne;").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 createTestEntityWithValidManyToOneMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_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(" @ManyToOne").append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id").append(CR);
- }
- });
- }
-
- 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(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(" 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 createTestEntityWithManyToOneMapping() throws Exception {
- createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity").append(CR);
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append("@ManyToOne").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 createTestEntityManyToOneMapping() throws Exception {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(JPA.ENTITY, JPA.MANY_TO_ONE, JPA.JOIN_COLUMN, JPA.FETCH_TYPE, JPA.CASCADE_TYPE, EclipseLink.JOIN_FETCH, EclipseLink.JOIN_FETCH_TYPE);
- }
- @Override
- public void appendTypeAnnotationTo(StringBuilder sb) {
- sb.append("@Entity");
- }
-
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(CR);
- sb.append(" @ManyToOne(fetch=FetchType.LAZY, optional=false, targetEntity=Address.class, cascade={CascadeType.ALL, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH, CascadeType.DETACH})");
- sb.append(CR);
- sb.append(" @JoinColumn(name=\"MY_COLUMN\", referencedColumnName=\"MY_REFERENCED_COLUMN\", unique=true, nullable=false, insertable=false, updatable=false, columnDefinition=\"COLUMN_DEFINITION\", table=\"MY_TABLE\")");
- sb.append(CR);
- sb.append(" @JoinFetch(JoinFetchType.INNER)");
- sb.append(CR);
- sb.append(" private Address address;").append(CR);
- sb.append(CR);
- sb.append(" @Id");
- }
- });
- }
-
- public void testUpdateDerivedId() throws Exception {
- createTestEntityWithIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("manyToOne");
- OrmManyToOneMapping2_0 contextMapping = (OrmManyToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlDerivedId_2_0 resourceMapping = resourceEntity.getAttributes().getManyToOnes().get(0);
-
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- resourceMapping.setId(Boolean.FALSE);
- assertEquals(Boolean.FALSE, resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- resourceMapping.setId(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceMapping.getId());
- assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- resourceMapping.setId(null);
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- }
-
- public void testSetDerivedId() throws Exception {
- createTestEntityWithIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("manyToOne");
- OrmManyToOneMapping2_0 contextMapping = (OrmManyToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlDerivedId_2_0 resourceMapping = resourceEntity.getAttributes().getManyToOnes().get(0);
-
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(true);
- assertEquals(Boolean.TRUE, resourceMapping.getId());
- assertTrue(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
-
- contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().setValue(false);
- assertNull(resourceMapping.getId());
- assertFalse(contextMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- }
-
- public void testUpdateMapsId() throws Exception {
- createTestEntityWithMapsIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("manyToOne");
- OrmManyToOneMapping2_0 contextMapping = (OrmManyToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlMapsId_2_0 resourceMapping = resourceEntity.getAttributes().getManyToOnes().get(0);
-
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- resourceMapping.setMapsId("foo");
- assertEquals("foo", resourceMapping.getMapsId());
- assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- resourceMapping.setMapsId("bar");
- assertEquals("bar", resourceMapping.getMapsId());
- assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- resourceMapping.setMapsId(null);
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
- }
-
- public void testSetMapsId() throws Exception {
- createTestEntityWithMapsIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("manyToOne");
- OrmManyToOneMapping2_0 contextMapping = (OrmManyToOneMapping2_0) contextAttribute.getMapping();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlMapsId_2_0 resourceMapping = resourceEntity.getAttributes().getManyToOnes().get(0);
-
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue("foo");
- assertEquals("foo", resourceMapping.getMapsId());
- assertEquals("foo", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue("bar");
- assertEquals("bar", resourceMapping.getMapsId());
- assertEquals("bar", contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().setSpecifiedValue(null);
- assertNull(resourceMapping.getMapsId());
- assertNull(contextMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
- }
-
- public void testMorphMapping() throws Exception {
- createTestEntityWithIdDerivedIdentity();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmPersistentAttribute contextAttribute = (OrmPersistentAttribute) contextType.getAttributeNamed("manyToOne");
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
-
- XmlManyToOne resourceManyToOne = resourceEntity.getAttributes().getManyToOnes().get(0);
- resourceManyToOne.setId(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceManyToOne.getId());
- assertTrue(((OrmManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceManyToOne.getMapsId());
- assertNull(((OrmManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextAttribute.setMappingKey(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- XmlOneToOne resourceOneToOne = resourceEntity.getAttributes().getOneToOnes().get(0);
- assertEquals(Boolean.TRUE, resourceOneToOne.getId());
- assertTrue(((OrmOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceOneToOne.getMapsId());
- assertNull(((OrmOneToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
-
- contextAttribute.setMappingKey(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- resourceManyToOne.setId(Boolean.TRUE);
- assertEquals(Boolean.TRUE, resourceManyToOne.getId());
- assertTrue(((OrmManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getIdDerivedIdentityStrategy().getValue());
- assertNull(resourceManyToOne.getMapsId());
- assertNull(((OrmManyToOneMapping2_0) contextAttribute.getMapping()).
- getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getSpecifiedValue());
- }
-
- public void testVirtualJoinTable() throws Exception {
- createTestEntityWithValidManyToOneMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmReadOnlyPersistentAttribute ormPersistentAttribute = ormPersistentType.getAttributeNamed("address");
- JavaManyToOneMapping2_0 javaManyToOneMapping = ((JavaManyToOneMapping2_0) ormPersistentAttribute.getJavaPersistentAttribute().getMapping());
- ManyToOneMapping2_0 virtualManyToOneMapping = (ManyToOneMapping2_0) ormPersistentAttribute.getMapping();
- ((ManyToOneRelationship2_0) javaManyToOneMapping.getRelationship()).setStrategyToJoinTable();
- JoinTable ormJoinTable = ((ManyToOneRelationship2_0) virtualManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
-
- assertTrue(ormPersistentAttribute.isVirtual());
- assertEquals(null, ormJoinTable.getSpecifiedName());
-
- createTestTargetEntityAddress();
- getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
-
- assertEquals(TYPE_NAME + "_Address", ormJoinTable.getName());
- assertNull(ormJoinTable.getSpecifiedCatalog());
- assertNull(ormJoinTable.getSpecifiedSchema());
- assertEquals(0, ormJoinTable.specifiedJoinColumnsSize());
- assertEquals(0, ormJoinTable.specifiedInverseJoinColumnsSize());
- JoinColumn ormJoinColumn = ormJoinTable.getDefaultJoinColumn();
- assertEquals(TYPE_NAME + "_Address", ormJoinColumn.getDefaultTable());
- assertEquals(TYPE_NAME + "_id", ormJoinColumn.getDefaultName());
- assertEquals("id", ormJoinColumn.getDefaultReferencedColumnName());
- JoinColumn inverseOrmJoinColumn = ormJoinTable.getDefaultInverseJoinColumn();
- assertEquals(TYPE_NAME + "_Address", inverseOrmJoinColumn.getDefaultTable());
- assertEquals("address_id", inverseOrmJoinColumn.getDefaultName());
- assertEquals("id", inverseOrmJoinColumn.getDefaultReferencedColumnName());
-
- JavaJoinTable javaJoinTable = ((JavaManyToOneRelationship2_0) javaManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- javaJoinTable.setSpecifiedName("FOO");
- javaJoinTable.setSpecifiedCatalog("CATALOG");
- javaJoinTable.setSpecifiedSchema("SCHEMA");
- JavaJoinColumn javaJoinColumn = javaJoinTable.addSpecifiedJoinColumn(0);
- javaJoinColumn.setSpecifiedName("NAME");
- javaJoinColumn.setSpecifiedReferencedColumnName("REFERENCED_NAME");
- JavaJoinColumn inverseJavaJoinColumn = javaJoinTable.addSpecifiedInverseJoinColumn(0);
- inverseJavaJoinColumn.setSpecifiedName("INVERSE_NAME");
- inverseJavaJoinColumn.setSpecifiedReferencedColumnName("INVERSE_REFERENCED_NAME");
-
- assertEquals("FOO", ormJoinTable.getSpecifiedName());
- assertEquals("CATALOG", ormJoinTable.getSpecifiedCatalog());
- assertEquals("SCHEMA", ormJoinTable.getSpecifiedSchema());
- assertEquals(1, ormJoinTable.specifiedJoinColumnsSize());
- assertEquals(1, ormJoinTable.specifiedInverseJoinColumnsSize());
- ormJoinColumn = ormJoinTable.specifiedJoinColumns().next();
- assertEquals("NAME", ormJoinColumn.getSpecifiedName());
- assertEquals("REFERENCED_NAME", ormJoinColumn.getSpecifiedReferencedColumnName());
- inverseOrmJoinColumn = ormJoinTable.specifiedInverseJoinColumns().next();
- assertEquals("INVERSE_NAME", inverseOrmJoinColumn.getSpecifiedName());
- assertEquals("INVERSE_REFERENCED_NAME", inverseOrmJoinColumn.getSpecifiedReferencedColumnName());
- }
-
- public void testUpdateDefaultNameFromJavaTable() throws Exception {
- createTestEntityWithValidManyToOneMapping();
-
- OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
-
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.addSpecifiedAttribute(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, "address");
- OrmManyToOneMapping2_0 ormManyToOneMapping = (OrmManyToOneMapping2_0) ormPersistentAttribute.getMapping();
- ((ManyToOneRelationship2_0) ormManyToOneMapping.getRelationship()).setStrategyToJoinTable();
- JoinTable ormJoinTable = ((OrmManyToOneRelationship2_0) ormManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertEquals(null, ormJoinTable.getDefaultName());
-
- createTestTargetEntityAddress();
- OrmPersistentType targetPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, PACKAGE_NAME + ".Address");
- assertEquals(TYPE_NAME + "_Address", ormJoinTable.getDefaultName());
-
-
- ((JavaEntity) targetPersistentType.getJavaPersistentType().getMapping()).getTable().setSpecifiedName("FOO");
- assertEquals(TYPE_NAME + "_FOO", ormJoinTable.getDefaultName());
-
- ((JavaEntity) ormPersistentType.getJavaPersistentType().getMapping()).getTable().setSpecifiedName("BAR");
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
- JavaManyToOneMapping2_0 javaManyToOneMapping = (JavaManyToOneMapping2_0) ormPersistentType.getJavaPersistentType().getAttributeNamed("address").getMapping();
- ((ManyToOneRelationship2_0) javaManyToOneMapping.getRelationship()).setStrategyToJoinTable();
- ((ManyToOneRelationship2_0) javaManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable().setSpecifiedName("JAVA_JOIN_TABLE");
-
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
-
- //set metadata-complete to true, will ignore java annotation settings
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(true);
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(Boolean.TRUE);
- assertEquals(TYPE_NAME + "_Address", ormJoinTable.getDefaultName());
-
-
- getEntityMappings().getPersistenceUnitMetadata().setXmlMappingMetadataComplete(false);
- //remove m-m mapping from the orm.xml file
- ormPersistentAttribute.convertToVirtual();
- //ormPersistentType.getMapping().setSpecifiedMetadataComplete(null);
- OrmReadOnlyPersistentAttribute ormPersistentAttribute2 = ormPersistentType.getAttributeNamed("address");
- ManyToOneMapping2_0 virtualManyToOneMapping = (ManyToOneMapping2_0) ormPersistentAttribute2.getMapping();
- ormJoinTable = ((ManyToOneRelationship2_0) virtualManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertTrue(ormPersistentAttribute2.isVirtual());
- assertEquals("JAVA_JOIN_TABLE", ormJoinTable.getSpecifiedName());//specifiedName since this is a virtual mapping now
-
- ((ManyToOneRelationship2_0) javaManyToOneMapping.getRelationship()).getJoinTableStrategy().removeStrategy();
- ormJoinTable = ((ManyToOneRelationship2_0) virtualManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertNull(ormJoinTable);
- ((ManyToOneRelationship2_0) javaManyToOneMapping.getRelationship()).setStrategyToJoinTable();
- ormJoinTable = ((ManyToOneRelationship2_0) virtualManyToOneMapping.getRelationship()).getJoinTableStrategy().getJoinTable();
- assertEquals("BAR_FOO", ormJoinTable.getName());
- assertEquals("BAR_FOO", ormJoinTable.getDefaultName());
-
- ((OrmEntity) ormPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TABLE_NAME");
- assertEquals("ORM_TABLE_NAME_FOO", ormJoinTable.getDefaultName());
-
- ((OrmEntity) targetPersistentType.getMapping()).getTable().setSpecifiedName("ORM_TARGET");
- assertEquals("ORM_TABLE_NAME_ORM_TARGET", ormJoinTable.getDefaultName());
- }
-
- public void testModifyPredominantJoiningStrategy() throws Exception {
- createTestEntityWithManyToOneMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("id");
- OrmManyToOneMapping2_0 contextMapping = (OrmManyToOneMapping2_0) contextAttribute.getMapping();
- OrmManyToOneRelationship2_0 rel = (OrmManyToOneRelationship2_0) contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlManyToOne resourceMapping = resourceEntity.getAttributes().getManyToOnes().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinColumn();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinTable();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
-
- rel.setStrategyToJoinColumn();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
- }
-
- public void testUpdatePredominantJoiningStrategy() throws Exception {
- createTestEntityWithManyToOneMapping();
- OrmPersistentType contextType = getEntityMappings().getPersistentType(FULLY_QUALIFIED_TYPE_NAME);
- OrmReadOnlyPersistentAttribute contextAttribute = contextType.getAttributeNamed("id");
- OrmManyToOneMapping2_0 contextMapping = (OrmManyToOneMapping2_0) contextAttribute.getMapping();
- OrmManyToOneRelationship2_0 rel = (OrmManyToOneRelationship2_0) contextMapping.getRelationship();
- XmlEntity resourceEntity = (XmlEntity) contextType.getMapping().getXmlTypeMapping();
- XmlManyToOne resourceMapping = resourceEntity.getAttributes().getManyToOnes().get(0);
-
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.getJoinColumns().add(OrmFactory.eINSTANCE.createXmlJoinColumn());
- getJpaProject().synchronizeContextModel();
- assertFalse(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.getJoinColumns().clear();
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNull(resourceMapping.getJoinTable());
- assertTrue(rel.strategyIsJoinColumn());
- assertFalse(rel.strategyIsJoinTable());
-
- resourceMapping.setJoinTable(OrmFactory.eINSTANCE.createXmlJoinTable());
- getJpaProject().synchronizeContextModel();
- assertTrue(resourceMapping.getJoinColumns().isEmpty());
- assertNotNull(resourceMapping.getJoinTable());
- assertFalse(rel.strategyIsJoinColumn());
- assertTrue(rel.strategyIsJoinTable());
- }
-
- public void testVirtualMappingMetadataCompleteFalse() throws Exception {
- createTestEntityManyToOneMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.virtualAttributes().next();
-
- ManyToOneMapping2_0 virtualManyToOneMapping = (ManyToOneMapping2_0) virtualPersistentAttribute.getMapping();
- assertEquals("address", virtualManyToOneMapping.getName());
- assertEquals(FetchType.LAZY, virtualManyToOneMapping.getSpecifiedFetch());
- assertEquals(Boolean.FALSE, virtualManyToOneMapping.getSpecifiedOptional());
- assertEquals("Address", virtualManyToOneMapping.getSpecifiedTargetEntity());
-
- JoinColumn virtualJoinColumn = virtualManyToOneMapping.getRelationship().getJoinColumnStrategy().specifiedJoinColumns().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.getSpecifiedTable());
-
- Cascade2_0 cascade = (Cascade2_0) virtualManyToOneMapping.getCascade();
- assertTrue(cascade.isAll());
- assertTrue(cascade.isMerge());
- assertTrue(cascade.isPersist());
- assertTrue(cascade.isRemove());
- assertTrue(cascade.isRefresh());
- assertTrue(cascade.isDetach());
-
- assertEquals(EclipseLinkJoinFetchType.INNER, ((EclipseLinkJoinFetchMapping) virtualManyToOneMapping).getJoinFetch().getValue());
- }
-
- public void testVirtualMappingMetadataCompleteTrue() throws Exception {
- createTestEntityManyToOneMapping();
- 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.virtualAttributesSize());
- OrmReadOnlyPersistentAttribute virtualPersistentAttribute = ormPersistentType.getAttributeNamed("address");
-
- assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, virtualPersistentAttribute.getMappingKey());
- assertTrue(virtualPersistentAttribute.isVirtual());
-
- virtualPersistentAttribute.convertToSpecified(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- OrmPersistentAttribute ormPersistentAttribute = ormPersistentType.specifiedAttributes().next();
-
- OrmManyToOneMapping2_0 ormManyToOneMapping = (OrmManyToOneMapping2_0) ormPersistentAttribute.getMapping();
- assertEquals("address", ormManyToOneMapping.getName());
- assertEquals(FetchType.EAGER, ormManyToOneMapping.getDefaultFetch());
- assertEquals(true, ormManyToOneMapping.isDefaultOptional());
- assertEquals("test.Address", ormManyToOneMapping.getDefaultTargetEntity());
-
- Cascade2_0 cascade = (Cascade2_0) ormManyToOneMapping.getCascade();
- assertFalse(cascade.isAll());
- assertFalse(cascade.isMerge());
- assertFalse(cascade.isPersist());
- assertFalse(cascade.isRemove());
- assertFalse(cascade.isRefresh());
- assertFalse(cascade.isDetach());
-
- assertEquals(null, ((EclipseLinkJoinFetchMapping) ormManyToOneMapping).getJoinFetch().getValue());
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/JptEclipseLink2_0OrmContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/JptEclipseLink2_0OrmContextModelTests.java
deleted file mode 100644
index afc9505c32..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/orm/JptEclipseLink2_0OrmContextModelTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.orm;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class JptEclipseLink2_0OrmContextModelTests extends TestCase
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink2_0OrmContextModelTests.class.getName());
- suite.addTestSuite(EclipseLink2_0OrmCollectionTableTests.class);
- suite.addTestSuite(EclipseLink2_0OrmElementCollectionMappingTests.class);
- suite.addTestSuite(EclipseLink2_0OrmEntityTests.class);
- suite.addTestSuite(EclipseLink2_0OrmManyToManyMappingTests.class);
- suite.addTestSuite(Eclipselink2_0OrmManyToOneMappingTests.class);
- suite.addTestSuite(EclipseLink2_0OrmMappedSuperclassTests.class);
- suite.addTestSuite(EclipseLink2_0OrmOneToOneMappingTests.class);
- suite.addTestSuite(EclipseLink2_0OrmOneToManyMappingTests.class);
- return suite;
- }
-
- private JptEclipseLink2_0OrmContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0ConnectionTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0ConnectionTests.java
deleted file mode 100644
index 71eec38423..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0ConnectionTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009 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.eclipselink.core.tests.internal.v2_0.context.persistence;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnection2_0;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.connection.Connection;
-import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.persistence.connection.Connection2_0;
-
-/**
- * EclipseLink2_0ConnectionTests
- */
-@SuppressWarnings("nls")
-public class EclipseLink2_0ConnectionTests extends EclipseLink2_0PersistenceUnitTestCase
-{
- private Connection2_0 connection;
-
- public static final String NATIVE_SQL_KEY = Connection.ECLIPSELINK_NATIVE_SQL;
- public static final Boolean NATIVE_SQL_TEST_VALUE = false;
- public static final Boolean NATIVE_SQL_TEST_VALUE_2 = ! NATIVE_SQL_TEST_VALUE;
-
- public static final String DRIVER_KEY = JpaConnection2_0.PERSISTENCE_JDBC_DRIVER;
- public static final String DRIVER_TEST_VALUE = "connection.driver";
- public static final String DRIVER_TEST_VALUE_2 = "connection.driver.2";
- public static final String LEGACY_DRIVER_KEY = Connection.ECLIPSELINK_DRIVER;
- public static final String LEGACY_DRIVER_TEST_VALUE = "legacy.connection.driver";
-
- public static final String URL_KEY = JpaConnection2_0.PERSISTENCE_JDBC_URL;
- public static final String URL_TEST_VALUE = "test";
- public static final String URL_TEST_VALUE_2 = "test_2";
- public static final String LEGACY_URL_KEY = Connection.ECLIPSELINK_URL;
- public static final String LEGACY_URL_TEST_VALUE = "legacy.connection.url";
-
- public static final String USER_KEY = JpaConnection2_0.PERSISTENCE_JDBC_USER;
- public static final String USER_TEST_VALUE = "test";
- public static final String USER_TEST_VALUE_2 = "test_2";
- public static final String LEGACY_USER_KEY = Connection.ECLIPSELINK_USER;
- public static final String LEGACY_USER_TEST_VALUE = "legacy.connection.user";
-
- public static final String PASSWORD_KEY = JpaConnection2_0.PERSISTENCE_JDBC_PASSWORD;
- public static final String PASSWORD_TEST_VALUE = "test";
- public static final String PASSWORD_TEST_VALUE_2 = "test_2";
- public static final String LEGACY_PASSWORD_KEY = Connection.ECLIPSELINK_PASSWORD;
- public static final String LEGACY_PASSWORD_TEST_VALUE = "legacy.connection.password";
-
- public EclipseLink2_0ConnectionTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.connection = (Connection2_0) this.subject.getConnection();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.connection.addPropertyChangeListener(Connection.DRIVER_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.URL_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.USER_PROPERTY, propertyChangeListener);
- this.connection.addPropertyChangeListener(Connection.PASSWORD_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PU properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 8; // EclipseLink properties
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 1; // 4 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- // Initializes EclipseLink properties
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(LEGACY_DRIVER_KEY, LEGACY_DRIVER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(DRIVER_KEY, DRIVER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(LEGACY_URL_KEY, LEGACY_URL_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(URL_KEY, URL_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(LEGACY_USER_KEY, LEGACY_USER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(USER_KEY, USER_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(LEGACY_PASSWORD_KEY, LEGACY_PASSWORD_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(PASSWORD_KEY, PASSWORD_TEST_VALUE.toString());
-
- return;
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.connection;
- }
-
- // ********** get/set property **********
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
-
- if (propertyName.equals(Connection.DRIVER_PROPERTY))
- modelValue = this.connection.getDriver();
- else if (propertyName.equals(Connection.URL_PROPERTY))
- modelValue = this.connection.getUrl();
- else if (propertyName.equals(Connection.USER_PROPERTY))
- modelValue = this.connection.getUser();
- else if (propertyName.equals(Connection.PASSWORD_PROPERTY))
- modelValue = this.connection.getPassword();
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Connection.DRIVER_PROPERTY))
- this.connection.setDriver((String) newValue);
- else if (propertyName.equals(Connection.URL_PROPERTY))
- this.connection.setUrl((String) newValue);
- else if (propertyName.equals(Connection.USER_PROPERTY))
- this.connection.setUser((String) newValue);
- else if (propertyName.equals(Connection.PASSWORD_PROPERTY))
- this.connection.setPassword((String) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
-
- // ********** Properties Name Migration tests **********
- public void testDriverPropertyNameMigration() throws Exception {
-
- // Verify legacy driver exists
- assertTrue("Legacy driver not exists", this.propertyValueEquals(LEGACY_DRIVER_KEY, LEGACY_DRIVER_TEST_VALUE));
-
- // Verify driver read in
- assertEquals("Incorrect driver read", this.connection.getDriver(), DRIVER_TEST_VALUE);
-
- // Change driver value
- this.connection.setDriver(DRIVER_TEST_VALUE_2);
- // Verify driver value changed
- assertEquals("Driver not set", this.connection.getDriver(), DRIVER_TEST_VALUE_2);
- assertTrue("PersistenceUnit property not set", this.propertyValueEquals(DRIVER_KEY, DRIVER_TEST_VALUE_2));
-
- // Verify legacy entry has been deleted
- this.verifyPuHasNotProperty(LEGACY_DRIVER_KEY, "Legacy property has not been deleted");
- }
-
- public void testPropertiesNamesMigration() throws Exception {
- // connection.initializeProperties() occurred before test.puPopulate() therefore
- // we cannot test the case where there are legacy properties only exist in the xml
- // Verify that User & Password exist in both forms
- this.verifyPuHasProperty(USER_KEY, "Property not exists");
- this.verifyPuHasProperty(PASSWORD_KEY, "Property not exists");
- this.verifyPuHasProperty(LEGACY_USER_KEY, "Legacy property not exists");
- this.verifyPuHasProperty(LEGACY_PASSWORD_KEY, "Legacy property not exists");
-
- // Change a property value to trigger migration routine
- this.connection.setNativeSql(NATIVE_SQL_TEST_VALUE);
-
- // Verify that all legacy entry has been deleted
- this.verifyPuHasNotProperty(LEGACY_DRIVER_KEY, "Legacy property has not been deleted");
- this.verifyPuHasNotProperty(LEGACY_URL_KEY, "Legacy property has not been deleted");
- this.verifyPuHasNotProperty(LEGACY_USER_KEY, "Legacy property has not been deleted");
- this.verifyPuHasNotProperty(LEGACY_PASSWORD_KEY, "Legacy property has not been deleted");
- }
-
-
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0LoggingTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0LoggingTests.java
deleted file mode 100644
index c9251febe2..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0LoggingTests.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.persistence;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.logging.LoggingLevel;
-import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.persistence.logging.Logging2_0;
-
-/**
- * EclipseLink2_0LoggingTests
- */
-@SuppressWarnings("nls")
-public class EclipseLink2_0LoggingTests extends EclipseLink2_0PersistenceUnitTestCase
-{
- private Logging2_0 logging;
-
- public static final String SQL_LOGGING_KEY = Logging2_0.ECLIPSELINK_SQL_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel SQL_LOGGING_TEST_VALUE = LoggingLevel.off;
- public static final LoggingLevel SQL_LOGGING_TEST_VALUE_2 = LoggingLevel.severe;
-
- public static final String TRANSACTION_LOGGING_KEY = Logging2_0.ECLIPSELINK_TRANSACTION_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel TRANSACTION_LOGGING_TEST_VALUE = LoggingLevel.warning;
- public static final LoggingLevel TRANSACTION_LOGGING_TEST_VALUE_2 = LoggingLevel.info;
-
- public static final String EVENT_LOGGING_KEY = Logging2_0.ECLIPSELINK_EVENT_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel EVENT_LOGGING_TEST_VALUE = LoggingLevel.config;
- public static final LoggingLevel EVENT_LOGGING_TEST_VALUE_2 = LoggingLevel.fine;
-
- public static final String CONNECTION_LOGGING_KEY = Logging2_0.ECLIPSELINK_CONNECTION_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel CONNECTION_LOGGING_TEST_VALUE = LoggingLevel.finer;
- public static final LoggingLevel CONNECTION_LOGGING_TEST_VALUE_2 = LoggingLevel.finest;
-
- public static final String QUERY_LOGGING_KEY = Logging2_0.ECLIPSELINK_QUERY_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel QUERY_LOGGING_TEST_VALUE = LoggingLevel.all;
- public static final LoggingLevel QUERY_LOGGING_TEST_VALUE_2 = LoggingLevel.off;
-
- public static final String CACHE_LOGGING_KEY = Logging2_0.ECLIPSELINK_CACHE_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel CACHE_LOGGING_TEST_VALUE = LoggingLevel.severe;
- public static final LoggingLevel CACHE_LOGGING_TEST_VALUE_2 = LoggingLevel.warning;
-
- public static final String PROPAGATION_LOGGING_KEY = Logging2_0.ECLIPSELINK_PROPAGATION_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel PROPAGATION_LOGGING_TEST_VALUE = LoggingLevel.info;
- public static final LoggingLevel PROPAGATION_LOGGING_TEST_VALUE_2 = LoggingLevel.config;
-
- public static final String SEQUENCING_LOGGING_KEY = Logging2_0.ECLIPSELINK_SEQUENCING_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel SEQUENCING_LOGGING_TEST_VALUE = LoggingLevel.fine;
- public static final LoggingLevel SEQUENCING_LOGGING_TEST_VALUE_2 = LoggingLevel.finer;
-
- public static final String EJB_LOGGING_KEY = Logging2_0.ECLIPSELINK_EJB_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel EJB_LOGGING_TEST_VALUE = LoggingLevel.finest;
- public static final LoggingLevel EJB_LOGGING_TEST_VALUE_2 = LoggingLevel.all;
-
- public static final String DMS_LOGGING_KEY = Logging2_0.ECLIPSELINK_DMS_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel DMS_LOGGING_TEST_VALUE = LoggingLevel.off;
- public static final LoggingLevel DMS_LOGGING_TEST_VALUE_2 = LoggingLevel.severe;
-
- public static final String EJB_OR_METADATA_LOGGING_KEY = Logging2_0.ECLIPSELINK_EJB_OR_METADATA_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel EJB_OR_METADATA_LOGGING_TEST_VALUE = LoggingLevel.warning;
- public static final LoggingLevel EJB_OR_METADATA_LOGGING_TEST_VALUE_2 = LoggingLevel.info;
-
- public static final String METAMODEL_LOGGING_KEY = Logging2_0.ECLIPSELINK_METAMODEL_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel METAMODEL_LOGGING_TEST_VALUE = LoggingLevel.config;
- public static final LoggingLevel METAMODEL_LOGGING_TEST_VALUE_2 = LoggingLevel.fine;
-
- public static final String WEAVER_LOGGING_KEY = Logging2_0.ECLIPSELINK_WEAVER_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel WEAVER_LOGGING_TEST_VALUE = LoggingLevel.finer;
- public static final LoggingLevel WEAVER_LOGGING_TEST_VALUE_2 = LoggingLevel.finest;
-
- public static final String PROPERTIES_LOGGING_KEY = Logging2_0.ECLIPSELINK_PROPERTIES_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel PROPERTIES_LOGGING_TEST_VALUE = LoggingLevel.all;
- public static final LoggingLevel PROPERTIES_LOGGING_TEST_VALUE_2 = LoggingLevel.off;
-
- public static final String SERVER_LOGGING_KEY = Logging2_0.ECLIPSELINK_SERVER_CATEGORY_LOGGING_LEVEL;
- public static final LoggingLevel SERVER_LOGGING_TEST_VALUE = LoggingLevel.severe;
- public static final LoggingLevel SERVER_LOGGING_TEST_VALUE_2 = LoggingLevel.warning;
-
- // ********** constructors **********
- public EclipseLink2_0LoggingTests(String name) {
- super(name);
- }
-
- // ********** behavior **********
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.logging = (Logging2_0) this.subject.getLogging();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.logging.addPropertyChangeListener(Logging2_0.SQL_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.TRANSACTION_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.EVENT_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.CONNECTION_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.QUERY_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.CACHE_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.PROPAGATION_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.SEQUENCING_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.EJB_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.DMS_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.EJB_OR_METADATA_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.METAMODEL_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.WEAVER_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.PROPERTIES_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
- this.logging.addPropertyChangeListener(Logging2_0.SERVER_CATEGORY_LOGGING_PROPERTY, propertyChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PersistenceUnit properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 15; // PersistenceUnit properties
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 1; // 1 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- // Initializes PersistenceUnit properties
- this.persistenceUnitSetProperty("misc.property.1", "value.1");
- this.persistenceUnitSetProperty(SQL_LOGGING_KEY, SQL_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(TRANSACTION_LOGGING_KEY, TRANSACTION_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(EVENT_LOGGING_KEY, EVENT_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(CONNECTION_LOGGING_KEY, CONNECTION_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(QUERY_LOGGING_KEY, QUERY_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(CACHE_LOGGING_KEY, CACHE_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(PROPAGATION_LOGGING_KEY, PROPAGATION_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(SEQUENCING_LOGGING_KEY, SEQUENCING_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(EJB_LOGGING_KEY, EJB_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(DMS_LOGGING_KEY, DMS_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(EJB_OR_METADATA_LOGGING_KEY, EJB_OR_METADATA_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(METAMODEL_LOGGING_KEY, METAMODEL_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(WEAVER_LOGGING_KEY, WEAVER_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(PROPERTIES_LOGGING_KEY, PROPERTIES_LOGGING_TEST_VALUE);
- this.persistenceUnitSetProperty(SERVER_LOGGING_KEY, SERVER_LOGGING_TEST_VALUE);
-
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.logging;
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
-
- return this.logging.getLevel(propertyName);
- }
-
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
-
- this.logging.setLevel(propertyName, (LoggingLevel) newValue);
- }
-
- // ********** Sql Level tests **********
- public void testSetSqlLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- SQL_LOGGING_KEY,
- SQL_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- SQL_LOGGING_KEY,
- SQL_LOGGING_TEST_VALUE,
- SQL_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveSqlLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- SQL_LOGGING_KEY,
- SQL_LOGGING_TEST_VALUE,
- SQL_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Transaction Level tests **********
- public void testSetTransactionLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- TRANSACTION_LOGGING_KEY,
- TRANSACTION_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- TRANSACTION_LOGGING_KEY,
- TRANSACTION_LOGGING_TEST_VALUE,
- TRANSACTION_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveTransactionLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- TRANSACTION_LOGGING_KEY,
- TRANSACTION_LOGGING_TEST_VALUE,
- TRANSACTION_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Event Level tests **********
- public void testSetEventLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- EVENT_LOGGING_KEY,
- EVENT_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- EVENT_LOGGING_KEY,
- EVENT_LOGGING_TEST_VALUE,
- EVENT_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveEventLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- EVENT_LOGGING_KEY,
- EVENT_LOGGING_TEST_VALUE,
- EVENT_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Connection Level tests **********
- public void testSetConnectionLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- CONNECTION_LOGGING_KEY,
- CONNECTION_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- CONNECTION_LOGGING_KEY,
- CONNECTION_LOGGING_TEST_VALUE,
- CONNECTION_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveConnectionLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- CONNECTION_LOGGING_KEY,
- CONNECTION_LOGGING_TEST_VALUE,
- CONNECTION_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Query Level tests **********
- public void testSetQueryLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- QUERY_LOGGING_KEY,
- QUERY_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- QUERY_LOGGING_KEY,
- QUERY_LOGGING_TEST_VALUE,
- QUERY_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveQueryLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- QUERY_LOGGING_KEY,
- QUERY_LOGGING_TEST_VALUE,
- QUERY_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Cache Level tests **********
- public void testSetCacheLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- CACHE_LOGGING_KEY,
- CACHE_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- CACHE_LOGGING_KEY,
- CACHE_LOGGING_TEST_VALUE,
- CACHE_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveCacheLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- CACHE_LOGGING_KEY,
- CACHE_LOGGING_TEST_VALUE,
- CACHE_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Propagation Level tests **********
- public void testSetPropagationLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- PROPAGATION_LOGGING_KEY,
- PROPAGATION_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- PROPAGATION_LOGGING_KEY,
- PROPAGATION_LOGGING_TEST_VALUE,
- PROPAGATION_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemovePropagationLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- PROPAGATION_LOGGING_KEY,
- PROPAGATION_LOGGING_TEST_VALUE,
- PROPAGATION_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Sequencing Level tests **********
- public void testSetSequencingLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- SEQUENCING_LOGGING_KEY,
- SEQUENCING_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- SEQUENCING_LOGGING_KEY,
- SEQUENCING_LOGGING_TEST_VALUE,
- SEQUENCING_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveSequencingLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- SEQUENCING_LOGGING_KEY,
- SEQUENCING_LOGGING_TEST_VALUE,
- SEQUENCING_LOGGING_TEST_VALUE_2);
- }
-
- // ********** EJB Level tests **********
- public void testSetEJBLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- EJB_LOGGING_KEY,
- EJB_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- EJB_LOGGING_KEY,
- EJB_LOGGING_TEST_VALUE,
- EJB_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveEJBLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- EJB_LOGGING_KEY,
- EJB_LOGGING_TEST_VALUE,
- EJB_LOGGING_TEST_VALUE_2);
- }
-
- // ********** DMS Level tests **********
- public void testSetDMSLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- DMS_LOGGING_KEY,
- DMS_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- DMS_LOGGING_KEY,
- DMS_LOGGING_TEST_VALUE,
- DMS_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveDMSLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- DMS_LOGGING_KEY,
- DMS_LOGGING_TEST_VALUE,
- DMS_LOGGING_TEST_VALUE_2);
- }
-
- // ********** EJB or Metadata Level tests **********
- public void testSetEJBOrMetadataLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- EJB_OR_METADATA_LOGGING_KEY,
- EJB_OR_METADATA_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- EJB_OR_METADATA_LOGGING_KEY,
- EJB_OR_METADATA_LOGGING_TEST_VALUE,
- EJB_OR_METADATA_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveEJBOrMetadataLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- EJB_OR_METADATA_LOGGING_KEY,
- EJB_OR_METADATA_LOGGING_TEST_VALUE,
- EJB_OR_METADATA_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Metamodel Level tests **********
- public void testSetMetamodelLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- METAMODEL_LOGGING_KEY,
- METAMODEL_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- METAMODEL_LOGGING_KEY,
- METAMODEL_LOGGING_TEST_VALUE,
- METAMODEL_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveMetamodelLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- METAMODEL_LOGGING_KEY,
- METAMODEL_LOGGING_TEST_VALUE,
- METAMODEL_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Weaver Level tests **********
- public void testSetWeaverLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- WEAVER_LOGGING_KEY,
- WEAVER_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- WEAVER_LOGGING_KEY,
- WEAVER_LOGGING_TEST_VALUE,
- WEAVER_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveWeaverLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- WEAVER_LOGGING_KEY,
- WEAVER_LOGGING_TEST_VALUE,
- WEAVER_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Properties Level tests **********
- public void testSetPropertiesLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- PROPERTIES_LOGGING_KEY,
- PROPERTIES_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- PROPERTIES_LOGGING_KEY,
- PROPERTIES_LOGGING_TEST_VALUE,
- PROPERTIES_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemovePropertiesLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- PROPERTIES_LOGGING_KEY,
- PROPERTIES_LOGGING_TEST_VALUE,
- PROPERTIES_LOGGING_TEST_VALUE_2);
- }
-
- // ********** Server Level tests **********
- public void testSetServerLoggingLevel() throws Exception {
- this.verifyModelInitialized(
- SERVER_LOGGING_KEY,
- SERVER_LOGGING_TEST_VALUE);
- this.verifySetProperty(
- SERVER_LOGGING_KEY,
- SERVER_LOGGING_TEST_VALUE,
- SERVER_LOGGING_TEST_VALUE_2);
- }
-
- public void testAddRemoveServerLoggingLevel() throws Exception {
- this.verifyAddRemoveProperty(
- SERVER_LOGGING_KEY,
- SERVER_LOGGING_TEST_VALUE,
- SERVER_LOGGING_TEST_VALUE_2);
- }
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0OptionsTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0OptionsTests.java
deleted file mode 100644
index f1e676a7b8..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0OptionsTests.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.persistence;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.eclipselink.core.v2_0.context.persistence.options.Options2_0;
-
-/**
- * EclipseLinkOptions2_0Tests
- */
-@SuppressWarnings("nls")
-public class EclipseLink2_0OptionsTests extends EclipseLink2_0PersistenceUnitTestCase
-{
- private Options2_0 options;
- private ListChangeEvent prePersistEvent;
- private ListChangeEvent preUpdateEvent;
- private ListChangeEvent preRemoveEvent;
-
- public static final String LOCK_TIMEOUT_KEY = Options2_0.PERSISTENCE_LOCK_TIMEOUT;
- public static final Integer LOCK_TIMEOUT_TEST_VALUE = 100;
- public static final Integer LOCK_TIMEOUT_TEST_VALUE_2 = 200;
-
- public static final String QUERY_TIMEOUT_KEY = Options2_0.PERSISTENCE_QUERY_TIMEOUT;
- public static final Integer QUERY_TIMEOUT_TEST_VALUE = 100;
- public static final Integer QUERY_TIMEOUT_TEST_VALUE_2 = 200;
-
- public static final String VALIDATION_GROUP_PRE_PERSIST_KEY = Options2_0.PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST;
- public static final String VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE = "test_pre-persist_group";
- public static final String VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2 = "test_2_pre-persist_group";
-
- public static final String VALIDATION_GROUP_PRE_UPDATE_KEY = Options2_0.PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE;
- public static final String VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE = "test_pre-update_group";
- public static final String VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2 = "test_2_pre-update_group";
-
- public static final String VALIDATION_GROUP_PRE_REMOVE_KEY = Options2_0.PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE;
- public static final String VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE = "test_pre-remove_group";
- public static final String VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2 = "test_2_pre-remove_group";
-
- // ********** constructors **********
- public EclipseLink2_0OptionsTests(String name) {
- super(name);
- }
-
- // ********** behavior **********
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.options = (Options2_0) this.subject.getOptions();
- PropertyChangeListener propertyChangeListener = this.buildPropertyChangeListener();
-
- this.options.addPropertyChangeListener(Options2_0.LOCK_TIMEOUT_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options2_0.QUERY_TIMEOUT_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY, propertyChangeListener);
- this.options.addPropertyChangeListener(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY, propertyChangeListener);
-
- ListChangeListener validationGroupListChangeListener = this.buildValidationGroupListChangeListener();
- this.options.addListChangeListener(Options2_0.VALIDATION_GROUP_PRE_PERSIST_LIST, validationGroupListChangeListener);
- this.options.addListChangeListener(Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST, validationGroupListChangeListener);
- this.options.addListChangeListener(Options2_0.VALIDATION_GROUP_PRE_REMOVE_LIST, validationGroupListChangeListener);
-
- this.clearEvent();
- }
-
- /**
- * Initializes directly the PersistenceUnit properties before testing.
- */
- @Override
- protected void populatePu() {
- this.modelPropertiesSizeOriginal = 5; // PersistenceUnit properties
- this.propertiesTotal = this.modelPropertiesSizeOriginal + 1; // 1 misc properties
- this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
-
- // Initializes PersistenceUnit properties
- this.persistenceUnitSetProperty(LOCK_TIMEOUT_KEY, LOCK_TIMEOUT_TEST_VALUE.toString());
- this.persistenceUnitSetProperty(QUERY_TIMEOUT_KEY, QUERY_TIMEOUT_TEST_VALUE.toString());
- this.persistenceUnitSetProperty("misc.property.3", "value.3");
-
- this.persistenceUnitSetProperty(VALIDATION_GROUP_PRE_PERSIST_KEY, VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE);
- this.persistenceUnitSetProperty(VALIDATION_GROUP_PRE_UPDATE_KEY, VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE);
- this.persistenceUnitSetProperty(VALIDATION_GROUP_PRE_REMOVE_KEY, VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE);
- }
-
- @Override
- protected PersistenceUnitProperties getModel() {
- return this.options;
- }
-
- @Override
- protected Object getProperty(String propertyName) throws NoSuchFieldException {
- Object modelValue = null;
- if (propertyName.equals(Options2_0.LOCK_TIMEOUT_PROPERTY))
- modelValue = this.options.getLockTimeout();
- else if (propertyName.equals(Options2_0.QUERY_TIMEOUT_PROPERTY))
- modelValue = this.options.getQueryTimeout();
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY)) {
- ListIterator<String> iterator = this.options.validationGroupPrePersists();
- modelValue = this.getFirstElement(iterator);
- }
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY)) {
- ListIterator<String> iterator = this.options.validationGroupPreUpdates();
- modelValue = this.getFirstElement(iterator);
- }
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY)) {
- ListIterator<String> iterator = this.options.validationGroupPreRemoves();
- modelValue = this.getFirstElement(iterator);
- }
- else
- this.throwMissingDefinition("getProperty", propertyName);
- return modelValue;
- }
-
- @Override
- protected void setProperty(String propertyName, Object newValue) throws Exception {
- if (propertyName.equals(Options2_0.LOCK_TIMEOUT_PROPERTY))
- this.options.setLockTimeout((Integer) newValue);
- else if (propertyName.equals(Options2_0.QUERY_TIMEOUT_PROPERTY))
- this.options.setQueryTimeout((Integer) newValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
- this.options.addValidationGroupPrePersist((String) newValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
- this.options.addValidationGroupPreUpdate((String) newValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
- this.options.addValidationGroupPreRemove((String) newValue);
- else
- this.throwMissingDefinition("setProperty", propertyName);
- }
-
- // ********** LockTimeout tests **********
- public void testSetLockTimeout() throws Exception {
- this.verifyModelInitialized(
- LOCK_TIMEOUT_KEY,
- LOCK_TIMEOUT_TEST_VALUE);
- this.verifySetProperty(
- LOCK_TIMEOUT_KEY,
- LOCK_TIMEOUT_TEST_VALUE,
- LOCK_TIMEOUT_TEST_VALUE_2);
- }
-
- public void testAddRemoveLockTimeout() throws Exception {
- this.verifyAddRemoveProperty(
- LOCK_TIMEOUT_KEY,
- LOCK_TIMEOUT_TEST_VALUE,
- LOCK_TIMEOUT_TEST_VALUE_2);
- }
-
- // ********** QueryTimeout tests **********
- public void testSetQueryTimeout() throws Exception {
- this.verifyModelInitialized(
- QUERY_TIMEOUT_KEY,
- QUERY_TIMEOUT_TEST_VALUE);
- this.verifySetProperty(
- QUERY_TIMEOUT_KEY,
- QUERY_TIMEOUT_TEST_VALUE,
- QUERY_TIMEOUT_TEST_VALUE_2);
- }
-
- public void testAddRemoveQueryTimeout() throws Exception {
- this.verifyAddRemoveProperty(
- QUERY_TIMEOUT_KEY,
- QUERY_TIMEOUT_TEST_VALUE,
- QUERY_TIMEOUT_TEST_VALUE_2);
- }
-
- // ********** ValidationGroupPrePersist tests **********
- public void testSetValidationGroupPrePersist() throws Exception {
- this.verifyModelInitialized(
- VALIDATION_GROUP_PRE_PERSIST_KEY,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE);
- this.verifySetValidationGroupProperty(
- Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
- VALIDATION_GROUP_PRE_PERSIST_KEY,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
- }
-
- public void testAddRemoveValidationGroupPrePersist() throws Exception {
- this.verifyAddRemoveValidationGroupProperty(
- Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
- VALIDATION_GROUP_PRE_PERSIST_KEY,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
- }
-
- public void testAddValidationGroupPrePersistCompositeValue() throws Exception {
- this.verifyAddCompositeValue(
- Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
- VALIDATION_GROUP_PRE_PERSIST_KEY,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
- }
-
- public void testRemoveValidationGroupPrePersistCompositeValue() throws Exception {
- this.verifyRemoveCompositeValue(
- Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
- VALIDATION_GROUP_PRE_PERSIST_KEY,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2);
- }
-
- // ********** ValidationGroupPreUpdate tests **********
- public void testSetValidationGroupPreUpdate() throws Exception {
- this.verifyModelInitialized(
- VALIDATION_GROUP_PRE_UPDATE_KEY,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE);
- this.verifySetValidationGroupProperty(
- Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
- VALIDATION_GROUP_PRE_UPDATE_KEY,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
- }
-
- public void testAddRemoveValidationGroupPreUpdate() throws Exception {
- this.verifyAddRemoveValidationGroupProperty(
- Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
- VALIDATION_GROUP_PRE_UPDATE_KEY,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
- }
-
- public void testAddValidationGroupPreUpdateCompositeValue() throws Exception {
- this.verifyAddCompositeValue(
- Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
- VALIDATION_GROUP_PRE_UPDATE_KEY,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
- }
-
- public void testRemoveValidationGroupPreUpdateCompositeValue() throws Exception {
- this.verifyRemoveCompositeValue(
- Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
- VALIDATION_GROUP_PRE_UPDATE_KEY,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2);
- }
-
- // ********** ValidationGroupPreRemove tests **********
- public void testSetValidationGroupPreRemove() throws Exception {
- this.verifyModelInitialized(
- VALIDATION_GROUP_PRE_REMOVE_KEY,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE);
- this.verifySetValidationGroupProperty(
- Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
- VALIDATION_GROUP_PRE_REMOVE_KEY,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
- }
-
- public void testAddRemoveValidationGroupPreRemove() throws Exception {
- this.verifyAddRemoveValidationGroupProperty(
- Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
- VALIDATION_GROUP_PRE_REMOVE_KEY,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
- }
-
- public void testAddValidationGroupPreRemoveCompositeValue() throws Exception {
- this.verifyAddCompositeValue(
- Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
- VALIDATION_GROUP_PRE_REMOVE_KEY,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
- }
-
- public void testRemoveValidationGroupPreRemoveCompositeValue() throws Exception {
- this.verifyRemoveCompositeValue(
- Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
- VALIDATION_GROUP_PRE_REMOVE_KEY,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2);
- }
-
- // ********** ValidationGroups list **********
- public void testValidationGroupsList() throws Exception {
- this.verifyListEvents(
- Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY,
- VALIDATION_GROUP_PRE_PERSIST_TEST_VALUE_2,
- Options2_0.VALIDATION_GROUP_PRE_PERSIST_LIST);
-
- this.verifyListEvents(
- Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY,
- VALIDATION_GROUP_PRE_UPDATE_TEST_VALUE_2,
- Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST);
-
- this.verifyListEvents(
- Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY,
- VALIDATION_GROUP_PRE_REMOVE_TEST_VALUE_2,
- Options2_0.VALIDATION_GROUP_PRE_REMOVE_LIST);
- }
-
- // ********** override **********
-
- @Override
- protected void clearEvent() {
- super.clearEvent();
- this.prePersistEvent = null;
- this.preUpdateEvent = null;
- this.preRemoveEvent = null;
- }
-
- // ****** convenience methods *******
-
- // ********** verify ValidationGroup property **********
- protected void verifySetValidationGroupProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- // Replace
- this.persistenceUnitSetProperty(key, testValue2, true);
- this.propertiesTotal++;
- this.verifyPutValidationGroupProperty(propertyName, testValue1);
- }
-
- @SuppressWarnings("unused")
- protected void verifyAddRemoveValidationGroupProperty(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- assertTrue(this.validationGroupValueExists(propertyName, (String)testValue1));
- // Remove
- this.clearEvent();
- --this.propertiesTotal;
- --this.modelPropertiesSize;
- this.getPersistenceUnit().removeProperty(key, (String)testValue1);
- assertFalse(this.validationGroupValueExists(propertyName, (String)testValue1));
- assertEquals(this.modelPropertiesSize, this.modelPropertiesSizeOriginal - 1);
-
- // Add original Property
- ++this.propertiesTotal;
- ++this.modelPropertiesSize;
- this.persistenceUnitSetProperty(key, testValue1, true);
- this.verifyPutValidationGroupProperty(propertyName, testValue1);
- }
-
- protected void verifyAddCompositeValue(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- String stringTestValue1 = (String)testValue1;
- String stringTestValue2 = (String)testValue2;
- assertTrue(this.validationGroupValueExists(propertyName, stringTestValue1));
- assertEquals(this.getValidationGroupSize(propertyName), 1);
- this.addValidationGroupValue(propertyName, stringTestValue2);
- assertEquals(this.getValidationGroupSize(propertyName), 2);
-
- assertTrue(this.validationGroupValueExists(propertyName, stringTestValue1));
- assertTrue(this.validationGroupValueExists(propertyName, stringTestValue2));
-
- String propertyValue = this.getPersistenceUnit().getProperty(key).getValue();
- assertTrue(propertyValue.indexOf(stringTestValue1) != -1);
- assertTrue(propertyValue.indexOf(stringTestValue2) != -1);
- }
-
- protected void verifyRemoveCompositeValue(String propertyName, String key, Object testValue1, Object testValue2) throws Exception {
- String stringTestValue1 = (String)testValue1;
- String stringTestValue2 = (String)testValue2;
- assertTrue(this.validationGroupValueExists(propertyName, stringTestValue1));
- assertEquals(this.getValidationGroupSize(propertyName), 1);
- this.addValidationGroupValue(propertyName, stringTestValue2);
- assertEquals(this.getValidationGroupSize(propertyName), 2);
-
- this.removeValidationGroupValue(propertyName, stringTestValue2);
- assertEquals(this.getValidationGroupSize(propertyName), 1);
- assertFalse(this.validationGroupValueExists(propertyName, stringTestValue2));
- String propertyValue = this.getPersistenceUnit().getProperty(key).getValue();
- assertTrue(propertyValue.indexOf(stringTestValue1) != -1);
- assertTrue(propertyValue.indexOf(stringTestValue2) == -1);
-
- this.removeValidationGroupValue(propertyName, stringTestValue2);
- assertEquals(this.getValidationGroupSize(propertyName), 1);
-
- this.removeValidationGroupValue(propertyName, stringTestValue1);
- assertEquals(this.getValidationGroupSize(propertyName), 0);
- assertFalse(this.validationGroupValueExists(propertyName, stringTestValue1));
-
- assertNull(this.getPersistenceUnit().getProperty(key));
- }
-
- protected void verifyListEvents(String propertyName, String testValue, String listName) throws Exception {
- // add
- this.clearEvent();
- this.addValidationGroupValue(propertyName, testValue);
-
- // verify event received
- assertNotNull("No Event Fired.", this.getEventFor(propertyName));
- // verify event for the expected property
- assertEquals("Wrong Event.", this.getEventFor(propertyName).getListName(), listName);
-
- // remove
- this.clearEvent();
-
- this.removeValidationGroupValue(propertyName, testValue);
- // verify event received
- assertNotNull("No Event Fired.", this.getEventFor(propertyName));
- // verify event for the expected property
- assertEquals("Wrong Event.", this.getEventFor(propertyName).getListName(), listName);
- }
-
- protected void verifyPutValidationGroupProperty(String propertyName, Object expectedValue) throws Exception {
- // verify event received
- assertNotNull("No Event Fired.", this.getEventFor(propertyName));
- // verify event value
- assertTrue(this.validationGroupValueExists(propertyName, (String) expectedValue));
- return;
- }
-
- // ********** internal method **********
-
- private ListChangeListener buildValidationGroupListChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsRemoved(ListRemoveEvent e) {
- EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsReplaced(ListReplaceEvent e) {
- EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
- }
-
- public void itemsMoved(ListMoveEvent e) {
- EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listCleared(ListClearEvent e) {
- EclipseLink2_0OptionsTests.this.throwUnsupportedOperationException(e);
- }
-
- public void listChanged(ListChangeEvent e) {
-
- EclipseLink2_0OptionsTests.this.validationGroupChanged(e);
- }
- };
- }
-
- private void validationGroupChanged(ListChangeEvent e) {
- String listName = e.getListName();
-
- if (listName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_LIST))
- this.prePersistEvent = e;
- else if (listName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_LIST))
- this.preUpdateEvent = e;
- else if (listName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_LIST))
- this.preRemoveEvent = e;
- else
- this.throwUnsupportedOperationException(e);
- }
-
- private void addValidationGroupValue(String propertyName, String propertyValue) throws NoSuchFieldException {
- if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
- this.options.addValidationGroupPrePersist(propertyValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
- this.options.addValidationGroupPreUpdate(propertyValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
- this.options.addValidationGroupPreRemove(propertyValue);
- else
- this.throwMissingDefinition("addValidationGroupValue", propertyName);
- }
-
- private void removeValidationGroupValue(String propertyName, String propertyValue) throws NoSuchFieldException {
- if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
- this.options.removeValidationGroupPrePersist(propertyValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
- this.options.removeValidationGroupPreUpdate(propertyValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
- this.options.removeValidationGroupPreRemove(propertyValue);
- else
- this.throwMissingDefinition("removeValidationGroupValue", propertyName);
- }
-
- private boolean validationGroupValueExists(String propertyName, String propertyValue) throws NoSuchFieldException {
- boolean result = false;
- if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
- result = this.options.validationGroupPrePersistExists(propertyValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
- result = this.options.validationGroupPreUpdateExists(propertyValue);
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
- result = this.options.validationGroupPreRemoveExists(propertyValue);
- else
- this.throwMissingDefinition("verifyValidationGroupValueExists", propertyName);
- return result;
- }
-
- private int getValidationGroupSize(String propertyName) throws NoSuchFieldException {
- int result = 0;
- if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
- result = this.options.validationGroupPrePersistsSize();
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
- result = this.options.validationGroupPreUpdatesSize();
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
- result = this.options.validationGroupPreRemovesSize();
- else
- this.throwMissingDefinition("verifyValidationGroupSize", propertyName);
- return result;
- }
-
- private ListChangeEvent getEventFor(String propertyName) throws NoSuchFieldException {
- ListChangeEvent event = null;
- if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_PERSIST_PROPERTY))
- event = this.prePersistEvent;
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_UPDATE_PROPERTY))
- event = this.preUpdateEvent;
- else if (propertyName.equals(Options2_0.VALIDATION_GROUP_PRE_REMOVE_PROPERTY))
- event = this.preRemoveEvent;
- else
- this.throwMissingDefinition("getEventFor", propertyName);
- return event;
- }
-
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java
deleted file mode 100644
index ddb5fa737e..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/EclipseLink2_0PersistenceUnitTestCase.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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.eclipselink.core.tests.internal.v2_0.context.persistence;
-
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.JpaFacet;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.jpa.core.tests.internal.context.persistence.PersistenceUnitTestCase;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.core.platform.EclipseLinkPlatform;
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-
-/**
- * EclipseLink2_0PersistenceUnitTestCase
- */
-public abstract class EclipseLink2_0PersistenceUnitTestCase extends PersistenceUnitTestCase
-{
- protected EclipseLinkPersistenceUnit subject;
-
- protected PropertyValueModel<EclipseLinkPersistenceUnit> subjectHolder;
-
- // ********** constructors **********
- protected EclipseLink2_0PersistenceUnitTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject = this.getPersistenceUnit();
- this.subjectHolder = new SimplePropertyValueModel<EclipseLinkPersistenceUnit>(this.subject);
- this.populatePu();
- }
-
- @Override
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = super.buildJpaConfigDataModel();
- dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaFacet.VERSION_2_0.getVersionString());
- dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, EclipseLinkPlatform.VERSION_2_0);
- return dataModel;
- }
-
- @Override
- protected EclipseLinkPersistenceUnit getPersistenceUnit() {
- return (EclipseLinkPersistenceUnit) super.getPersistenceUnit();
- }
-
-} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/JptEclipseLink2_0CorePersistenceContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/JptEclipseLink2_0CorePersistenceContextModelTests.java
deleted file mode 100644
index 167c8c2002..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/v2_0/context/persistence/JptEclipseLink2_0CorePersistenceContextModelTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2010 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.eclipselink.core.tests.internal.v2_0.context.persistence;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptEclipseLink2_0CorePersistenceContextModelTests
-{
- public static Test suite() {
- TestSuite suite = new TestSuite(JptEclipseLink2_0CorePersistenceContextModelTests.class.getPackage().getName());
-
- suite.addTestSuite(EclipseLink2_0ConnectionTests.class);
- suite.addTestSuite(EclipseLink2_0LoggingTests.class);
- suite.addTestSuite(EclipseLink2_0OptionsTests.class);
-
- return suite;
- }
-
- private JptEclipseLink2_0CorePersistenceContextModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/test.xml b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/test.xml
deleted file mode 100644
index 9b3b5db533..0000000000
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/test.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0"?> <!--
- Copyright (c) 2008, 2010 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 -->
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <echo message="basedir ${basedir}" />
- <echo message="eclipse place ${eclipse-home}" />
- <!-- sets the properties plugin-name -->
- <property name="plugin-name" value="org.eclipse.jpt.jpa.eclipselink.core.tests"/>
- <echo level="debug" message="testRoot: ${testRoot}" />
- <fail message="testRoot must be set" unless="testRoot" />
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite1">
- <property file="${testRoot}/testServer.properties"/>
- <property name="jpt-folder" value="${eclipse-home}/jpt_folder"/>
- <delete dir="${jpt-folder}" quiet="true"/>
-
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jpt-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jpt.jpa.eclipselink.core.tests.internal.resource.JptJpaEclipselinkCoreResourceModelTests" />
- <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
- <property name="extraVMargs" value="-Dorg.eclipse.jpt.jpa.jar=${testDir}/${jpt-persistence-jar} -Dorg.eclipse.jpt.eclipselink.jar=${testDir}/${jpt-eclipselink-jar}"/>
- </ant>
- </target>
- <target name="suite2"> <property file="${testRoot}/testServer.properties"/> <property name="jpt-folder" value="${eclipse-home}/jpt_folder"/> <delete dir="${jpt-folder}" quiet="true"/> <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> <property name="data-dir" value="${jpt-folder}"/> <property name="plugin-name" value="${plugin-name}"/> <property name="classname" value="org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.JptJpaEclipseLinkCoreContextModelTests" /> <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/> <property name="extraVMargs" value="-Dorg.eclipse.jpt.jpa.jar=${testDir}/${jpt-persistence-jar} -Dorg.eclipse.jpt.eclipselink.jar=${testDir}/${jpt-eclipselink-jar}"/> </ant> </target>
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init, suite1, suite2, cleanup">
- </target>
-</project> \ No newline at end of file

Back to the top