You need to sign in to do that
Don't have an account?
Thiago Barbosa 1
How to coverage this methods?
@AuraEnabled public static Map<string, object> newrefreshOptyListBySearch(String jsonOpp, String accountId, String userId){ MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController(); Map<string, object> objReturn = new Map<string, object>(); try{ controller.searchRecord = new Opportunity(); controller.helperRecord = new Reassign_Helper__c(); controller.mapErros = new Map<String, String>(); Map<String, object> mapaSearch = (Map<String, object>)JSON.deserializeUntyped(jsonOpp); controller.searchRecord.Name = !String.isEmpty((String)mapaSearch.get('Name'))?(String)mapaSearch.get('Name'): null; controller.searchRecord.StageName = !String.isEmpty((String)mapaSearch.get('StageName'))?(String)mapaSearch.get('StageName'): null; controller.searchRecord.AccountId = !String.isEmpty((String)accountId) ? accountId : null; controller.searchRecord.OwnerId = !String.isEmpty((String)userId) ? userId : null; controller.helperRecord.BI_BR_CNPJ_CPF__c = !String.isEmpty((String)mapaSearch.get('BI_BR_CNPJ_CPF__c'))?(String)mapaSearch.get('BI_BR_CNPJ_CPF__c'): null; controller.helperRecord.BI_BR_Identificador__c = !String.isEmpty((String)mapaSearch.get('BI_BR_Numero_da_oportunidade__c'))?(String)mapaSearch.get('BI_BR_Numero_da_oportunidade__c'): null; controller.helperRecord.From__c = mapaSearch.get('From__c') != '' ? Date.valueOf((String)mapaSearch.get('From__c')): null; controller.helperRecord.To__c = mapaSearch.get('To__c') !='' ? Date.valueOf((String)mapaSearch.get('To__c')):null; controller.helperRecord.closedDate_From__c = mapaSearch.get('ClosedDate_From__c') != '' ?Date.valueOf((String)mapaSearch.get('ClosedDate_From__c')):null; controller.helperRecord.closedDate_To__c = mapaSearch.get('ClosedDate_To__c') != '' ?Date.valueOf((String)mapaSearch.get('ClosedDate_To__c')):null; controller.refreshOptyListBySearch(); List<Opportunity> lstOpp = new List<Opportunity>(); for(cOpty Acc : controller.optyList){ lstOpp.add(acc.oOpty); } if(lstOpp.size() == 0){ controller.mapErros.put('Não existem Dados para serem exibidos', 'info'); } objReturn.put('table', lstOpp); }catch(Exception e){ controller.mapErros.put(e.getMessage(), 'error'); } objReturn.put('mensagem' , controller.mapErros); return objReturn; } @AuraEnabled public static Map<String, object> newAssign(String userId, List<Opportunity> lstOpport){ MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController(); Map<String, object> objReturnAssign = new Map<String, object>(); try{ controller.searchRecord = new Opportunity(); controller.helperRecord = new Reassign_Helper__c(); Map<String, object> mapaAssign = new Map<String, object>(); controller.helperRecord.Assign_to__c = !String.isEmpty((String)userId) ? userId : null; for(Opportunity opp : lstOpport){ opp.OwnerId = userId; cOpty pt = new cOpty(opp); pt.selected = true; controller.optyList.add(pt); } controller.Assign(); }catch(exception e){ controller.mapErros.put(e.getMessage(), 'error'); } objReturnAssign.put('mensagemErro', controller.mapErros); return objReturnAssign; } @AuraEnabled public static Map<String, object> newrefreshOptyList(String filterId){ MassReassignOpportunitiesController controller = new MassReassignOpportunitiesController(); controller.filterId = filterId; controller.refreshOptyList(); Map<string, object> objReturn = new Map<String, object>(); List<Opportunity> lstOpp = new List<Opportunity>(); for(cOpty Acc : controller.optyList){ lstOpp.add(acc.oOpty); } objReturn.put('lSelectTable', lstOpp); return objReturn; }