Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316358

Summary: JPA2: Metamodel - increase code coverage from 79%
Product: z_Archived Reporter: Michael OBrien <michael.f.obrien>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.orm-inbox
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 266912    
Bug Blocks:    

Description Michael OBrien CLA 2010-06-09 15:11:13 EDT
>general concurrency issues with object publishing in the constructors
>Code coverage results below illustrate test coverage that is missing as follows
>AttributeImpl.java

>Method level accessors (everything is field access in the model)
  97  12      public Member getJavaMember() {
  98  12          AttributeAccessor accessor = getMapping().getAttributeAccessor();
 100  12          if (accessor.isMethodAttributeAccessor()) {
 101  0              return ((MethodAttributeAccessor) accessor).getGetMethod();
 
>@ManyToMany mapping
 198  22          if (mapping.isManyToManyMapping()) {
 199                 // Check for a OneToMany on a MappedSuperclass being processed internally as a ManyToMany 
 200  4              if(((ManyToManyMapping)mapping).isDefinedAsOneToManyMapping()) {
 201  4                  return PersistentAttributeType.ONE_TO_MANY;
 202                 } else { 
 203                     // Test coverage required 
 204  0                  return PersistentAttributeType.MANY_TO_MANY;
 
>@ElementCollection mapping
 215  0          return PersistentAttributeType.ELEMENT_COLLECTION;
 
>BasicTypeImpl.java
 70         protected boolean isIdentifiableType() { 

>CollectionAttributeImpl.java
 52  0      protected CollectionAttributeImpl(ManagedTypeImpl<X> managedType, CollectionMapping mapping) {
 
>IdentifiableTypeImpl.java
  
 179  32      public <Y> SingularAttribute<? super X, Y> getId(Class<Y> type) {
 182  32          if(!hasSingleIdAttribute()) {
 183                 // Id is part of an IdClass 
 184  0              throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
 

 228  0              if (pkMappings.size() == 1) {
 229  0                  Class aClass = pkMappings.get(0).getAttributeClassification(); // null for OneToOneMapping
 230                     // lookup class in our types map 
 231  0                  return this.metamodel.getType(aClass);
 
 265  16      public <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type) {
 266             // Lazy load the version attribute if it exists 
 267  16          if(null == getVersion()) {
 268                 // No version exists - throw IAE 
 269  0              throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
 270                     "metamodel_identifiable_no_version_attribute_present",  
 271                     new Object[] { this })); 

>test IdentifiableType without an Id (actually invalid)
 308  64      public boolean hasSingleIdAttribute() {
 324  64          if(pkFields.isEmpty()) {
 330  32                  pkClass = ((CMP3Policy)this.getDescriptor().getCMPPolicy()).getPKClass();
 331  32                  if(null == pkClass) {
 

>CollectionAttributeImpl.java
 171  16      public CollectionAttribute<? super X, ?> getCollection(String name) {
 180  16          if(null == anAttribute) {
 
 181  0              throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
 
>a collection that is actually returned (non-variant test)
 362  24      public <E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType) {
 370  0          return anAttribute;
 
 489  0      public ListAttribute<X, ?> getDeclaredList(String name) {
 508  0      public MapAttribute<X, ?, ?> getDeclaredMap(String name) {
 573  0      public <E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType) {
 679  4      private ListAttribute<? super X, ?> getList(String name, boolean performNullCheck) {
 686  4          if(performNullCheck && null == anAttribute) {
 
 687  0              throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
 
 808  8      public <K, V> MapAttribute<? super X, K, V> getMap(String name, Class<K> keyType, Class<V> valueType) {
 809  8          MapAttribute<? super X, K, V> anAttribute = (MapAttribute<? super X, K, V>)this.getMap(name);
 810  8          Class<V> aClass = anAttribute.getElementType().getJavaType();
 811  8          if(valueType != aClass) {
 812  0              throw new IllegalArgumentException(ExceptionLocalization.buildMessage(
 
>test other boxed types besides int and double
 912  24      private boolean isAutoboxedType(Class targetPrimitiveOrWrapperClass, Class actualPrimitiveOrWrapperClass) {
 
>null getMethodName in
 1123  22179      protected void initialize() { // Future: Check all is*Policy() calls
 1223  137                                  String getMethodName = ((MethodAttributeAccessor)colMapping.getAttributeAccessor()).getGetMethodName();
 1224  137                                  if(null == getMethodName) {
 
 1390             // 5) Special processing for MappedSuperclass hierarchies 
 1391             // MappedSuperclasses need special handling to get their type from an inheriting subclass 
 1392  5314          if(null == aField && null == aType && this.isMappedSuperclass()) {
 1393                 // get inheriting subtype member (without handling @override annotations) 
 1394  0              MappedSuperclassTypeImpl aMappedSuperclass = ((MappedSuperclassTypeImpl)this);
 1395  0              AttributeImpl inheritingTypeMember = aMappedSuperclass.getMemberFromInheritingType(mapping.getAttributeName());
 1396  0              aField = ((InstanceVariableAttributeAccessor)inheritingTypeMember.getMapping().getAttributeAccessor()).getAttributeField(); 

>MapAttributeImpl.java

>null policyKeyType in the constructor
 177  4486          if(null == policyKeyType) {
 178                 // Pending reproduction case: @MapKey private Map<K,V> // no name column specified and the PK is defined by a method 
 179  0              if(null == javaClass) {
 180  0                  if(policy.isMappedKeyMapPolicy()) {
 181                         // See UC10, UC11 
 182  0                      javaClass = getOwningPKTypeWhenMapKeyAnnotationMissingOrDefaulted(
 183                                 (MappedKeyMapContainerPolicy)policy); 


 210  0      private Class getOwningPKTypeWhenMapKeyAnnotationMissingOrDefaulted(MappedKeyMapContainerPolicy policy) {
   
>PluralAttributeImpl.java
>constructor MapKeyMapping
 102  402              } else if(mapping.isMapKeyMapping()) {                   
 103  0                  ContainerPolicy policy = mapping.getContainerPolicy();
 104  0                  if (policy.isMapPolicy()) {
 105  0                    MapContainerPolicy mapPolicy = (MapContainerPolicy) mapping.getContainerPolicy();
 106  0                      attributeClass = mapPolicy.getElementClass();
 107                     } else { 
 108                         // TODO: refactor: default to the managedType 
 109  0                      attributeClass = managedType.getJavaType();
 
 155  0      public CollectionMapping getCollectionMapping() {
 
>SingularAttributeImpl.java
>constructor validation=false
 101  148                  if(validationEnabled) {
 
>null elementType
 201         public Class<T> getJavaType() { 
 202  620          if(null == elementType) {
 203  0              Class aJavaType = getMapping().getAttributeClassification();
Comment 1 Michael OBrien CLA 2010-11-30 11:06:46 EST
>We are at 80% - more coverage of error handling and [unwritten] else clauses is no longer efficient
- we have better coverage than the entire product (62.2%) and
org.eclipse.persistence (62.2%)
- the jpa subproject
org.eclipse.persistence.internal.jpa (72.5%)


org.eclipse.persistence (62.2%)
org.eclipse.persistence.internal.jpa (72.5%)
org.eclipse.persistence.internal.jpa.metamodel (80%)

Classes
AttributeImpl (87.6%)
BasicTypeImpl (85.7%)
CollectionAttributeImpl (75%)
EmbeddableTypeImpl (100%)
EntityTypeImpl (100%)
IdentifiableTypeImpl (80.5%)
ListAttributeImpl (100%)
ManagedTypeImpl (79%)
MapAttributeImpl (52.5%)
MappedSuperclassTypeImpl (100%)
MetamodelImpl (89.9%)
PluralAttributeImpl (80.4%)
SetAttributeImpl (50%)
SingularAttributeImpl (66.7%)
TypeImpl (84.6%)
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:14:40 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:23:58 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink