You need to sign in to do that
Don't have an account?

Please Provide Test class
public class CSI_BankReferenceController { /** * ───────────────────────────────────────────────────────────────────────────────────────────────┐ * getApplicationRecord method is written to get ApplicationId of current Application. * CSIApplicationController.getApplicationRecord returns CSI_Response. * ──────────────────────────────────────────────────────────────────────────────────────────────── * @return CSI_Response returns instance of CSI_Responce class. * ───────────────────────────────────────────────────────────────────────────────────────────────┘ */ @AuraEnabled public static CSI_Response getApplicationRecord(){ return CSI_ApplicationController.getApplicationRecord(); } /** * ───────────────────────────────────────────────────────────────────────────────────────────────┐ * getBankReferences method is written to get Bank deteials of current Application. * ──────────────────────────────────────────────────────────────────────────────────────────────── * @return CSI_Response returns instance of CSI_Responce class. * ───────────────────────────────────────────────────────────────────────────────────────────────┘ */ @AuraEnabled public static CSI_Response getBankReferences(String applicationId){ if(String.isNotEmpty(applicationId)){ System.debug('applicationId '+ applicationId); Application_Member__c applicationMember; //Query to get List of Application Members of current Application where RecordType='Bank Reference' List<Application_Member__c> lstApplicationMember = [SELECT Id, Name,Phone__c, Mobile__c,Name__c,Phone_Type__c FROM Application_Member__c WHERE Application__c =: applicationId AND RecordType.Name = 'Bank Reference' LIMIT 1]; System.debug('lstApplicationMember '+ lstApplicationMember); if(!lstApplicationMember.isEmpty()){ applicationMember=lstApplicationMember.get(0); } //Query to get List of Application Contract of current Application List<Application_Contract__c> lstApplicationContract = [SELECT Bank_Institution__c, Account_Funding_Type__c,Reference_Bank_US_Ind__c FROM Application_Contract__c WHERE Application__c =: applicationId LIMIT 1]; Application_Contract__c applicationContract; if(!lstApplicationContract.isEmpty()){ applicationContract = lstApplicationContract.get(0); return new CSI_Response(true, '', new CompanyInformationWrapper(applicationId,applicationContract,applicationMember)); } } return new CSI_Response(false, 'Application not found', ''); } /** * ───────────────────────────────────────────────────────────────────────────────────────────────┐ * saveCompanyInformation method is written to save data entered on form/scrren of bankReference. * ──────────────────────────────────────────────────────────────────────────────────────────────── * @param applicationId Type:String Id of current Application. * @param jsonData Type:String Data entered on screen convertd into json type string. * @return CSI_Response returns instance of CSI_Responce class. * ───────────────────────────────────────────────────────────────────────────────────────────────┘ */ @AuraEnabled public static CSI_Response saveCompanyInformation(String applicationId, String jsonData){ System.debug('Save Method'); System.debug('jsonData '+ jsonData); if(String.isNotBlank(applicationId) && String.isNotBlank(jsonData)){ CompanyInformationWrapper companyInfo = (CompanyInformationWrapper) JSON.deserialize(jsonData, CompanyInformationWrapper.class); try{ if(companyInfo.applicationMember != null){ upsert companyInfo.applicationMember; } if(companyInfo.applicationContract != null){ upsert companyInfo.applicationContract; } CSI_Response csiResp = getBankReferences(applicationId); CSI_ApplicationProgressHandler.updateApplicationProgress('Bank Reference', applicationId); csiResp.message = 'Saved Successfully!'; return csiResp; }catch(Exception ex){ System.debug('Exception : '+ ex.getMessage()); return new CSI_Response(false, ex.getMessage(), ''); } } return new CSI_Response(false, 'Something went wrong.' , ''); } //Methode to create new Instance of Application_Member__c where Record Type is 'Bank Reference' & Application=applicationId public static Application_Member__c createNewApplicationMemberInstanceCmp(String applicationId){ Id recordTypeId=Schema.SObjectType.Application_Member__c.getRecordTypeInfosByName().get('Bank Reference').getRecordTypeId(); system.debug('recordTypeId ' + recordTypeId); Application_Member__c newAppMemberInstance = new Application_Member__c(); newAppMemberInstance.Salutation__c = ''; newAppMemberInstance.Application__c = applicationId; newAppMemberInstance.Email__c = ''; newAppMemberInstance.Mobile__c = ''; newAppMemberInstance.Name__c = ''; newAppMemberInstance.Phone__c = ''; newAppMemberInstance.Phone_Type__c=''; newAppMemberInstance.FirstName__c = 'te'; newAppMemberInstance.LastName__c = ''; newAppMemberInstance.Title__c = ''; newAppMemberInstance.RecordTypeId = recordTypeId; newAppMemberInstance.Address_Line_1__c = ''; //newAppMemberInstance.Address_Line_2__c = ''; newAppMemberInstance.City__c = ''; newAppMemberInstance.State__c = ''; newAppMemberInstance.Zip_Code__c = ''; newAppMemberInstance.Country__c = ''; return newAppMemberInstance; } }