You need to sign in to do that
Don't have an account?
test class having wrapper class...please Help
Hello Everyone,I need help. I have a class who has wrapper too. Confused.
Main Class:::
public without sharing class DownloadAllFilesController {
public static Per_ResponseWrapper response = new Per_ResponseWrapper();
@AuraEnabled
public static Per_ResponseWrapper getAllContentDocumentIds(String recordId){
system.debug('recordId is :::: ' + recordId);
try{
Set<Id> setDocumentChecklistIds = new Set<Id>();
Set<Id> setCaseIds = new Set<Id>();
for(Case subCase: [select Id,Document_Checklist__c from Case
where ParentId =:recordId and RecordType.Name in ('RCU Document Check','RCU Profile Check Off')]){
setDocumentChecklistIds.add(subCase.Document_Checklist__c);
setDocumentChecklistIds.add(subCase.Id);
}
String ContentdocumentIds = '';
if(setDocumentChecklistIds.size() >0){
List<ContentDocumentLink> contentDocumentLinkDatafrmCase = [select id, ContentdocumentId, LinkedEntityId from ContentDocumentLink
where LinkedEntityId IN : setDocumentChecklistIds WITH SECURITY_ENFORCED];
System.debug('contentDocumentLinkDatafrmCase: '+contentDocumentLinkDatafrmCase.size());
if(contentDocumentLinkDatafrmCase.size() > 0){
for(integer i=0; i < contentDocumentLinkDatafrmCase.size(); i++){
ContentdocumentIds += '/' + contentDocumentLinkDatafrmCase[i].ContentdocumentId;
}
}
}
response.success = true;
response.data = ContentdocumentIds;
}
catch(Exception e)
{
system.debug('exception:' + e.getMessage());
response.success = false;
response.message = e.getMessage();
}
system.debug('Content Document ID is:::: ' + response);
return response;
}
}
Wrapper Class:::
public with sharing class Per_ResponseWrapper {
@AuraEnabled public String message {get; set;}
@AuraEnabled public Boolean success {get; set;}
@AuraEnabled public object data {get; set;}
@AuraEnabled public Boolean hasEditAccess {get; set;}
@AuraEnabled public String lastModifiedBy {get; set;}
public class LabelValueWrapper{
@AuraEnabled public Object label;
@AuraEnabled public Object value;
@AuraEnabled public Object optionKey;
@AuraEnabled public Object subQuestionID;
public LabelValueWrapper(Object newLabel, Object newValue){
label = newLabel;
value = newValue;
}
public LabelValueWrapper(Object newLabel, Object newValue, Object newKey){
label = newLabel;
value = newValue;
optionKey = newKey;
}
public LabelValueWrapper(Object newLabel, Object newValue, Object newKey, Object newSubQuestionID){
label = newLabel;
value = newValue;
optionKey = newKey;
subQuestionID = newSubQuestionID;
}
}
public static List<FieldWrapper> getFieldSet(String fieldSetName, String objectName) {
List<FieldWrapper> lstfieldWrapper = new List<FieldWrapper>();
if (String.isNotBlank(fieldSetName) && String.isNotBlank(objectName)) {
Schema.DescribeSObjectResult describeSObjectResult = Schema.getGlobalDescribe().get(objectName).getDescribe();
Map<String,Schema.SObjectField> objFieldMap = describeSObjectResult.fields.getMap();
Schema.FieldSet fieldSetObj = describeSObjectResult.FieldSets.getMap().get(fieldSetName);
if (fieldSetObj != null) {
for(Schema.FieldSetMember fieldSet : fieldSetObj.getFields() ) {
System.debug(fieldSet);
lstfieldWrapper.add( new FieldWrapper(
String.ValueOf(fieldSet.getLabel()+'$$'+String.valueOf(fieldSet.getType())),
String.ValueOf(fieldSet.getFieldPath()),
(fieldSet.getDBRequired() || fieldSet.getRequired())
));
}
}
}
return lstfieldWrapper;
}
@AuraEnabled
public static Per_ResponseWrapper getPicklistValues(Id recordId, List<String> fieldApiNames){
Per_ResponseWrapper response = new Per_ResponseWrapper();
List<Per_ResponseWrapper.LabelValueWrapper> fieldPicklistValueList = new List<LabelValueWrapper>();
Schema.DescribeSObjectResult describeSObjectResult = recordId.getSobjectType().getDescribe();
Map<String,Schema.SObjectField> objFieldMap = describeSObjectResult.fields.getMap();
for(String fieldName : objFieldMap.keySet()){
if(fieldApiNames.contains(fieldName)){
List<Schema.PicklistEntry> picklistValues = objFieldMap.get(fieldName).getDescribe().getPicklistValues();
fieldPicklistValueList.add(new Per_ResponseWrapper.LabelValueWrapper(fieldName, picklistValues));
}
}
response.success = true;
response.data = fieldPicklistValueList;
return response;
}
public class FieldWrapper {
@AuraEnabled public String fieldName {get;set;}
@AuraEnabled public String fieldLabel {get;set;}
@AuraEnabled public String dataType {get;set;}
@AuraEnabled public Boolean isRequired {get;set;}
public FieldWrapper(String fieldLabel,String fieldName,Boolean isRequired ) {
this.fieldLabel = fieldLabel;
this.fieldName = fieldName;
this.isRequired = isRequired;
}
}
}
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
All Answers
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!