Support of auto-generating other Number field types, like BigDecimal
authorindvdum (gotoindvdum[at]gmail[dot]com)
Sat, 24 Nov 2012 16:11:35 +0400
changeset 157d8a7e7635d2
parent 14 22646fd200c5
child 16 409046072775
Support of auto-generating other Number field types, like BigDecimal
src/test/java/ru/indvdum/jpa/tests/AbstractJPAEntityTest.groovy
     1.1 --- a/src/test/java/ru/indvdum/jpa/tests/AbstractJPAEntityTest.groovy	Sat Nov 24 15:58:22 2012 +0400
     1.2 +++ b/src/test/java/ru/indvdum/jpa/tests/AbstractJPAEntityTest.groovy	Sat Nov 24 16:11:35 2012 +0400
     1.3 @@ -162,6 +162,9 @@
     1.4  			newValue = (float) uniqueValue++ % Float.MAX_VALUE + 1f
     1.5  		} else if(type.toString() == 'double' || type == Double) {
     1.6  			newValue = (double) uniqueValue++ % Double.MAX_VALUE + 1d
     1.7 +		} else if(Number.class.isAssignableFrom(type)) {
     1.8 +			// trying to use constructor with int argument
     1.9 +			newValue = type.newInstance(uniqueValue++ % Byte.MAX_VALUE + 1i)
    1.10  		} else if(type == String.class) {
    1.11  			newValue = (String) "test${uniqueValue++}"
    1.12  		} else if(type instanceof Class && (type as Class).annotations.find {it instanceof Entity} != null) { // modifying of a primary keys is deprecated