Fixed issue in generating classes for collection of collections in java and scala

This commit is contained in:
rpidikiti 2012-02-10 14:21:20 -08:00
parent 99dcb02c23
commit 293f8ad1f5
3 changed files with 54 additions and 7 deletions

View File

@ -97,7 +97,21 @@
"httpMethod" : "POST",
"path" : "/store.{format}/order",
"suggestedMethodName" : "placeOrder"
}
},
{
"id" : 15,
"name" : "Get users with array input",
"httpMethod" : "POST",
"path" : "/user.{format}/usersWithArray",
"suggestedMethodName" : "getUserByNamesArray"
},
{
"id" : 16,
"name" : "get users with list",
"httpMethod" : "POST",
"path" : "/user.{format}/usersWithList",
"suggestedMethodName" : "getUserByNamesList"
}
],
"testSuites" : [
{
@ -179,9 +193,40 @@
"expectedOutput" : "${input.userList[2].username}"
}
]
},
{
"name" : "Find users with array of user names",
"id" : 6,
"resourceId" : 15,
"input" : {
"postData":"[\"testuser1\", \"testuser2\"]"
},
"assertions" : [
{
"actualOutput" : "${output(1.6).size}",
"condition" : "==",
"expectedOutput" : "2"
}
]
},
{
"name" : "Find users with list of user names",
"id" : 7,
"resourceId" : 16,
"input" : {
"postData":"[\"testuser1\", \"testuser2\"]"
},
"assertions" : [
{
"actualOutput" : "${output(1.7).size}",
"condition" : "==",
"expectedOutput" : "2"
}
]
}
]
},
{

View File

@ -199,13 +199,14 @@ public class JavaDataTypeMappingProvider implements DataTypeMappingProvider {
String classShortName = "";
if(type.startsWith("List[")){
classShortName = type.substring(5, type.length()-1);
classShortName = "List<"+ getClassName(classShortName, true)+">";
classShortName = "List<"+ getClassType(classShortName, true)+">";
}else if (type.startsWith("Map[")) {
classShortName = type.substring(4, type.length()-1);
classShortName = "Map<"+ getClassName(classShortName, true) +">";
String[] mapTypes = classShortName.split(",");
classShortName = "Map<"+ getClassType(mapTypes[0], true) + "," + getClassType(mapTypes[1], true) +">";
}else if (type.startsWith("Set[")) {
classShortName = type.substring(4, type.length()-1);
classShortName = "Set<"+ getClassName(classShortName, true) +">";
classShortName = "Set<"+ getClassType(classShortName, true) +">";
}else if (type.startsWith("Array[")) {
classShortName = type.substring(6, type.length()-1);
classShortName = getClassName(classShortName, true) +"[]";

View File

@ -178,13 +178,14 @@ class ScalaDataTypeMappingProvider extends DataTypeMappingProvider {
var classShortName = ""
if (input.startsWith("List[")) {
classShortName = input.substring(5, input.length() - 1);
classShortName = "List[" + getClassName(classShortName, true) + "]";
classShortName = "List[" + getClassType(classShortName, true) + "]";
} else if (input.startsWith("Map[")) {
classShortName = input.substring(4, input.length() - 1);
classShortName = "Map[" + getClassName(classShortName, true) + "]";
val mapTypes:Array[String] = classShortName.split(",");
classShortName = "Map[" + getClassType(mapTypes(0), true) + "," + getClassType(mapTypes(1), true) + "]";
} else if (input.startsWith("Set[")) {
classShortName = input.substring(4, input.length() - 1);
classShortName = "Set[" + getClassName(classShortName, true) + "]";
classShortName = "Set[" + getClassType(classShortName, true) + "]";
} else if (input.startsWith("Array[")) {
classShortName = input.substring(6, input.length() - 1);
classShortName = "Array["+getClassName(classShortName, true) + "]";