Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue - 44 - Correction related to generating short #46

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final String getFieldType() {

@Override
public final String getFunctionType() {
return "shortType";
return "integerType";
}

@Override
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/templateDslBuilder.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
<#else>
pactDslJsonBody.${field.functionByType}("${field.name}", "${field.formatValue?no_esc}", ${field.name}.toInstant());
</#if>
<#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>
Expand Down
Loading