src/test/java/ru/indvdum/jpa/tests/AbstractJPAEntityTest.groovy
changeset 15 7d8a7e7635d2
parent 14 22646fd200c5
child 20 a05948e9458c
equal deleted inserted replaced
14:22646fd200c5 15:7d8a7e7635d2
   160 			newValue = (long) uniqueValue++ % Long.MAX_VALUE + 1L
   160 			newValue = (long) uniqueValue++ % Long.MAX_VALUE + 1L
   161 		} else if(type.toString() == 'float' || type == Float) {
   161 		} else if(type.toString() == 'float' || type == Float) {
   162 			newValue = (float) uniqueValue++ % Float.MAX_VALUE + 1f
   162 			newValue = (float) uniqueValue++ % Float.MAX_VALUE + 1f
   163 		} else if(type.toString() == 'double' || type == Double) {
   163 		} else if(type.toString() == 'double' || type == Double) {
   164 			newValue = (double) uniqueValue++ % Double.MAX_VALUE + 1d
   164 			newValue = (double) uniqueValue++ % Double.MAX_VALUE + 1d
       
   165 		} else if(Number.class.isAssignableFrom(type)) {
       
   166 			// trying to use constructor with int argument
       
   167 			newValue = type.newInstance(uniqueValue++ % Byte.MAX_VALUE + 1i)
   165 		} else if(type == String.class) {
   168 		} else if(type == String.class) {
   166 			newValue = (String) "test${uniqueValue++}"
   169 			newValue = (String) "test${uniqueValue++}"
   167 		} else if(type instanceof Class && (type as Class).annotations.find {it instanceof Entity} != null) { // modifying of a primary keys is deprecated
   170 		} else if(type instanceof Class && (type as Class).annotations.find {it instanceof Entity} != null) { // modifying of a primary keys is deprecated
   168 			// an attempt to use already created entities
   171 			// an attempt to use already created entities
   169 			def currentValue = getFieldValue(entity, field)
   172 			def currentValue = getFieldValue(entity, field)