• subramanyam subbu 7
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies
 public Pagereference saveQuestion(){
        businessfetchedDataToSave = [Select Id,Name ,Subject_Matter_Expert__r.Name ,Subject_Matter_Expert__r.Email from Line_Of_Business__c where Name =:lineDisciplineValue];
        Question__c q = new Question__c ();
        q.Line_Of_Discipline_C__c = businessfetchedDataToSave.Id;
        User u = [select id from user where user.Name=:businessfetchedDataToSave.Subject_Matter_Expert__r.Name];
        q.Line_Of_Discipline_Focal_Point__c = u.id;
        q.Line_Of_Discipline_Focal_Point_Email__c = businessfetchedDataToSave.Subject_Matter_Expert__r.Email;
        q.Priority_C__c = ques.Priority_C__c;
        q.Title_C__c = ques.Title_C__c;
        q.Question_C__c = ques.Question_C__c;
        q.Status_C__c = 'Open';
        q.Site__c = companySiteValue;
        insert q;    
        
        return null;
    }
public with sharing class extController {

    public Document document { get; set; }
   
    public Line_Of_Business__c businessfetchedData{get; set;}
    public Line_Of_Business__c businessfetchedDataToSave{get; set;}
    public string lineDisciplineValue{get; set;}
    public Question__c ques {get; set;}-
   
    public extController() {
        ques = new Question__c();
    }
   
   
   
    public List<SelectOption> getItems() {
        List<Line_Of_Business__c> getBusinessRecs  =  new List<Line_Of_Business__c>([Select Id,Name from Line_Of_Business__c limit 50000]);
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--None--'));
        for(Line_Of_Business__c business : getBusinessRecs){
            options.add(new SelectOption(business.Name,business.Name));
        }
       
       
        return options;
    }
   
    public Pagereference getRelatedValues(){
        string businessLine = ApexPages.currentPage().getParameters().get('businessValue');
        businessfetchedData = [Select Id,Name ,Subject_Matter_Expert__r.Name ,Subject_Matter_Expert__r.Email from Line_Of_Business__c where Name =:businessLine];
        return null;
    }
   
    public Pagereference saveQuestion(){
        businessfetchedDataToSave = [Select Id,Name ,Subject_Matter_Expert__r.Name ,Subject_Matter_Expert__r.Email from Line_Of_Business__c where Name =:lineDisciplineValue];
        Question__c q = new Question__c ();
        q.Line_Of_Discipline_C__c = businessfetchedDataToSave.Id;
        User u = [select id from user where user.Name=:businessfetchedDataToSave.Subject_Matter_Expert__r.Name];
        q.Line_Of_Discipline_Focal_Point__c = u.id;
        q.Line_Of_Discipline_Focal_Point_Email__c = businessfetchedDataToSave.Subject_Matter_Expert__r.Email;
        q.Priority_C__c = ques.Priority_C__c;
        q.Title_C__c = ques.Title_C__c;
        q.Question_C__c = ques.Question_C__c;
        q.Status_C__c = 'Open';
        insert q;
       
        return null;
    }

}
Hi all.

here is my code . how can i achieve 100% code coverage for this Trigger?



trigger CopyAttachments on SVMXC__Service_Order__c(after insert)
{
 //Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c];
 Attachment[] insertAttList = new Attachment[]{};
 
         for(Attachment a: [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c])
         {
               Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
               insertAttList.add(att);
         }
       if(insertAttList.size() > 0)
       {
            insert insertAttList;
       }
 
}
  • November 16, 2016
  • Like
  • 1
hi guys,

i am having problem while setting mock responses for my web service.....here is the code....please provide with some solution
 
******************************************code for the web service************************************************************
public String synchronizeAX(String sdfcObjectId,String sfdcObjectName,String companyName,String operationtype,ID stagingStatusId) {
            string xml;
            OAC_AXIntegrate.synchronizeAX_element request_x = new OAC_AXIntegrate.synchronizeAX_element();
            OAC_AXIntegrate.synchronizeAXResponse_element response_x;
            request_x.sdfcObjectId = sdfcObjectId;
            request_x.sfdcObjectName = sfdcObjectName;
            request_x.companyName = companyName;
            request_x.operationtype = operationtype;
            request_x.domain = domain_x;
            request_x.username = username_x;
            request_x.password = password_x;
            Map<String, OAC_AXIntegrate.synchronizeAXResponse_element> response_map_x = new Map<String, OAC_AXIntegrate.synchronizeAXResponse_element>();
            response_map_x.put('response_x', response_x);
            //stagingStatusId = OAC_AXSynchronize.createStagingData(sdfcObjectId,sfdcObjectName,companyName,operationtype); 
                        WebServiceCallout.invoke(
                this,
                request_x,
                response_map_x,
                new String[]{endpoint_x,
                'http://tempuri.org/IAXSdfcService/synchronizeAX',
                'http://tempuri.org/',
                'synchronizeAX',
                'http://tempuri.org/',
                'synchronizeAXResponse',
                'OAC_AXIntegrate.synchronizeAXResponse_element'}
            );
            
            response_x = response_map_x.get('response_x');
                 system.debug('---message----'+response_x);
            
          
           xml = this.getXml(sdfcObjectId,sfdcObjectName,companyName);
           OAC_AXSynchronize.updateStagingData(sdfcObjectId,companyName,sfdcObjectName,stagingStatusId,response_x.synchronizeAXResult,xml);
         return response_x.synchronizeAXResult;
            
            
        }



*********************************​code for the  mock response for web service************************************************
@isTest
global class  mocksyncax implements WebServiceMock {
   global void doInvoke(
           Object stub,
           Object request,
           Map<String, Object> response,
           String endpoint,
           String soapAction,
           String requestName,
           String responseNS,
           String responseName,
           string responseType) {

// Create response element from the autogenerated class.
        OAC_AXIntegrate.synchronizeAXResponse_element reselement   = new  OAC_AXIntegrate.synchronizeAXResponse_element();
//Here createRecordResponse_element is an inner class in generated service class for preparing response
// Populate response element.
       reselement.synchronizeAXResult='welcome';
// Add response element to the response parameter, as follows:
        response.put('response_x', reselement);
   }
      
}


**********************************this is my test class***********************************

@isTest
private class CalloutClassTest {

  
    
     @isTest static void testEchoString() {   
         
         
        
       

      // Test.setMock(WebServiceMock.class, new mocksyncax());
        
        // Call the method that invokes a callout
        
      // string ressyncax = axservice.synchronizeAX('0011700000Po7oaAAB','Account','OA','Insert','a0117000004ynJuAAI');
          
         
        
         

    }
    }
i am getting the following error:
FATAL_ERROR System.TypeException: Collection store exception putting OAC_AXIntegrate.getXMLResponse_element into Map<String,OAC_AXIntegrate.synchronizeAXResponse_element>

please provide with some solution.............



 
 public Pagereference saveQuestion(){
        businessfetchedDataToSave = [Select Id,Name ,Subject_Matter_Expert__r.Name ,Subject_Matter_Expert__r.Email from Line_Of_Business__c where Name =:lineDisciplineValue];
        Question__c q = new Question__c ();
        q.Line_Of_Discipline_C__c = businessfetchedDataToSave.Id;
        User u = [select id from user where user.Name=:businessfetchedDataToSave.Subject_Matter_Expert__r.Name];
        q.Line_Of_Discipline_Focal_Point__c = u.id;
        q.Line_Of_Discipline_Focal_Point_Email__c = businessfetchedDataToSave.Subject_Matter_Expert__r.Email;
        q.Priority_C__c = ques.Priority_C__c;
        q.Title_C__c = ques.Title_C__c;
        q.Question_C__c = ques.Question_C__c;
        q.Status_C__c = 'Open';
        q.Site__c = companySiteValue;
        insert q;    
        
        return null;
    }
public with sharing class extController {

    public Document document { get; set; }
   
    public Line_Of_Business__c businessfetchedData{get; set;}
    public Line_Of_Business__c businessfetchedDataToSave{get; set;}
    public string lineDisciplineValue{get; set;}
    public Question__c ques {get; set;}-
   
    public extController() {
        ques = new Question__c();
    }
   
   
   
    public List<SelectOption> getItems() {
        List<Line_Of_Business__c> getBusinessRecs  =  new List<Line_Of_Business__c>([Select Id,Name from Line_Of_Business__c limit 50000]);
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--None--'));
        for(Line_Of_Business__c business : getBusinessRecs){
            options.add(new SelectOption(business.Name,business.Name));
        }
       
       
        return options;
    }
   
    public Pagereference getRelatedValues(){
        string businessLine = ApexPages.currentPage().getParameters().get('businessValue');
        businessfetchedData = [Select Id,Name ,Subject_Matter_Expert__r.Name ,Subject_Matter_Expert__r.Email from Line_Of_Business__c where Name =:businessLine];
        return null;
    }
   
    public Pagereference saveQuestion(){
        businessfetchedDataToSave = [Select Id,Name ,Subject_Matter_Expert__r.Name ,Subject_Matter_Expert__r.Email from Line_Of_Business__c where Name =:lineDisciplineValue];
        Question__c q = new Question__c ();
        q.Line_Of_Discipline_C__c = businessfetchedDataToSave.Id;
        User u = [select id from user where user.Name=:businessfetchedDataToSave.Subject_Matter_Expert__r.Name];
        q.Line_Of_Discipline_Focal_Point__c = u.id;
        q.Line_Of_Discipline_Focal_Point_Email__c = businessfetchedDataToSave.Subject_Matter_Expert__r.Email;
        q.Priority_C__c = ques.Priority_C__c;
        q.Title_C__c = ques.Title_C__c;
        q.Question_C__c = ques.Question_C__c;
        q.Status_C__c = 'Open';
        insert q;
       
        return null;
    }

}