Skip to content

Commit

Permalink
address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vam-google committed Jan 21, 2022
1 parent d3dca27 commit 3f692cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,16 @@ private MethodDefinition createRpcTestMethod(
.setValueExpr(valExpr)
.build());
} else {
Map<String, String> valuePatterns = Collections.emptyMap();
if (getTransportContext().useValuePatterns() && method.hasHttpBindings()) {
valuePatterns = method.httpBindings().getPathParametersValuePatterns();
}
for (MethodArgument methodArg : methodSignature) {
String methodArgName = JavaStyle.toLowerCamelCase(methodArg.name());
VariableExpr varExpr =
VariableExpr.withVariable(
Variable.builder().setType(methodArg.type()).setName(methodArgName).build());
argExprs.add(varExpr);
Map<String, String> valuePatterns = Collections.emptyMap();
if (getTransportContext().useValuePatterns() && method.hasHttpBindings()) {
valuePatterns = method.httpBindings().getPathParametersValuePatterns();
}
Expr valExpr =
DefaultValueComposer.createMethodArgValue(
methodArg, resourceNames, messageTypes, valuePatterns);
Expand Down Expand Up @@ -777,17 +777,16 @@ protected List<Statement> createRpcExceptionTestStatements(
.setValueExpr(valExpr)
.build());
} else {
Map<String, String> valuePatterns = Collections.emptyMap();
if (getTransportContext().useValuePatterns() && method.hasHttpBindings()) {
valuePatterns = method.httpBindings().getPathParametersValuePatterns();
}
for (MethodArgument methodArg : methodSignature) {
String methodArgName = JavaStyle.toLowerCamelCase(methodArg.name());
VariableExpr varExpr =
VariableExpr.withVariable(
Variable.builder().setType(methodArg.type()).setName(methodArgName).build());
argVarExprs.add(varExpr);
Map<String, String> valuePatterns = Collections.emptyMap();
if (getTransportContext().useValuePatterns() && method.hasHttpBindings()) {
valuePatterns = method.httpBindings().getPathParametersValuePatterns();
}

Expr valExpr =
DefaultValueComposer.createMethodArgValue(
methodArg, resourceNames, messageTypes, valuePatterns);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,16 +600,14 @@ private static String constructValueMatchingPattern(String fieldName, String pat

final String suffix = "-" + (Math.abs((fieldName + pattern).hashCode()) % 10000);

String value = pattern;
value = value.replace("**", "*");
String value = pattern.replace("**", "*");

String prevTempl = null;
while (!value.equals(prevTempl)) {
prevTempl = value;
value = REPLACER_PATTERN.matcher(value).replaceFirst("$1$2$1" + suffix);
}

value = value.replace("*", fieldName + suffix);
return value;
return value.replace("*", fieldName + suffix);
}
}

0 comments on commit 3f692cb

Please sign in to comment.