getBodyVariableUnitTest method
Implementation
String getBodyVariableUnitTest(
String apiName, dynamic body, String parent, List<String> paramPath) {
final List<Map> data = [];
if (body is List) {
for (var element in body) {
data.add(element);
}
} else if (body is Map) {
data.add(body);
}
List<String> result = [];
listClassNameUnitTest.clear();
for (var element in data) {
final keys = element.keys;
final variables = keys
.map((e) => getValueUnitTest(e.toString(), element[e],
apiName.pascalCase, parent, 'body_${apiName.snakeCase}'))
.join(',');
result.add(
'body_${apiName.snakeCase}.${apiName.pascalCase}Body(${paramPath.map((e) => "${e.camelCase}: '$e',").join()} $variables${variables.isNotEmpty ? ',' : ''})');
}
if (result.length > 1) {
return '[${result.join(',')}];';
} else {
return '${result.join(',')};';
}
}