src/test/java/ru/indvdum/jpa/tests/AbstractJPAEntityTest.groovy
changeset 14 22646fd200c5
parent 10 7241826f43f6
child 15 7d8a7e7635d2
equal deleted inserted replaced
13:bfcb605c25ef 14:22646fd200c5
   168 			// an attempt to use already created entities
   168 			// an attempt to use already created entities
   169 			def currentValue = getFieldValue(entity, field)
   169 			def currentValue = getFieldValue(entity, field)
   170 			newValue = toRemove.find {it.class == type && it != currentValue}
   170 			newValue = toRemove.find {it.class == type && it != currentValue}
   171 			if(newValue == null)
   171 			if(newValue == null)
   172 				newValue = createEntity(type as Class)
   172 				newValue = createEntity(type as Class)
       
   173 		} else if(Enum.class.isAssignableFrom(type)) {
       
   174 			def values = type.values();
       
   175 			newValue = values[uniqueValue++ % values.size()];
   173 		} else if(
   176 		} else if(
   174 				type instanceof Class 
   177 				type instanceof Class 
   175 				&& !(
   178 				&& !(
   176 					field.clazz.annotations.find {it instanceof IdClass} != null 
   179 					field.clazz.annotations.find {it instanceof IdClass} != null 
   177 					&& field.declaredAnnotations.find {it instanceof Id} != null
   180 					&& field.declaredAnnotations.find {it instanceof Id} != null