diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java index 2869127e..e2eb18fd 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/helpers/NamingHelper.java @@ -21,6 +21,7 @@ import static org.apache.commons.lang3.StringUtils.upperCase; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -57,6 +58,14 @@ public class NamingHelper { private static final String ILLEGAL_CHARACTER_REGEX = "[^0-9a-zA-Z_$]"; + private static final String KEYWORDS[] = { "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", + "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float", "for", "goto", "if", + "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", + "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", + "true", "try", "void", "volatile", "while" }; + + private static List keywordsList; + private static NameHelper cachedNameHelper; private static NameHelper getNameHelper() { @@ -217,7 +226,7 @@ public static String cleanLeadingAndTrailingNewLineAndChars(String input) { * @return The name for this using Java class convention */ public static String convertToClassName(String clazz) { - return StringUtils.capitalize(cleanNameForJava(clazz)); + return StringUtils.capitalize(cleanNameForJava(clazz, false)); } /** @@ -330,7 +339,7 @@ public static String pluralize(String target) { * @return A name suitable for a Java parameter */ public static String getParameterName(String name) { - return StringUtils.uncapitalize(cleanNameForJava(name)); + return filterKeywords(StringUtils.uncapitalize(cleanNameForJava(name))); } /** @@ -341,6 +350,11 @@ public static String getParameterName(String name) { * @return cleaned string */ public static String cleanNameForJava(String resourceName) { + + return cleanNameForJava(resourceName, true); + } + + private static String cleanNameForJava(String resourceName, boolean filterKeywords) { String outString = resourceName; if (StringUtils.hasText(resourceName)) { outString = getNameHelper().replaceIllegalCharacters(resourceName); @@ -348,7 +362,19 @@ public static String cleanNameForJava(String resourceName) { outString = getNameHelper().normalizeName(outString); } } - return outString; + + if (!filterKeywords) { + return outString; + } + + return filterKeywords(outString); + } + + public static String filterKeywords(String name) { + if (getKeywords().contains(name)) { + return name + "Custom"; + } + return name; } /** @@ -375,7 +401,7 @@ public static String cleanNameForJavaEnum(String enumConstant) { enumName = "_" + enumName; } - return enumName; + return filterKeywords(enumName); } private static boolean doesUriEndsWithParam(String uri) { @@ -632,4 +658,11 @@ public static String getDefaultModelPackage() { return ".model"; } + private static List getKeywords() { + if (keywordsList == null || keywordsList.isEmpty()) { + keywordsList = Arrays.asList(KEYWORDS); + } + return keywordsList; + } + } diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java index dba6d107..ff1775e2 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/basic/MethodParamsRule.java @@ -15,6 +15,8 @@ import static com.phoenixnap.oss.ramlplugin.raml2code.helpers.CodeModelHelper.findFirstClassBySimpleName; import static org.springframework.util.StringUtils.uncapitalize; +import java.math.BigDecimal; +import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -174,7 +176,15 @@ protected JVar paramQueryForm(ApiParameterMetadata paramMetaData, CodeModelHelpe } protected JVar paramObjects(ApiActionMetadata endpointMetadata, CodeModelHelper.JExtMethod generatableType) { + String requestBodyName = endpointMetadata.getRequestBody().getName(); + String requestBodyFullName = requestBodyName; + if (BigDecimal.class.getSimpleName().equals(requestBodyName)) { + requestBodyFullName = BigDecimal.class.getName(); + } else if (BigInteger.class.getSimpleName().equals(requestBodyName)) { + requestBodyFullName = BigInteger.class.getName(); + } + boolean array = endpointMetadata.getRequestBody().isArray(); List codeModels = new ArrayList<>(); @@ -186,15 +196,15 @@ protected JVar paramObjects(ApiActionMetadata endpointMetadata, CodeModelHelper. codeModels.add(generatableType.owner()); } - JClass requestBodyType = findFirstClassBySimpleName(codeModels.toArray(new JCodeModel[codeModels.size()]), requestBodyName); + JClass requestBodyType = findFirstClassBySimpleName(codeModels.toArray(new JCodeModel[codeModels.size()]), requestBodyFullName); if (allowArrayParameters && array) { JClass arrayType = generatableType.owner().ref(List.class); requestBodyType = arrayType.narrow(requestBodyType); } if (addParameterJavadoc) { - generatableType.get().javadoc().addParam(uncapitalize(requestBodyName) + " The Request Body Payload"); + generatableType.get().javadoc().addParam(NamingHelper.getParameterName(requestBodyName) + " The Request Body Payload"); } - JVar param = generatableType.get().param(requestBodyType, uncapitalize(requestBodyName)); + JVar param = generatableType.get().param(requestBodyType, NamingHelper.getParameterName(requestBodyName)); if (Config.getPojoConfig().isIncludeJsr303Annotations() && !RamlActionType.PATCH.equals(endpointMetadata.getActionType())) { // skip Valid annotation for PATCH actions since it's a partial // update so some required fields might be omitted diff --git a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/spring/SpringRestClientMethodBodyRule.java b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/spring/SpringRestClientMethodBodyRule.java index d2e84643..535082c4 100644 --- a/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/spring/SpringRestClientMethodBodyRule.java +++ b/src/main/java/com/phoenixnap/oss/ramlplugin/raml2code/rules/spring/SpringRestClientMethodBodyRule.java @@ -32,6 +32,7 @@ import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiActionMetadata; import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiParameterMetadata; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.CodeModelHelper; +import com.phoenixnap.oss.ramlplugin.raml2code.helpers.NamingHelper; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RamlHelper; import com.phoenixnap.oss.ramlplugin.raml2code.helpers.RuleHelper; import com.phoenixnap.oss.ramlplugin.raml2code.plugin.Config; @@ -152,7 +153,7 @@ public JMethod apply(ApiActionMetadata endpointMetadata, CodeModelHelper.JExtMet JInvocation init = JExpr._new(httpEntityClass); if (endpointMetadata.getRequestBody() != null) { - init.arg(methodParamMap.get(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, endpointMetadata.getRequestBody().getName()))); + init.arg(methodParamMap.get(NamingHelper.getParameterName(endpointMetadata.getRequestBody().getName()))); } init.arg(httpHeaders); diff --git a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue152RulesTest.java b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue152RulesTest.java new file mode 100644 index 00000000..d2c3f09c --- /dev/null +++ b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue152RulesTest.java @@ -0,0 +1,60 @@ +package com.phoenixnap.oss.ramlplugin.raml2code.github; + +import org.junit.Before; +import org.junit.Test; + +import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiResourceMetadata; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.Config; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.ConfigurableRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.GitHubAbstractRuleTestBase; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerDecoratorRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerInterfaceRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4RestTemplateClientRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.TestPojoConfig; +import com.sun.codemodel.JCodeModel; +import com.sun.codemodel.JDefinedClass; + +/** + * @author aleksandars + * @since 2.0.4 + */ +public class Issue152RulesTest extends GitHubAbstractRuleTestBase { + + private ConfigurableRule rule; + + @Before + public void init() { + super.setGitHubValidatorBase(DEFAULT_GITHUB_VALIDATOR_BASE + "issue-152/"); + } + + @Test + public void collision_java_keywords_decorator() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-152.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue152-Spring4ControllerDecorator"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void collision_java_keywords_interface() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-152.raml"); + rule = new Spring4ControllerInterfaceRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue152-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void collision_java_keywords_client() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-152.raml"); + rule = new Spring4RestTemplateClientRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue152-Spring4RestTemplateClient"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + +} \ No newline at end of file diff --git a/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue288RulesTest.java b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue288RulesTest.java new file mode 100644 index 00000000..b6dccb5e --- /dev/null +++ b/src/test/java/com/phoenixnap/oss/ramlplugin/raml2code/github/Issue288RulesTest.java @@ -0,0 +1,335 @@ +package com.phoenixnap.oss.ramlplugin.raml2code.github; + +import static com.phoenixnap.oss.ramlplugin.raml2code.rules.spring.SpringConfigurableRule.CALLABLE_RESPONSE_CONFIGURATION; +import static com.phoenixnap.oss.ramlplugin.raml2code.rules.spring.SpringConfigurableRule.SIMPLE_RETURN_TYPES; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +import com.phoenixnap.oss.ramlplugin.raml2code.data.ApiResourceMetadata; +import com.phoenixnap.oss.ramlplugin.raml2code.plugin.Config; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.ConfigurableRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.GitHubAbstractRuleTestBase; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerDecoratorRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerInterfaceRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4ControllerStubRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.Spring4RestTemplateClientRule; +import com.phoenixnap.oss.ramlplugin.raml2code.rules.TestPojoConfig; +import com.sun.codemodel.JCodeModel; +import com.sun.codemodel.JDefinedClass; + +/** + * @author aleksandars + * @since 2.0.4 + */ +public class Issue288RulesTest extends GitHubAbstractRuleTestBase { + + private ConfigurableRule rule; + + @Before + public void init() { + super.setGitHubValidatorBase(DEFAULT_GITHUB_VALIDATOR_BASE + "issue-288/"); + } + + @Test + public void validate_basic_interface_rule_decimal() throws Exception { + + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerInterfaceRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_interface_rule_integer() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerInterfaceRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigInteger-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_basic_interface_rule_decimal_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerInterfaceRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Format-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_interface_rule_decimal_integer_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerInterfaceRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-BigInteger-Format-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_callable_interface_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerInterfaceRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Callable-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_callable_interface_rule_integer() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerInterfaceRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigInteger-Callable-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_callable_interface_rule_decimal_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerInterfaceRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Callable-Format-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_callable_interface_rule_decimal_integer_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerInterfaceRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerInterface"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_simple_return_type_interface_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerInterfaceRule(); + + Map configuration = new HashMap<>(); + configuration.put(SIMPLE_RETURN_TYPES, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Simple-Spring4ControllerInterface"); + } + + @Test + public void validate_basic_decorator_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Spring4ControllerDecoratorRule"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_decorator_rule_integer() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigInteger-Spring4ControllerDecoratorRule"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_basic_decorator_rule_decimal_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Format-Spring4ControllerDecoratorRule"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_decorator_rule_decimal_integer_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerDecoratorRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-BigInteger-Format-Spring4ControllerDecoratorRule"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_callable_decorator_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerDecoratorRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Callable-Spring4ControllerDecorator"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_callable_decorator_rule_integer() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerDecoratorRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigInteger-Callable-Spring4ControllerDecorator"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_callable_decorator_rule_decimal_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerDecoratorRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Callable-Format-Spring4ControllerDecorator"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_callable_decorator_rule_decimal_integer_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4ControllerDecoratorRule(); + + Map configuration = new HashMap<>(); + configuration.put(CALLABLE_RESPONSE_CONFIGURATION, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerDecorator"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_simple_return_type_decorator_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerDecoratorRule(); + + Map configuration = new HashMap<>(); + configuration.put(SIMPLE_RETURN_TYPES, "true"); + rule.applyConfiguration(configuration); + + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Simple-Spring4ControllerDecorator"); + } + + @Test + public void validate_basic_client_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4RestTemplateClientRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Spring4RestTemplateClient"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_client_rule_integer() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4RestTemplateClientRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigInteger-Spring4RestTemplateClient"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_basic_client_rule_decimal_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4RestTemplateClientRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Format-Spring4RestTemplateClient"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_client_rule_decimal_integer_format() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-2.raml"); + rule = new Spring4RestTemplateClientRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-BigInteger-Format-Spring4RestTemplateClient"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } + + @Test + public void validate_basic_stub_rule_decimal() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerStubRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigDecimal-Spring4ControllerStub"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigDecimals(false); + } + + @Test + public void validate_basic_stub_rule_integer() throws Exception { + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(true); + loadRaml("issue-288-1.raml"); + rule = new Spring4ControllerStubRule(); + rule.apply(getControllerMetadata(), jCodeModel); + verifyGeneratedCode("Issue288-BigInteger-Spring4ControllerStub"); + ((TestPojoConfig) Config.getPojoConfig()).setUseBigIntegers(false); + } +} \ No newline at end of file diff --git a/src/test/resources/ramls/github/issue-152.raml b/src/test/resources/ramls/github/issue-152.raml new file mode 100644 index 00000000..f6bf9094 --- /dev/null +++ b/src/test/resources/ramls/github/issue-152.raml @@ -0,0 +1,50 @@ +#%RAML 1.0 +title: Collision with java keywords #152 + +types: + import: + type: object + properties: + amount: + type: number + required: false + description: | + Monetary amount. + currency: + type: string + required: false + description: | + String based on ISO-4217 for specifying the currency related to the amount. + integer: + type: integer + required: false + while: string + super: number + +/break: + post: + queryParameters: + long: number + boolean: boolean + body: + application/json: + type: import + responses: + 201: + body: + application/json: + type: import + /{byte}: + uriParameters: + byte: + type: number + get: + queryParameters: + return: date-only + void: string + default: number + responses: + 200: + body: + application/json: + type: import[] \ No newline at end of file diff --git a/src/test/resources/ramls/github/issue-288-1.raml b/src/test/resources/ramls/github/issue-288-1.raml new file mode 100644 index 00000000..4c28491e --- /dev/null +++ b/src/test/resources/ramls/github/issue-288-1.raml @@ -0,0 +1,10 @@ +#%RAML 1.0 +title: Import Statement for BigDecimal/BigInteger not generated for request body #288 +version: 1.0 + +/number: + post: + description: Returns the winning number. + body: + application/json: + type: number diff --git a/src/test/resources/ramls/github/issue-288-2.raml b/src/test/resources/ramls/github/issue-288-2.raml new file mode 100644 index 00000000..83cc92a1 --- /dev/null +++ b/src/test/resources/ramls/github/issue-288-2.raml @@ -0,0 +1,11 @@ +#%RAML 1.0 +title: Import Statement for BigDecimal/BigInteger not generated for request body #288 +version: 1.0 + +/number: + post: + description: Returns the winning number. + body: + application/json: + type: number + format: long \ No newline at end of file diff --git a/src/test/resources/validations/github/issue-152/Issue152-Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/issue-152/Issue152-Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..1303f27a --- /dev/null +++ b/src/test/resources/validations/github/issue-152/Issue152-Spring4ControllerDecorator.java.txt @@ -0,0 +1,286 @@ +-----------------------------------com.gen.test.model.Import.java----------------------------------- + +package com.gen.test.model; + +import java.io.Serializable; +import java.math.BigInteger; +import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class Import implements Serializable +{ + + /** + * Monetary amount. + * + * + */ + protected Double amount; + /** + * String based on ISO-4217 for specifying the currency related to the amount. + * + * + */ + protected String currency; + protected BigInteger integer; + @JsonProperty("while") + protected String whileCustom; + @JsonProperty("super") + protected Double superCustom; + + /** + * Creates a new Import. + * + */ + public Import() { + super(); + } + + /** + * Creates a new Import. + * + */ + public Import(Double amount, String currency, BigInteger integer, String whileCustom, Double superCustom) { + super(); + this.amount = amount; + this.currency = currency; + this.integer = integer; + this.whileCustom = whileCustom; + this.superCustom = superCustom; + } + + /** + * Returns the amount. + * + * @return + * amount + */ + public Double getAmount() { + return amount; + } + + /** + * Set the amount. + * + * @param amount + * the new amount + */ + public void setAmount(Double amount) { + this.amount = amount; + } + + /** + * Returns the currency. + * + * @return + * currency + */ + public String getCurrency() { + return currency; + } + + /** + * Set the currency. + * + * @param currency + * the new currency + */ + public void setCurrency(String currency) { + this.currency = currency; + } + + /** + * Returns the integer. + * + * @return + * integer + */ + public BigInteger getInteger() { + return integer; + } + + /** + * Set the integer. + * + * @param integer + * the new integer + */ + public void setInteger(BigInteger integer) { + this.integer = integer; + } + + /** + * Returns the whileCustom. + * + * @return + * whileCustom + */ + @NotNull + public String getWhileCustom() { + return whileCustom; + } + + /** + * Set the whileCustom. + * + * @param whileCustom + * the new whileCustom + */ + public void setWhileCustom(String whileCustom) { + this.whileCustom = whileCustom; + } + + /** + * Returns the superCustom. + * + * @return + * superCustom + */ + @NotNull + public Double getSuperCustom() { + return superCustom; + } + + /** + * Set the superCustom. + * + * @param superCustom + * the new superCustom + */ + public void setSuperCustom(Double superCustom) { + this.superCustom = superCustom; + } + + public int hashCode() { + return new HashCodeBuilder().append(amount).append(currency).append(integer).append(whileCustom).append(superCustom).toHashCode(); + } + + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if (this.getClass()!= other.getClass()) { + return false; + } + Import otherObject = ((Import) other); + return new EqualsBuilder().append(amount, otherObject.amount).append(currency, otherObject.currency).append(integer, otherObject.integer).append(whileCustom, otherObject.whileCustom).append(superCustom, otherObject.superCustom).isEquals(); + } + + public String toString() { + return new ToStringBuilder(this).append("amount", amount).append("currency", currency).append("integer", integer).append("whileCustom", whileCustom).append("superCustom", superCustom).toString(); + } + +} +-----------------------------------com.gen.test.BreakController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import javax.validation.Valid; +import com.gen.test.model.Import; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface BreakController { + + + /** + * No description + * + */ + public ResponseEntity createImport(BigDecimal longCustom, Boolean booleanCustom, + @Valid + Import importCustom); + + /** + * No description + * + */ + public ResponseEntity> getImports(BigDecimal byteCustom, Date returnCustom, String voidCustom, BigDecimal defaultCustom); + +} +-----------------------------------com.gen.test.BreakControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import javax.validation.Valid; +import com.gen.test.model.Import; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/break") +@Validated +public class BreakControllerDecorator + implements BreakController +{ + + @Autowired + private BreakController breakControllerDelegate; + + /** + * No description + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createImport( + @RequestParam(name = "long") + BigDecimal longCustom, + @RequestParam(name = "boolean") + Boolean booleanCustom, + @Valid + @RequestBody + Import importCustom) { + return this.breakControllerDelegate.createImport(longCustom, booleanCustom, importCustom); + } + + /** + * No description + * + */ + @RequestMapping(value = "/{byte}", method = RequestMethod.GET) + public ResponseEntity> getImports( + @PathVariable(name = "byte") + BigDecimal byteCustom, + @RequestParam(name = "return") + @DateTimeFormat(pattern = "yyyy-MM-dd") + Date returnCustom, + @RequestParam(name = "void") + String voidCustom, + @RequestParam(name = "default") + BigDecimal defaultCustom) { + return this.breakControllerDelegate.getImports(byteCustom, returnCustom, voidCustom, defaultCustom); + } + +} + diff --git a/src/test/resources/validations/github/issue-152/Issue152-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-152/Issue152-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..94521fd6 --- /dev/null +++ b/src/test/resources/validations/github/issue-152/Issue152-Spring4ControllerInterface.java.txt @@ -0,0 +1,242 @@ +-----------------------------------com.gen.test.model.Import.java----------------------------------- + +package com.gen.test.model; + +import java.io.Serializable; +import java.math.BigInteger; +import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class Import implements Serializable +{ + + /** + * Monetary amount. + * + * + */ + protected Double amount; + /** + * String based on ISO-4217 for specifying the currency related to the amount. + * + * + */ + protected String currency; + protected BigInteger integer; + @JsonProperty("while") + protected String whileCustom; + @JsonProperty("super") + protected Double superCustom; + + /** + * Creates a new Import. + * + */ + public Import() { + super(); + } + + /** + * Creates a new Import. + * + */ + public Import(Double amount, String currency, BigInteger integer, String whileCustom, Double superCustom) { + super(); + this.amount = amount; + this.currency = currency; + this.integer = integer; + this.whileCustom = whileCustom; + this.superCustom = superCustom; + } + + /** + * Returns the amount. + * + * @return + * amount + */ + public Double getAmount() { + return amount; + } + + /** + * Set the amount. + * + * @param amount + * the new amount + */ + public void setAmount(Double amount) { + this.amount = amount; + } + + /** + * Returns the currency. + * + * @return + * currency + */ + public String getCurrency() { + return currency; + } + + /** + * Set the currency. + * + * @param currency + * the new currency + */ + public void setCurrency(String currency) { + this.currency = currency; + } + + /** + * Returns the integer. + * + * @return + * integer + */ + public BigInteger getInteger() { + return integer; + } + + /** + * Set the integer. + * + * @param integer + * the new integer + */ + public void setInteger(BigInteger integer) { + this.integer = integer; + } + + /** + * Returns the whileCustom. + * + * @return + * whileCustom + */ + @NotNull + public String getWhileCustom() { + return whileCustom; + } + + /** + * Set the whileCustom. + * + * @param whileCustom + * the new whileCustom + */ + public void setWhileCustom(String whileCustom) { + this.whileCustom = whileCustom; + } + + /** + * Returns the superCustom. + * + * @return + * superCustom + */ + @NotNull + public Double getSuperCustom() { + return superCustom; + } + + /** + * Set the superCustom. + * + * @param superCustom + * the new superCustom + */ + public void setSuperCustom(Double superCustom) { + this.superCustom = superCustom; + } + + public int hashCode() { + return new HashCodeBuilder().append(amount).append(currency).append(integer).append(whileCustom).append(superCustom).toHashCode(); + } + + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if (this.getClass()!= other.getClass()) { + return false; + } + Import otherObject = ((Import) other); + return new EqualsBuilder().append(amount, otherObject.amount).append(currency, otherObject.currency).append(integer, otherObject.integer).append(whileCustom, otherObject.whileCustom).append(superCustom, otherObject.superCustom).isEquals(); + } + + public String toString() { + return new ToStringBuilder(this).append("amount", amount).append("currency", currency).append("integer", integer).append("whileCustom", whileCustom).append("superCustom", superCustom).toString(); + } + +} +-----------------------------------com.gen.test.BreakController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import javax.validation.Valid; +import com.gen.test.model.Import; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/break") +public interface BreakController { + + + /** + * No description + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createImport( + @RequestParam(name = "long") + BigDecimal longCustom, + @RequestParam(name = "boolean") + Boolean booleanCustom, + @Valid + @RequestBody + Import importCustom); + + /** + * No description + * + */ + @RequestMapping(value = "/{byte}", method = RequestMethod.GET) + public ResponseEntity> getImports( + @PathVariable(name = "byte") + BigDecimal byteCustom, + @RequestParam(name = "return") + @DateTimeFormat(pattern = "yyyy-MM-dd") + Date returnCustom, + @RequestParam(name = "void") + String voidCustom, + @RequestParam(name = "default") + BigDecimal defaultCustom); + +} + diff --git a/src/test/resources/validations/github/issue-152/Issue152-Spring4RestTemplateClient.java.txt b/src/test/resources/validations/github/issue-152/Issue152-Spring4RestTemplateClient.java.txt new file mode 100644 index 00000000..0be3794f --- /dev/null +++ b/src/test/resources/validations/github/issue-152/Issue152-Spring4RestTemplateClient.java.txt @@ -0,0 +1,321 @@ +-----------------------------------com.gen.test.model.Import.java----------------------------------- + +package com.gen.test.model; + +import java.io.Serializable; +import java.math.BigInteger; +import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class Import implements Serializable +{ + + /** + * Monetary amount. + * + * + */ + protected Double amount; + /** + * String based on ISO-4217 for specifying the currency related to the amount. + * + * + */ + protected String currency; + protected BigInteger integer; + @JsonProperty("while") + protected String whileCustom; + @JsonProperty("super") + protected Double superCustom; + + /** + * Creates a new Import. + * + */ + public Import() { + super(); + } + + /** + * Creates a new Import. + * + */ + public Import(Double amount, String currency, BigInteger integer, String whileCustom, Double superCustom) { + super(); + this.amount = amount; + this.currency = currency; + this.integer = integer; + this.whileCustom = whileCustom; + this.superCustom = superCustom; + } + + /** + * Returns the amount. + * + * @return + * amount + */ + public Double getAmount() { + return amount; + } + + /** + * Set the amount. + * + * @param amount + * the new amount + */ + public void setAmount(Double amount) { + this.amount = amount; + } + + /** + * Returns the currency. + * + * @return + * currency + */ + public String getCurrency() { + return currency; + } + + /** + * Set the currency. + * + * @param currency + * the new currency + */ + public void setCurrency(String currency) { + this.currency = currency; + } + + /** + * Returns the integer. + * + * @return + * integer + */ + public BigInteger getInteger() { + return integer; + } + + /** + * Set the integer. + * + * @param integer + * the new integer + */ + public void setInteger(BigInteger integer) { + this.integer = integer; + } + + /** + * Returns the whileCustom. + * + * @return + * whileCustom + */ + @NotNull + public String getWhileCustom() { + return whileCustom; + } + + /** + * Set the whileCustom. + * + * @param whileCustom + * the new whileCustom + */ + public void setWhileCustom(String whileCustom) { + this.whileCustom = whileCustom; + } + + /** + * Returns the superCustom. + * + * @return + * superCustom + */ + @NotNull + public Double getSuperCustom() { + return superCustom; + } + + /** + * Set the superCustom. + * + * @param superCustom + * the new superCustom + */ + public void setSuperCustom(Double superCustom) { + this.superCustom = superCustom; + } + + public int hashCode() { + return new HashCodeBuilder().append(amount).append(currency).append(integer).append(whileCustom).append(superCustom).toHashCode(); + } + + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if (this.getClass()!= other.getClass()) { + return false; + } + Import otherObject = ((Import) other); + return new EqualsBuilder().append(amount, otherObject.amount).append(currency, otherObject.currency).append(integer, otherObject.integer).append(whileCustom, otherObject.whileCustom).append(superCustom, otherObject.superCustom).isEquals(); + } + + public String toString() { + return new ToStringBuilder(this).append("amount", amount).append("currency", currency).append("integer", integer).append("whileCustom", whileCustom).append("superCustom", superCustom).toString(); + } + +} +-----------------------------------com.gen.test.BreakClient.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import javax.validation.Valid; +import com.gen.test.model.Import; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface BreakClient { + + + /** + * No description + * + * @param importCustom The Request Body Payload + * @param booleanCustom + * @param longCustom + */ + public ResponseEntity createImport(BigDecimal longCustom, Boolean booleanCustom, + @Valid + Import importCustom); + + /** + * No description + * + * @param returnCustom + * @param defaultCustom + * @param voidCustom + * @param byteCustom + */ + public ResponseEntity> getImports(BigDecimal byteCustom, Date returnCustom, String voidCustom, BigDecimal defaultCustom); + +} +-----------------------------------com.gen.test.BreakClientImpl.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.validation.Valid; +import com.gen.test.model.Import; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@Component +public class BreakClientImpl + implements BreakClient +{ + + @Value("${client.url}") + private String baseUrl; + @Autowired + private RestTemplate restTemplate; + + /** + * No description + * + */ + public ResponseEntity createImport(BigDecimal longCustom, Boolean booleanCustom, + @Valid + Import importCustom) { + HttpHeaders httpHeaders = new HttpHeaders(); + // Add Accepts Headers and Body Content-Type + ArrayList acceptsList = new ArrayList(); + httpHeaders.setContentType(MediaType.valueOf("application/json")); + acceptsList.add(MediaType.valueOf("application/json")); + httpHeaders.setAccept(acceptsList); + String url = baseUrl.concat("/break"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + if (longCustom!= null) { + builder.queryParam("long", longCustom); + } + if (booleanCustom!= null) { + builder.queryParam("boolean", booleanCustom); + } + UriComponents uriComponents = builder.build(); + HttpEntity httpEntity = new HttpEntity(importCustom, httpHeaders); + return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.POST, httpEntity, Import.class); + } + + /** + * No description + * + */ + public ResponseEntity> getImports(BigDecimal byteCustom, Date returnCustom, String voidCustom, BigDecimal defaultCustom) { + HttpHeaders httpHeaders = new HttpHeaders(); + // Add Accepts Headers and Body Content-Type + ArrayList acceptsList = new ArrayList(); + acceptsList.add(MediaType.valueOf("application/json")); + httpHeaders.setAccept(acceptsList); + String url = baseUrl.concat("/break/{byte}"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + if (returnCustom!= null) { + builder.queryParam("return", returnCustom); + } + if (voidCustom!= null) { + builder.queryParam("void", voidCustom); + } + if (defaultCustom!= null) { + builder.queryParam("default", defaultCustom); + } + UriComponents uriComponents = builder.build(); + HttpEntity httpEntity = new HttpEntity(httpHeaders); + Map uriParamMap = new HashMap(); + uriParamMap.put("byte", byteCustom); + uriComponents = uriComponents.expand(uriParamMap); + class _P extends org.springframework.core.ParameterizedTypeReference>{}; + ParameterizedTypeReference> typeReference = new _P(); + return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.GET, httpEntity, typeReference); + } + +} + diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..38facdce --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerDecorator.java.txt @@ -0,0 +1,71 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public Callable> createBigInteger( + @Valid + BigInteger bigInteger); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createBigInteger( + @Valid + @RequestBody + BigInteger bigInteger) { + return this.numberControllerDelegate.createBigInteger(bigInteger); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..dec3b9ed --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Callable-Format-Spring4ControllerInterface.java.txt @@ -0,0 +1,37 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createBigInteger( + @Valid + @RequestBody + BigInteger bigInteger); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4ControllerDecoratorRule.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4ControllerDecoratorRule.java.txt new file mode 100644 index 00000000..3feb6c9d --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4ControllerDecoratorRule.java.txt @@ -0,0 +1,69 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public ResponseEntity createBigInteger( + @Valid + BigInteger bigInteger); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createBigInteger( + @Valid + @RequestBody + BigInteger bigInteger) { + return this.numberControllerDelegate.createBigInteger(bigInteger); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..a59cba14 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4ControllerInterface.java.txt @@ -0,0 +1,35 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createBigInteger( + @Valid + @RequestBody + BigInteger bigInteger); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4RestTemplateClient.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4RestTemplateClient.java.txt new file mode 100644 index 00000000..af83bc97 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-BigInteger-Format-Spring4RestTemplateClient.java.txt @@ -0,0 +1,83 @@ +-----------------------------------com.gen.test.NumberClient.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberClient { + + + /** + * Returns the winning number. + * + * @param bigInteger The Request Body Payload + */ + public ResponseEntity createBigInteger( + @Valid + BigInteger bigInteger); + +} +-----------------------------------com.gen.test.NumberClientImpl.java----------------------------------- + +package com.gen.test; + +import java.math.BigInteger; +import java.util.ArrayList; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@Component +public class NumberClientImpl + implements NumberClient +{ + + @Value("${client.url}") + private String baseUrl; + @Autowired + private RestTemplate restTemplate; + + /** + * Returns the winning number. + * + */ + public ResponseEntity createBigInteger( + @Valid + BigInteger bigInteger) { + HttpHeaders httpHeaders = new HttpHeaders(); + // Add Accepts Headers and Body Content-Type + ArrayList acceptsList = new ArrayList(); + httpHeaders.setContentType(MediaType.valueOf("application/json")); + acceptsList.add(MediaType.valueOf("application/json")); + httpHeaders.setAccept(acceptsList); + String url = baseUrl.concat("/number"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + UriComponents uriComponents = builder.build(); + HttpEntity httpEntity = new HttpEntity(bigInteger, httpHeaders); + return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.POST, httpEntity, Object.class); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Format-Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Format-Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..ae3bee38 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Format-Spring4ControllerDecorator.java.txt @@ -0,0 +1,69 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public Callable> createLong( + @Valid + Long longCustom); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createLong( + @Valid + @RequestBody + Long longCustom) { + return this.numberControllerDelegate.createLong(longCustom); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Format-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Format-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..c0832787 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Format-Spring4ControllerInterface.java.txt @@ -0,0 +1,36 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createLong( + @Valid + @RequestBody + Long longCustom); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..d51297eb --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Spring4ControllerDecorator.java.txt @@ -0,0 +1,71 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public Callable> createBigDecimal( + @Valid + BigDecimal bigDecimal); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal) { + return this.numberControllerDelegate.createBigDecimal(bigDecimal); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..c4a5a095 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Callable-Spring4ControllerInterface.java.txt @@ -0,0 +1,37 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4ControllerDecoratorRule.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4ControllerDecoratorRule.java.txt new file mode 100644 index 00000000..f7566178 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4ControllerDecoratorRule.java.txt @@ -0,0 +1,67 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public ResponseEntity createLong( + @Valid + Long longCustom); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createLong( + @Valid + @RequestBody + Long longCustom) { + return this.numberControllerDelegate.createLong(longCustom); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..2198a3c3 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4ControllerInterface.java.txt @@ -0,0 +1,35 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createLong( + @Valid + @RequestBody + Long longCustom); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4RestTemplateClient.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4RestTemplateClient.java.txt new file mode 100644 index 00000000..ce43e691 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Format-Spring4RestTemplateClient.java.txt @@ -0,0 +1,81 @@ +-----------------------------------com.gen.test.NumberClient.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberClient { + + + /** + * Returns the winning number. + * + * @param longCustom The Request Body Payload + */ + public ResponseEntity createLong( + @Valid + Long longCustom); + +} +-----------------------------------com.gen.test.NumberClientImpl.java----------------------------------- + +package com.gen.test; + +import java.util.ArrayList; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + + +/** + * No description + * (Generated with springmvc-raml-parser v.2.0.4) + * + */ +@Component +public class NumberClientImpl + implements NumberClient +{ + + @Value("${client.url}") + private String baseUrl; + @Autowired + private RestTemplate restTemplate; + + /** + * Returns the winning number. + * + */ + public ResponseEntity createLong( + @Valid + Long longCustom) { + HttpHeaders httpHeaders = new HttpHeaders(); + // Add Accepts Headers and Body Content-Type + ArrayList acceptsList = new ArrayList(); + httpHeaders.setContentType(MediaType.valueOf("application/json")); + acceptsList.add(MediaType.valueOf("application/json")); + httpHeaders.setAccept(acceptsList); + String url = baseUrl.concat("/number"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + UriComponents uriComponents = builder.build(); + HttpEntity httpEntity = new HttpEntity(longCustom, httpHeaders); + return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.POST, httpEntity, Object.class); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Simple-Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Simple-Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..4e340e3b --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Simple-Spring4ControllerDecorator.java.txt @@ -0,0 +1,69 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public ResponseEntity createBigDecimal( + @Valid + BigDecimal bigDecimal); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal) { + return this.numberControllerDelegate.createBigDecimal(bigDecimal); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Simple-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Simple-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..77b4025d --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Simple-Spring4ControllerInterface.java.txt @@ -0,0 +1,35 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Object createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerDecoratorRule.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerDecoratorRule.java.txt new file mode 100644 index 00000000..c038b980 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerDecoratorRule.java.txt @@ -0,0 +1,68 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public ResponseEntity createBigDecimal( + @Valid + BigDecimal bigDecimal); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal) { + return this.numberControllerDelegate.createBigDecimal(bigDecimal); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..d365af79 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerInterface.java.txt @@ -0,0 +1,36 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerStub.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerStub.java.txt new file mode 100644 index 00000000..e98fba47 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4ControllerStub.java.txt @@ -0,0 +1,38 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createBigDecimal( + @Valid + @RequestBody + BigDecimal bigDecimal) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + +} \ No newline at end of file diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4RestTemplateClient.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4RestTemplateClient.java.txt new file mode 100644 index 00000000..9d4841e5 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigDecimal-Spring4RestTemplateClient.java.txt @@ -0,0 +1,83 @@ +-----------------------------------com.gen.test.NumberClient.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberClient { + + + /** + * Returns the winning number. + * + * @param bigDecimal The Request Body Payload + */ + public ResponseEntity createBigDecimal( + @Valid + BigDecimal bigDecimal); + +} +-----------------------------------com.gen.test.NumberClientImpl.java----------------------------------- + +package com.gen.test; + +import java.math.BigDecimal; +import java.util.ArrayList; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@Component +public class NumberClientImpl + implements NumberClient +{ + + @Value("${client.url}") + private String baseUrl; + @Autowired + private RestTemplate restTemplate; + + /** + * Returns the winning number. + * + */ + public ResponseEntity createBigDecimal( + @Valid + BigDecimal bigDecimal) { + HttpHeaders httpHeaders = new HttpHeaders(); + // Add Accepts Headers and Body Content-Type + ArrayList acceptsList = new ArrayList(); + httpHeaders.setContentType(MediaType.valueOf("application/json")); + acceptsList.add(MediaType.valueOf("application/json")); + httpHeaders.setAccept(acceptsList); + String url = baseUrl.concat("/number"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + UriComponents uriComponents = builder.build(); + HttpEntity httpEntity = new HttpEntity(bigDecimal, httpHeaders); + return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.POST, httpEntity, Object.class); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Callable-Spring4ControllerDecorator.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Callable-Spring4ControllerDecorator.java.txt new file mode 100644 index 00000000..4bb93efb --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Callable-Spring4ControllerDecorator.java.txt @@ -0,0 +1,69 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public Callable> createDouble( + @Valid + Double doubleCustom); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createDouble( + @Valid + @RequestBody + Double doubleCustom) { + return this.numberControllerDelegate.createDouble(doubleCustom); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Callable-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Callable-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..b73098fd --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Callable-Spring4ControllerInterface.java.txt @@ -0,0 +1,36 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import java.util.concurrent.Callable; +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public Callable> createDouble( + @Valid + @RequestBody + Double doubleCustom); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerDecoratorRule.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerDecoratorRule.java.txt new file mode 100644 index 00000000..7bfba1b8 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerDecoratorRule.java.txt @@ -0,0 +1,66 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + public ResponseEntity createDouble( + @Valid + Double doubleCustom); + +} +-----------------------------------com.gen.test.NumberControllerDecorator.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberControllerDecorator + implements NumberController +{ + + @Autowired + private NumberController numberControllerDelegate; + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createDouble( + @Valid + @RequestBody + Double doubleCustom) { + return this.numberControllerDelegate.createDouble(doubleCustom); + } + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerInterface.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerInterface.java.txt new file mode 100644 index 00000000..30ef34d1 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerInterface.java.txt @@ -0,0 +1,35 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@Validated +@RequestMapping("/api/number") +public interface NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createDouble( + @Valid + @RequestBody + Double doubleCustom); + +} diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerStub.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerStub.java.txt new file mode 100644 index 00000000..26cbea48 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4ControllerStub.java.txt @@ -0,0 +1,37 @@ +-----------------------------------com.gen.test.NumberController.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@RestController +@RequestMapping("/api/number") +@Validated +public class NumberController { + + + /** + * Returns the winning number. + * + */ + @RequestMapping(value = "", method = RequestMethod.POST) + public ResponseEntity createDouble( + @Valid + @RequestBody + Double doubleCustom) { + return null; //TODO Autogenerated Method Stub. Implement me please. + } + +} \ No newline at end of file diff --git a/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4RestTemplateClient.java.txt b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4RestTemplateClient.java.txt new file mode 100644 index 00000000..4c4095a8 --- /dev/null +++ b/src/test/resources/validations/github/issue-288/Issue288-BigInteger-Spring4RestTemplateClient.java.txt @@ -0,0 +1,81 @@ +-----------------------------------com.gen.test.NumberClient.java----------------------------------- + +package com.gen.test; + +import javax.validation.Valid; +import org.springframework.http.ResponseEntity; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +public interface NumberClient { + + + /** + * Returns the winning number. + * + * @param doubleCustom The Request Body Payload + */ + public ResponseEntity createDouble( + @Valid + Double doubleCustom); + +} +-----------------------------------com.gen.test.NumberClientImpl.java----------------------------------- + +package com.gen.test; + +import java.util.ArrayList; +import javax.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + + +/** + * No description + * (Generated with springmvc-raml-parser v.@project.version@) + * + */ +@Component +public class NumberClientImpl + implements NumberClient +{ + + @Value("${client.url}") + private String baseUrl; + @Autowired + private RestTemplate restTemplate; + + /** + * Returns the winning number. + * + */ + public ResponseEntity createDouble( + @Valid + Double doubleCustom) { + HttpHeaders httpHeaders = new HttpHeaders(); + // Add Accepts Headers and Body Content-Type + ArrayList acceptsList = new ArrayList(); + httpHeaders.setContentType(MediaType.valueOf("application/json")); + acceptsList.add(MediaType.valueOf("application/json")); + httpHeaders.setAccept(acceptsList); + String url = baseUrl.concat("/number"); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); + UriComponents uriComponents = builder.build(); + HttpEntity httpEntity = new HttpEntity(doubleCustom, httpHeaders); + return this.restTemplate.exchange(uriComponents.encode().toUri(), HttpMethod.POST, httpEntity, Object.class); + } + +}