You need to sign in to do that
Don't have an account?
SIVA KUMAR 507
Hey Guys I need Test Class For the below Code please guys help me.a
Apex Class:
_______________
global with sharing class FlowListController {
@AuraEnabled(cacheable=true)
public static List<FlowDefinitionView> getFlowNamesApex(String filtersString) {
String queryString = 'SELECT Id, ApiName, Label FROM FlowDefinitionView ';
if (filtersString != null) {
Map<String, List<String>> filters = (Map<String, List<String>>) JSON.deserialize(filtersString, Map<String, List<String>>.class);
if (!filters.isEmpty()) {
queryString += ' WHERE ';
Boolean isFirst = true;
for (String fieldName : filters.keySet()) {
List<String> values = filters.get(fieldName);
String negativeClause = fieldName.contains('!') ? (values.size() > 1 ? 'NOT ' : '!') : '';
String operator = values.size() == 1 ? '= ' : 'IN ';
String value = values.size() == 1 ? values[0] : '(\'' + String.join(values, '\',\'') + '\')';
queryString += (!isFirst ? ' AND ' : ' ') + fieldName.replace('!', '') + ' ' + negativeClause + operator + value;
isFirst = false;
}
}
}
return (List<FlowDefinitionView>) Database.query(queryString);
}
}
_______________
global with sharing class FlowListController {
@AuraEnabled(cacheable=true)
public static List<FlowDefinitionView> getFlowNamesApex(String filtersString) {
String queryString = 'SELECT Id, ApiName, Label FROM FlowDefinitionView ';
if (filtersString != null) {
Map<String, List<String>> filters = (Map<String, List<String>>) JSON.deserialize(filtersString, Map<String, List<String>>.class);
if (!filters.isEmpty()) {
queryString += ' WHERE ';
Boolean isFirst = true;
for (String fieldName : filters.keySet()) {
List<String> values = filters.get(fieldName);
String negativeClause = fieldName.contains('!') ? (values.size() > 1 ? 'NOT ' : '!') : '';
String operator = values.size() == 1 ? '= ' : 'IN ';
String value = values.size() == 1 ? values[0] : '(\'' + String.join(values, '\',\'') + '\')';
queryString += (!isFirst ? ' AND ' : ' ') + fieldName.replace('!', '') + ' ' + negativeClause + operator + value;
isFirst = false;
}
}
}
return (List<FlowDefinitionView>) Database.query(queryString);
}
}
Hi Siva,
Please find the solution. "Hey Guys I need Test Class For the below Code please guys help me.a"
Note: Please pass the valid string "filtersString" as I am not passing correct data here.I mean you know this string "filtersString" which type of data has this String "filtersString"
Please mark it as the Best answer so that other people would take reference from it.
Thank You
When i tried to run the test class it showing errors.