diff --git a/pom.xml b/pom.xml index c299803..76c453b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.sngular pact-annotation-processor - 1.1.6 + 1.1.7 PactDslBuilder - Annotation Processor Pact DSL Builder annotation processor. diff --git a/src/main/java/com/sngular/annotation/processor/mapping/ShortMapping.java b/src/main/java/com/sngular/annotation/processor/mapping/ShortMapping.java index 0b8f2fa..aa33e8a 100644 --- a/src/main/java/com/sngular/annotation/processor/mapping/ShortMapping.java +++ b/src/main/java/com/sngular/annotation/processor/mapping/ShortMapping.java @@ -24,7 +24,7 @@ public final String getFieldType() { @Override public final String getFunctionType() { - return "shortType"; + return "integerType"; } @Override @@ -36,12 +36,15 @@ public final String getFunctionOnlyValue() { public final Integer getRandomDefaultValue(final FieldValidations fieldValidations) { final int randomDefaultValue; if (Objects.nonNull(fieldValidations) && ObjectUtils.anyNotNull(fieldValidations.getMin(), fieldValidations.getMax())) { - final int minValue = ObjectUtils.defaultIfNull(fieldValidations.getMin(), (int) Byte.MIN_VALUE); - final int maxValue = ObjectUtils.defaultIfNull(fieldValidations.getMax(), (int) Byte.MAX_VALUE); + int minValue = ObjectUtils.defaultIfNull(fieldValidations.getMin(), (int) Short.MIN_VALUE); + minValue = minValue < Short.MIN_VALUE ? minValue : Short.MIN_VALUE; + + int maxValue = ObjectUtils.defaultIfNull(fieldValidations.getMax(), (int) Short.MAX_VALUE); + maxValue = maxValue > Short.MAX_VALUE ? maxValue : Short.MAX_VALUE; randomDefaultValue = uniformRandomProvider.nextInt(minValue, maxValue); } else { - randomDefaultValue = uniformRandomProvider.nextInt(0, Integer.MAX_VALUE); + randomDefaultValue = uniformRandomProvider.nextInt(Short.MIN_VALUE, Short.MAX_VALUE); } return randomDefaultValue; diff --git a/src/main/resources/templates/templateDslBuilder.ftlh b/src/main/resources/templates/templateDslBuilder.ftlh index 2e259a9..7532c23 100644 --- a/src/main/resources/templates/templateDslBuilder.ftlh +++ b/src/main/resources/templates/templateDslBuilder.ftlh @@ -101,6 +101,8 @@ <#else> pactDslJsonBody.${field.functionByType}("${field.name}", "${field.formatValue?no_esc}", ${field.name}.toInstant()); + <#elseif field.fieldType == "short"> + pactDslJsonBody.${field.functionByType}("${field.name}", (int) ${field.name}); <#elseif field.fieldType == "BigInteger"> pactDslJsonBody.${field.functionByType}("${field.name}", ${field.name}.intValue()); <#else>