Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn authored and Bosn committed Nov 6, 2012
1 parent ee32725 commit fdd3521
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ private String mockValue(Parameter para, int index) {
if (tagIndex == index) {
regex = arr[0];
Xeger generator = new Xeger(regex);
return "\"" + generator.generate() + "\"";
return generator.generate();
}
}

regex = tagMap.get("regex");
if (regex != null && !regex.isEmpty()) {
Xeger generator = new Xeger(regex);
return "\"" + generator.generate() + "\"";
return generator.generate();
}

String value = tagMap.get("value_index");
Expand All @@ -198,12 +198,12 @@ private String mockValue(Parameter para, int index) {
int tagIndex = Integer.parseInt(arr[1]);
if (tagIndex == index) {
value = arr[0];
return "\"" + value + "\"";
return value;
}
}
value = tagMap.get("value");
if (value != null && !value.isEmpty()) {
return "\"" + value + "\"";
return value;
}

String format = tagMap.get("format_index");
Expand All @@ -221,6 +221,24 @@ private String mockValue(Parameter para, int index) {
}
return NumberUtils.randomInt10Str();
} else if (dataType.equals("string")) {
String regex = tagMap.get("regex_index");
if (regex != null && !regex.isEmpty()) {
// value should be like "$trueValue_INDEX_5"
String[] arr = regex.split("_INDEX_");
int tagIndex = Integer.parseInt(arr[1]);
if (tagIndex == index) {
regex = arr[0];
Xeger generator = new Xeger(regex);
return "\"" + generator.generate() + "\"";
}
}

regex = tagMap.get("regex");
if (regex != null && !regex.isEmpty()) {
Xeger generator = new Xeger(regex);
return "\"" + generator.generate() + "\"";
}

String value = tagMap.get("value_index");
if (value != null && !value.isEmpty()) {
String[] arr = value.split("_INDEX_");
Expand Down

0 comments on commit fdd3521

Please sign in to comment.