function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sunfishettesunfishette 

Epic Fail on Test Method... Urgent help needed

I have cobbled together a Test Method (my first one!) by reading what I could from here and other places.  I have no idea why it isnt giving me higher code coverage, but I am guessing someone out there can help me!  With what I have listed below, I get only 2% coverage.  I highlighted the only purple line in my code coverage result, all the other lines are either comments or red.    

 

 

Here is my test code as is:

@isTest
private with sharing class TestgetAllRecords {               
    static testMethod void myTest(){
        List<Opportunity> oList = new List<Opportunity>{};
        test.startTest();  
                date testdate = date.parse('12/31/2020');
                Account testaccount = new Account();
                    testaccount.Name = 'test';
                    insert testaccount;
                Contact testcontact = new Contact();
                    testcontact.LastName = 'test';
                    testcontact.AccountId = testaccount.Id;
                    insert testcontact;
                Opportunity testrenewal =  new Opportunity();
                    testrenewal.accountid = testaccount.Id;
                    testrenewal.Amount = 100.00;
                    testrenewal.Closedate = testdate;
                    testrenewal.Description = 'test';
                    testrenewal.Name =  'test';
                    testrenewal.Stagename = 'Baseline';
                    testrenewal.Probability = 100;
                    testrenewal.OwnerId = UserInfo.getUserId();
                    testrenewal.Coverage_Start_Date__c = testdate;
                    testrenewal.Coverage_End_Date__c = testdate;
                    insert testrenewal;
                Asset_Information__c testasset = new Asset_Information__c();
                    testasset.Name = 'test';
                    testasset.Maintenance_Renewal__c = testrenewal.Id;
                    testasset.Coverage_Start_Date__c = testdate;
                    testasset.Coverage_End_Date__c = testdate;
                    insert testasset;
         oList = [SELECT Name, Contract_Owner__c, Amount, CloseDate FROM Opportunity WHERE Name = 'test'];
         test.stopTest();          
    ApexPages.StandardController sc1 = new ApexPages.StandardController(testrenewal);        
    getAllRecords controller1 = new getAllRecords(sc1);
    }
}

 

and here is my actual class:

public class getAllRecords {
    public getAllRecords(ApexPages.StandardController Controller) {
    }  
    //method to get all maint. renewals
    public Opportunity[] getRecordDetail(){
    //declare and instantiate recordList
    Opportunity[]recordList = new List<Opportunity>();
    //SOQL call to get all the records
        recordList = [SELECT Name,
                             Contract_Owner__c,
                             Amount,
                             CloseDate
                        FROM Opportunity
                       WHERE AccountId IN
                            (SELECT AccountId
                             From User
                             WHERE username=:UserInfo.getUsername())
                         AND (Stagename = 'Baseline' OR Stagename = 'Review' OR Stagename = 'Execution')
                       ORDER BY CloseDate];
       return recordList;
    }
    //method to strip out pastdue to 5 days from close_date
    public Opportunity[] getDuePastDue(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> pastDueList = new List<Opportunity>();
        for(Opportunity obj:recordList) {
                if(obj.CloseDate < (system.today() +5)) {
                   obj.Name = obj.Name.toUpperCase();
                   if(obj.Contract_Owner__c != Null) {
                       obj.Contract_Owner__c = obj.Contract_Owner__c.toUpperCase();
                   }
                   pastDueList.add(obj);
                }    
        }
    return pastDueList;
    }
    //method to strip out 5-30 days from close_date
    public Opportunity[] getFiveThirty(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> fiveThirtyList = new List<Opportunity>();
        for(Opportunity obj4:recordList) {
            if((obj4.CloseDate > (system.today() + 5)) && (obj4.CloseDate <= (system.today() + 30)))  {
                fiveThirtyList.add(obj4);
            }
        }
    return fiveThirtyList;
    }
    //method to strip out over 60 days from close date
    public Opportunity[] getOverSixty(){
        List<Opportunity> recordList = getRecordDetail();
        List<Opportunity> overSixtyList = new List<Opportunity>();
            for(Opportunity obj2:recordList) {
                if(obj2.CloseDate > (system.today() + 60)) {
                    overSixtyList.add(obj2);
                }
            }
    return overSixtyList;
    }    
    //method to strip out 30-60 days from close date
    public Opportunity[] getThirtySixty(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> thirtySixtyList = new List<Opportunity>();
        for(Opportunity obj3:recordList) {
            if((obj3.CloseDate <= (system.today() + 60)) && (obj3.CloseDate > (system.today() + 30))) {
                thirtySixtyList.add(obj3);
            }
        }
    return thirtySixtyList;
    }
    // get a company logo: based on user log in, strip spaces, return image name
    public String getImageName(){     
       String file = [SELECT Name
                        FROM Account
                       WHERE Id IN
                            (SELECT AccountId
                               FROM user
                              WHERE username=:UserInfo.getUsername()
                             )
                       LIMIT 1
                     ].Name;
       file = file.replace(' ', '');  
       String foldername = 'Logos/';
       String extension = '.jpg';
       String fullImageName = foldername + file + extension;
       return fullImageName;
    }  
}

 

 

 

Thank you!!!

Rajesh SriramuluRajesh Sriramulu

Hi

 

U didin't pass any method in test class which are in class try to pass them with controller1.

 

 

Regards,

Rajesh.

sunfishettesunfishette

Rajesh-

Thank you.  But HOW do I do that?  Can you provide a sample syntax?  How do I add the four missing methods to the test?  From a syntax standpoint, I am completely lost.

 

Thanks again!

sunfishettesunfishette

Ah!  Here I am at 63% covered!  I just need a little more help!

 

My Test Method:

@isTest
private with sharing class TestgetAllRecords {               
     static testMethod void myTest(){
        List<Opportunity> oList = new List<Opportunity>{};
                date testdate = date.parse('12/31/2020');
                Account testaccount = new Account();
                    testaccount.Name = 'test';
                    insert testaccount;
                Contact testcontact = new Contact();
                    testcontact.LastName = 'test';
                    testcontact.AccountId = testaccount.Id;
                    insert testcontact;
                Opportunity testrenewal =  new Opportunity();
                    testrenewal.accountid = testaccount.Id;
                    testrenewal.Amount = 100.00;
                    testrenewal.Closedate = testdate;
                    testrenewal.Description = 'test';
                    testrenewal.Name =  'test';
                    testrenewal.Stagename = 'Baseline';
                    testrenewal.Probability = 100;
                    testrenewal.OwnerId = UserInfo.getUserId();
                    testrenewal.Coverage_Start_Date__c = testdate;
                    testrenewal.Coverage_End_Date__c = testdate;
                    insert testrenewal;
    ApexPages.StandardController sc1 = new ApexPages.StandardController(testrenewal);
    getAllRecords controller1 = new getAllRecords(sc1);
    controller1.getRecordDetail();
    controller1.getDuePastDue();
    controller1.getFiveThirty();
    controller1.getOverSixty();
    controller1.getThirtySixty();
    controller1.getImageName();  
    }
}

 

 

And my class:

public class getAllRecords {
    public getAllRecords(ApexPages.StandardController Controller) {
    }  
    //method to get all maint. renewals
    public Opportunity[] getRecordDetail(){
    //declare and instantiate recordList
    Opportunity[]recordList = new List<Opportunity>();
    //SOQL call to get all the records
        recordList = [SELECT Name,
                             Contract_Owner__c,
                             Amount,
                             CloseDate
                        FROM Opportunity
                       WHERE AccountId IN
                            (SELECT AccountId
                             From User
                             WHERE username=:UserInfo.getUsername())
                         AND (Stagename = 'Baseline' OR Stagename = 'Review' OR Stagename = 'Execution')
                       ORDER BY CloseDate];
       return recordList;
    }
    //method to strip out pastdue to 5 days from close_date
    public Opportunity[] getDuePastDue(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> pastDueList = new List<Opportunity>();
        for(Opportunity obj:recordList) {
                if(obj.CloseDate < (system.today() +5)) {
                   obj.Name = obj.Name.toUpperCase();
                   if(obj.Contract_Owner__c != Null) {
                       obj.Contract_Owner__c = obj.Contract_Owner__c.toUpperCase();
                   }
                   pastDueList.add(obj);
                }    
        }
    return pastDueList;
    }
    //method to strip out 5-30 days from close_date
    public Opportunity[] getFiveThirty(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> fiveThirtyList = new List<Opportunity>();
        for(Opportunity obj4:recordList) {
            if((obj4.CloseDate > (system.today() + 5)) && (obj4.CloseDate <= (system.today() + 30)))  {
                fiveThirtyList.add(obj4);
            }
        }
    return fiveThirtyList;
    }
    //method to strip out over 60 days from close date
    public Opportunity[] getOverSixty(){
        List<Opportunity> recordList = getRecordDetail();
        List<Opportunity> overSixtyList = new List<Opportunity>();
            for(Opportunity obj2:recordList) {
                if(obj2.CloseDate > (system.today() + 60)) {
                    overSixtyList.add(obj2);
                }
            }
    return overSixtyList;
    }
    //method to strip out 30-60 days from close date
    public Opportunity[] getThirtySixty(){
    List<Opportunity> recordList = getRecordDetail();
    List<Opportunity> thirtySixtyList = new List<Opportunity>();
        for(Opportunity obj3:recordList) {
            if((obj3.CloseDate <= (system.today() + 60)) && (obj3.CloseDate > (system.today() + 30))) {
                thirtySixtyList.add(obj3);
            }
        }
    return thirtySixtyList;
    }   
    public String getImageName(){     
       String file = [SELECT Name
                        FROM Account
                       WHERE Id IN
                            (SELECT AccountId
                               FROM user
                              WHERE username=:UserInfo.getUsername()
                             )
                       LIMIT 1
                     ].Name;
       file = file.replace(' ', '');  
       String foldername = 'Logos/';
       String extension = '.jpg';
       String fullImageName = foldername + file + extension;
       return fullImageName;
    }  
}

 

 

My failure alert:

System.QueryException: List has no rows for assignment to SObject Class.getAllRecords.getImageName

 

and I am at 63% covered.

 

PLEASE ... any help is appreciated. 

 

Thank you all very much.

 

Jake GmerekJake Gmerek

Without looking at your code coverage I would guess that some of the lines inside of an if statement are not being covered.  What you need to do is make sure that you have test data that ensures that the if statement evaluates to true, then the lines will be covered.  This may mean that you need to have two or more sets of data and/or function calls.  If you have any questions or this is not the case, let me know.

sunfishettesunfishette

You are spot on with the IF statements not being covered.  I scanning the posts now trying to find some sample code to work with, but I am coming up with nada.  Here is the uncovered code:

public class getAllRecords {
  public getAllRecords(ApexPages.StandardController Controller) { } public Opportunity[] getRecordDetail(){ Opportunity[]recordList = new List<Opportunity>(); recordList = [SELECT Name, Contract_Owner__c, Amount, CloseDate FROM Opportunity WHERE AccountId IN (SELECT AccountId From User WHERE username=:UserInfo.getUsername()) AND (Stagename = 'Baseline' OR Stagename = 'Review' OR Stagename = 'Execution') ORDER BY CloseDate]; return recordList; } public Opportunity[] getDuePastDue(){ List<Opportunity> recordList = getRecordDetail(); List<Opportunity> pastDueList = new List<Opportunity>(); for(Opportunity obj:recordList) { if(obj.CloseDate < (system.today() +5)) { obj.Name = obj.Name.toUpperCase(); if(obj.Contract_Owner__c != Null) { obj.Contract_Owner__c = obj.Contract_Owner__c.toUpperCase(); } pastDueList.add(obj); } } return pastDueList; } public Opportunity[] getFiveThirty(){ List<Opportunity> recordList = getRecordDetail(); List<Opportunity> fiveThirtyList = new List<Opportunity>(); for(Opportunity obj4:recordList) { if((obj4.CloseDate > (system.today() + 5)) && (obj4.CloseDate <= (system.today() + 30))) { fiveThirtyList.add(obj4); } } return fiveThirtyList; } public Opportunity[] getOverSixty(){ List<Opportunity> recordList = getRecordDetail(); List<Opportunity> overSixtyList = new List<Opportunity>(); for(Opportunity obj2:recordList) { if(obj2.CloseDate > (system.today() + 60)) { overSixtyList.add(obj2); } } return overSixtyList; } public Opportunity[] getThirtySixty(){ List<Opportunity> recordList = getRecordDetail(); List<Opportunity> thirtySixtyList = new List<Opportunity>(); for(Opportunity obj3:recordList) { if((obj3.CloseDate <= (system.today() + 60)) && (obj3.CloseDate > (system.today() + 30))) { thirtySixtyList.add(obj3); } } return thirtySixtyList; } public String getImageName(){ String file = [SELECT Name FROM Account WHERE Id IN (SELECT AccountId FROM user WHERE username=:UserInfo.getUsername() ) LIMIT 1 ].Name; file = file.replace(' ', ''); String foldername = 'Logos/'; String extension = '.jpg'; String fullImageName = foldername + file + extension; return fullImageName; } }

 and here is my test method:

@isTest
private with sharing class TestgetAllRecords {               
     static testMethod void myTest(){
        List<Opportunity> oList = new List<Opportunity>{};
                date testdate = date.parse('1/20/2012');
                Account testaccount = new Account();
                    testaccount.Name = 'test';
                    insert testaccount;
                Contact testcontact = new Contact();
                    testcontact.LastName = 'test';
                    testcontact.AccountId = testaccount.Id;
                    insert testcontact;
                Opportunity testrenewal =  new Opportunity();
                    testrenewal.accountid = testaccount.Id;
                    testrenewal.Amount = 100.00;
                    testrenewal.Closedate = testdate;
                    testrenewal.Description = 'test';
                    testrenewal.Name = 'test';
                    testrenewal.Stagename = 'Baseline';
                    testrenewal.Probability = 100;
                    testrenewal.OwnerId = UserInfo.getUserId();
                    testrenewal.Coverage_Start_Date__c = testdate;
                    testrenewal.Coverage_End_Date__c = testdate;
                    insert testrenewal;
    ApexPages.StandardController sc1 = new ApexPages.StandardController(testrenewal);
    getAllRecords controller1 = new getAllRecords(sc1);
    controller1.getRecordDetail();
    controller1.getDuePastDue();
    controller1.getFiveThirty();
    controller1.getOverSixty();
    controller1.getThirtySixty();
    }
}

 does this help?

 

Thanks!

Jake GmerekJake Gmerek

OK, I looked a little closer and I realized that you are getting an error.  From what I can tell this is throwing the error:

 

 FROM Account 
                       WHERE Id IN 
                            (SELECT AccountId 
                               FROM user 
                              WHERE username=:UserInfo.getUsername()
                             )
                       LIMIT 1
                     ].Name;

 From the error message I would assume that the SOQL query there is not returning any records so when you try to dereference it (with .name) there is nothing there and it throws an error.  You need to specifically set the AccountID on a user to your ID I think.  I am pretty sure that there is a way to run the test in the context of another user, but I have never done that so you will have to look it up.  You can confirm all my assumptions in the debug log if you want.  It should show you which SOQL statement is returning 0 records and that would be the one that is causing you trouble, I do think that it is this one though as that is what the error message implies

 

sunfishettesunfishette

Hi Jake.

 

I think you are pointing me in the right direction.  Here is my debug log:

Debug Log:

25.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
12:48:13.400 (4400727000)|EXECUTION_STARTED
12:48:13.400 (4400756000)|CODE_UNIT_STARTED|[EXTERNAL]|01pR00000005YPC|TestgetAllRecords.myTest
12:48:13.401 (4401118000)|METHOD_ENTRY|[2]|01pR00000005YPC|TestgetAllRecords.TestgetAllRecords()
12:48:13.401 (4401213000)|METHOD_EXIT|[2]|TestgetAllRecords
12:48:13.401 (4401413000)|SYSTEM_CONSTRUCTOR_ENTRY|[4]|<init>()
12:48:13.401 (4401455000)|SYSTEM_CONSTRUCTOR_EXIT|[4]|<init>()
12:48:13.548 (4548294000)|DML_BEGIN|[8]|Op:Insert|Type:Account|Rows:1
12:48:13.632 (4632726000)|DML_END|[8]
12:48:13.633 (4633056000)|DML_BEGIN|[12]|Op:Insert|Type:Contact|Rows:1
12:48:13.677 (4677853000)|DML_END|[12]
12:48:13.678 (4678576000)|DML_BEGIN|[24]|Op:Insert|Type:Opportunity|Rows:1
12:48:13.743 (4743010000)|CODE_UNIT_STARTED|[EXTERNAL]|01q6000000004v5|changeOpportunityOwnerIfGoldPartner on Opportunity trigger event BeforeInsert for [new]
12:48:13.744 (4744117000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select profileid from user where id = :tmpVar1
12:48:13.754 (4754049000)|SOQL_EXECUTE_END|[4]|Rows:1
12:48:13.754 (4754533000)|SOQL_EXECUTE_BEGIN|[5]|Aggregations:0|select ownerid from account where id = :tmpVar1
12:48:13.756 (4756501000)|SOQL_EXECUTE_END|[5]|Rows:1
12:48:13.756 (4756840000)|SOQL_EXECUTE_BEGIN|[6]|Aggregations:0|select name from profile where id = :tmpVar1
12:48:13.758 (4758821000)|SOQL_EXECUTE_END|[6]|Rows:1
12:48:12.437 (4759215000)|CUMULATIVE_LIMIT_USAGE
12:48:12.437|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 3 out of 100
  Number of query rows: 3 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 3 out of 150
  Number of DML rows: 3 out of 10000
  Number of script statements: 25 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

12:48:12.437|CUMULATIVE_LIMIT_USAGE_END

12:48:13.759 (4759272000)|CODE_UNIT_FINISHED|changeOpportunityOwnerIfGoldPartner on Opportunity trigger event BeforeInsert for [new]
12:48:13.835 (4835963000)|ENTERING_MANAGED_PKG|HubSpot_Inc
12:48:13.842 (4842720000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select Id, OpportunityId, ContactId from OpportunityContactRole where OpportunityId = :tmpVar1
12:48:13.845 (4845720000)|SOQL_EXECUTE_END|[4]|Rows:0
12:48:13.846 (4846583000)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Id, HubSpot_Inc__Contact__c, HubSpot_Inc__Lead__c, HubSpot_Inc__Changes__c, HubSpot_Inc__GUID__c, HubSpot_Inc__Has_Changes__c from HubSpot_Intelligence__c where Contact__c = :tmpVar1
12:48:13.851 (4851254000)|SOQL_EXECUTE_END|[12]|Rows:0
12:48:13.851 (4851805000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:0|select id, email, firstname, lastname from User where UserType = 'Standard'
12:48:13.856 (4856173000)|SOQL_EXECUTE_END|[17]|Rows:10
12:48:13.859 (4859190000)|CODE_UNIT_STARTED|[EXTERNAL]|Workflow:Opportunity
12:48:13.885 (4885808000)|WF_RULE_EVAL_BEGIN|Assignment
12:48:13.885 (4885832000)|WF_RULE_EVAL_BEGIN|Response
12:48:13.885 (4885842000)|WF_RULE_EVAL_BEGIN|Workflow
12:48:13.885 (4885863000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Check for Trident Closed Opp|01Q60000000Af59|ON_CREATE_OR_TRIGGERING_UPDATE
12:48:13.902 (4902571000)|WF_RULE_FILTER|[Maintenance Renewal : Stage equals Closed via Trident]
12:48:13.902 (4902596000)|WF_RULE_EVAL_VALUE|Baseline
12:48:13.902 (4902602000)|WF_CRITERIA_END|false
12:48:13.902 (4902613000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Opportunity Created|01Q60000000B2VD|ON_CREATE_ONLY
12:48:13.902 (4902911000)|WF_RULE_FILTER|[Maintenance Renewal : Created Date equals TODAY] and [Maintenance Renewal : Stage not equal to Execution, Review]
12:48:13.903 (4903130000)|WF_RULE_EVAL_VALUE|2012-07-10 17:48:12
12:48:13.903 (4903144000)|WF_RULE_EVAL_VALUE|Baseline
12:48:13.903 (4903150000)|WF_CRITERIA_END|true
12:48:13.916 (4916449000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Clone Substatus Check|01Q60000000AdFS|ON_CREATE_OR_TRIGGERING_UPDATE
12:48:13.916 (4916506000)|WF_RULE_FILTER|[Maintenance Renewal : Stage not equal to Closed not via Trident] 
AND [Maintenance Renewal : Poseidon Update equals Archive renewal, Move to T&M, Renewed Direct - Move out 1yr, Change client to prospect/inactive, Renewed via another VAR - Move date out 1yr]
12:48:13.916 (4916521000)|WF_RULE_EVAL_VALUE|Baseline
12:48:13.916 (4916527000)|WF_RULE_EVAL_VALUE|null
12:48:13.916 (4916531000)|WF_CRITERIA_END|false
12:48:13.916 (4916540000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Oppty Changed by Portal User|01Q60000000Ad3g|ON_ALL_CHANGES
12:48:13.916 (4916562000)|WF_RULE_FILTER|[User : User Type equals Partner]
12:48:13.916 (4916587000)|WF_RULE_EVAL_VALUE|Standard
12:48:13.916 (4916591000)|WF_CRITERIA_END|false
12:48:13.916 (4916600000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Status Change to Close|01Q60000000AdG1|ON_CREATE_OR_TRIGGERING_UPDATE
12:48:13.916 (4916666000)|WF_RULE_FILTER|[Maintenance Renewal : Stage equals Closed via Trident] OR
 ([Maintenance Renewal : Stage equals Closed not via Trident] AND
 [Maintenance Renewal : Poseidon Update equals Renewed Direct - Move out 1yr, Move to T&M, Archive renewal, Renewed via another VAR - Move date out 1yr])
12:48:13.916 (4916718000)|WF_RULE_EVAL_VALUE|Baseline
12:48:13.916 (4916726000)|WF_RULE_EVAL_VALUE|Baseline
12:48:13.916 (4916731000)|WF_CRITERIA_END|false
12:48:13.916 (4916742000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Calculate Coverage End Date|01Q60000000Acv8|ON_ALL_CHANGES
12:48:13.916 (4916766000)|WF_RULE_FILTER|[Maintenance Renewal : Coverage End Date equals null] 
AND [Maintenance Renewal : Coverage Start Date not equal to null]
12:48:13.916 (4916776000)|WF_RULE_EVAL_VALUE|2012-01-31 00:00:00
12:48:13.916 (4916780000)|WF_CRITERIA_END|false
12:48:13.916 (4916788000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Check For Close Date|01Q60000000Af54|ON_CREATE_OR_TRIGGERING_UPDATE
12:48:13.916 (4916817000)|WF_RULE_FILTER|[Maintenance Renewal : Stage not equal to Closed Won, Closed Lost, Closed not via Trident, Closed via Trident] 
AND [Maintenance Renewal : Original Close Date equals null]
12:48:13.916 (4916832000)|WF_RULE_EVAL_VALUE|Baseline
12:48:13.916 (4916837000)|WF_RULE_EVAL_VALUE|null
12:48:13.916 (4916841000)|WF_CRITERIA_END|true
12:48:13.916 (4916856000)|WF_CRITERIA_BEGIN|[Maintenance Renewal: test 006R0000007Nuek]|Check for Notification Date|01Q60000000AdVf|ON_CREATE_OR_TRIGGERING_UPDATE
12:48:13.916 (4916871000)|WF_RULE_FILTER|[Maintenance Renewal : Notification Date not equal to null]
12:48:13.916 (4916877000)|WF_RULE_EVAL_VALUE|null
12:48:13.916 (4916881000)|WF_CRITERIA_END|false
12:48:13.916 (4916897000)|WF_SPOOL_ACTION_BEGIN|Workflow
12:48:13.917 (4917289000)|WF_FIELD_UPDATE|[Maintenance Renewal: test 006R0000007Nuek]|Field:Maintenance Renewal: Original Close Date|Value:Tue Jan 31 00:00:00 GMT 2012|Id=04Y600000008XMy|CurrentRule:Check For Close Date (Id=01Q60000000Af54)
12:48:13.917 (4917321000)|WF_RULE_INVOCATION|[Maintenance Renewal: test 006R0000007Nuek]
12:48:13.917 (4917333000)|WF_EMAIL_ALERT|Id=01W600000004eHH|CurrentRule:Opportunity Created (Id=01Q60000000B2VD)
12:48:13.985 (4985815000)|WF_EMAIL_SENT|Template:00X60000000tPmz|Recipients:jdenzer@trident-it.com.sandbox1 jwoollen@trident-it.com |CcEmails:
12:48:13.985 (4985854000)|WF_ACTION| Field Update: 1; Email Alert: 1;
12:48:13.985 (4985872000)|WF_RULE_EVAL_BEGIN|Escalation
12:48:13.985 (4985882000)|WF_RULE_EVAL_END
12:48:13.987 (4987508000)|CODE_UNIT_STARTED|[EXTERNAL]|01q6000000004v5|changeOpportunityOwnerIfGoldPartner on Opportunity trigger event BeforeUpdate for [006R0000007Nuek]
12:48:13.988 (4988136000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select profileid from user where id = :tmpVar1
12:48:13.990 (4990324000)|SOQL_EXECUTE_END|[4]|Rows:1
12:48:13.990 (4990638000)|SOQL_EXECUTE_BEGIN|[5]|Aggregations:0|select ownerid from account where id = :tmpVar1
12:48:13.992 (4992542000)|SOQL_EXECUTE_END|[5]|Rows:1
12:48:13.992 (4992787000)|SOQL_EXECUTE_BEGIN|[6]|Aggregations:0|select name from profile where id = :tmpVar1
12:48:13.994 (4994653000)|SOQL_EXECUTE_END|[6]|Rows:1
12:48:12.672 (4994821000)|CUMULATIVE_LIMIT_USAGE
12:48:12.672|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 6 out of 100
  Number of query rows: 6 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 3 out of 150
  Number of DML rows: 3 out of 10000
  Number of script statements: 29 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

12:48:12.672|LIMIT_USAGE_FOR_NS|HubSpot_Inc|
  Number of SOQL queries: 3 out of 100
  Number of query rows: 10 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 16 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

12:48:12.672|CUMULATIVE_LIMIT_USAGE_END

12:48:13.994 (4994914000)|CODE_UNIT_FINISHED|changeOpportunityOwnerIfGoldPartner on Opportunity trigger event BeforeUpdate for [006R0000007Nuek]
12:48:14.020 (5020643000)|ENTERING_MANAGED_PKG|HubSpot_Inc
12:48:14.021 (5021258000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select Id, OpportunityId, ContactId from OpportunityContactRole where OpportunityId = :tmpVar1
12:48:14.022 (5022633000)|SOQL_EXECUTE_END|[4]|Rows:0
12:48:14.023 (5023124000)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Id, HubSpot_Inc__Contact__c, HubSpot_Inc__Lead__c, HubSpot_Inc__Changes__c, HubSpot_Inc__GUID__c, HubSpot_Inc__Has_Changes__c from HubSpot_Intelligence__c where Contact__c = :tmpVar1
12:48:14.026 (5026073000)|SOQL_EXECUTE_END|[12]|Rows:0
12:48:14.026 (5026401000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:0|select id, email, firstname, lastname from User where UserType = 'Standard'
12:48:14.028 (5028826000)|SOQL_EXECUTE_END|[17]|Rows:10
12:48:14.032 (5032475000)|WF_TIME_TRIGGERS_BEGIN
12:48:14.032 (5032947000)|WF_TIME_TRIGGER|[Maintenance Renewal: test 006R0000007Nuek]|0 after trigger date|Opportunity Created 01Q60000000B2VD|12:48:12.710
12:48:14.041 (5041129000)|WF_ACTIONS_END| Field Update: 1; Email Alert: 1;
12:48:14.041 (5041137000)|CODE_UNIT_FINISHED|Workflow:Opportunity
12:48:14.069 (5069228000)|DML_END|[24]
12:48:14.073 (5073969000)|METHOD_ENTRY|[1]|01pR00000005YO9|getAllRecords.getAllRecords()
12:48:14.073 (5073991000)|METHOD_EXIT|[1]|getAllRecords
12:48:14.074 (5074029000)|CONSTRUCTOR_ENTRY|[26]|01pR00000005YO9|<init>(ApexPages.StandardController)
12:48:14.074 (5074086000)|CONSTRUCTOR_EXIT|[26]|01pR00000005YO9|<init>(ApexPages.StandardController)
12:48:14.074 (5074123000)|METHOD_ENTRY|[27]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.074 (5074161000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
12:48:14.074 (5074197000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
12:48:14.093 (5093118000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
12:48:14.103 (5103115000)|SOQL_EXECUTE_END|[9]|Rows:0
12:48:14.103 (5103167000)|METHOD_EXIT|[27]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.103 (5103188000)|METHOD_ENTRY|[28]|01pR00000005YO9|getAllRecords.getDuePastDue()
12:48:14.103 (5103225000)|METHOD_ENTRY|[24]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.103 (5103250000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
12:48:14.103 (5103257000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
12:48:14.103 (5103832000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
12:48:14.108 (5108138000)|SOQL_EXECUTE_END|[9]|Rows:0
12:48:14.108 (5108175000)|METHOD_EXIT|[24]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.108 (5108196000)|SYSTEM_CONSTRUCTOR_ENTRY|[25]|<init>()
12:48:14.108 (5108223000)|SYSTEM_CONSTRUCTOR_EXIT|[25]|<init>()
12:48:14.108 (5108292000)|METHOD_EXIT|[28]|01pR00000005YO9|getAllRecords.getDuePastDue()
12:48:14.108 (5108307000)|METHOD_ENTRY|[29]|01pR00000005YO9|getAllRecords.getFiveThirty()
12:48:14.108 (5108341000)|METHOD_ENTRY|[39]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.108 (5108360000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
12:48:14.108 (5108366000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
12:48:14.108 (5108905000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
12:48:14.113 (5113443000)|SOQL_EXECUTE_END|[9]|Rows:0
12:48:14.113 (5113481000)|METHOD_EXIT|[39]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.113 (5113499000)|SYSTEM_CONSTRUCTOR_ENTRY|[40]|<init>()
12:48:14.113 (5113523000)|SYSTEM_CONSTRUCTOR_EXIT|[40]|<init>()
12:48:14.113 (5113577000)|METHOD_EXIT|[29]|01pR00000005YO9|getAllRecords.getFiveThirty()
12:48:14.113 (5113592000)|METHOD_ENTRY|[30]|01pR00000005YO9|getAllRecords.getOverSixty()
12:48:14.113 (5113617000)|METHOD_ENTRY|[50]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.113 (5113635000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
12:48:14.113 (5113641000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
12:48:14.114 (5114183000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
12:48:14.118 (5118540000)|SOQL_EXECUTE_END|[9]|Rows:0
12:48:14.118 (5118582000)|METHOD_EXIT|[50]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.118 (5118600000)|SYSTEM_CONSTRUCTOR_ENTRY|[51]|<init>()
12:48:14.118 (5118623000)|SYSTEM_CONSTRUCTOR_EXIT|[51]|<init>()
12:48:14.118 (5118676000)|METHOD_EXIT|[30]|01pR00000005YO9|getAllRecords.getOverSixty()
12:48:14.118 (5118691000)|METHOD_ENTRY|[31]|01pR00000005YO9|getAllRecords.getThirtySixty()
12:48:14.118 (5118717000)|METHOD_ENTRY|[61]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.118 (5118735000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
12:48:14.118 (5118742000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
12:48:14.119 (5119273000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
12:48:14.123 (5123603000)|SOQL_EXECUTE_END|[9]|Rows:0
12:48:14.123 (5123639000)|METHOD_EXIT|[61]|01pR00000005YO9|getAllRecords.getRecordDetail()
12:48:14.123 (5123656000)|SYSTEM_CONSTRUCTOR_ENTRY|[62]|<init>()
12:48:14.123 (5123680000)|SYSTEM_CONSTRUCTOR_EXIT|[62]|<init>()
12:48:14.123 (5123733000)|METHOD_EXIT|[31]|01pR00000005YO9|getAllRecords.getThirtySixty()
12:48:12.801 (5123763000)|CUMULATIVE_LIMIT_USAGE
12:48:12.801|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 11 out of 100
  Number of query rows: 6 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 3 out of 150
  Number of DML rows: 3 out of 10000
  Number of script statements: 68 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

12:48:12.801|LIMIT_USAGE_FOR_NS|HubSpot_Inc|
  Number of SOQL queries: 6 out of 100
  Number of query rows: 20 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of script statements: 27 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

12:48:12.801|CUMULATIVE_LIMIT_USAGE_END

12:48:14.123 (5123811000)|CODE_UNIT_FINISHED|TestgetAllRecords.myTest
12:48:14.123 (5123819000)|EXECUTION_FINISHED

 

sunfishettesunfishette

 I am not sure what I am looking for exactly.  So I amended my test data as such:

@isTest
private with sharing class TestgetAllRecords {               
     static testMethod void myTest(){
        List<Opportunity> oList = new List<Opportunity>{};
                date testdate = date.parse('1/31/2012');
                Account testaccount = new Account();
                    testaccount.Name = 'test';      
                    testaccount.Id = UserInfo.getUserId();    
                    insert testaccount;
                Contact testcontact = new Contact();
                    testcontact.LastName = 'test';
                    testcontact.AccountId = testaccount.Id;
                    insert testcontact;
                Opportunity testrenewal =  new Opportunity();
                    testrenewal.accountid = testaccount.Id;
                    testrenewal.Amount = 100.00;
                    testrenewal.Closedate = testdate;
                    testrenewal.Description = 'test';
                    testrenewal.Name = 'test';
                    testrenewal.Stagename = 'Baseline';
                    testrenewal.Probability = 100;
                    testrenewal.OwnerId = UserInfo.getUserId();
                    testrenewal.Coverage_Start_Date__c = testdate;
                    testrenewal.Coverage_End_Date__c = testdate;
                    insert testrenewal;
    ApexPages.StandardController sc1 = new ApexPages.StandardController(testrenewal);
    getAllRecords controller1 = new getAllRecords(sc1);
    controller1.getRecordDetail();
    controller1.getDuePastDue();
    controller1.getFiveThirty();
    controller1.getOverSixty();
    controller1.getThirtySixty();
    }
}

 adding the green line to solve the id issue, and I got this failure warning:

TestGetAllRecords: Field is not writeable:Account Id

 

 Any suggestions?

 

Thanks!

Jake GmerekJake Gmerek

Yes, you are trying to write to the account ID field that is not the field that I believe is causing you problems.  In the query:

 FROM Account 
                       WHERE Id IN 
                            (SELECT AccountId 
                               FROM user 
                              WHERE username=:UserInfo.getUsername()
                             )
                       LIMIT 1
                     ].Name;

 You are looking for user.AccountID and checking for an account with that ID.  From the sales force developer docs that field is:

 

"ID of the Account associated with a Customer Portal user.

This field is null for Salesforce users."

 

What that means is that the field is null since tests are generally run in system mode without a specific user context.  If you are sure that that is the field that you need to use, then you will have to run the test in the context of another user.  See here:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm

 

Then you can create a new portal user, associate it with the account that you are creating in the test class and then run the test as that user.  Let me know what happens.

 

 

 

 

sunfishettesunfishette
... debug log ...

15:09:06.159|CUMULATIVE_LIMIT_USAGE_END

15:09:07.610 (6610014000)|CODE_UNIT_FINISHED|changeOpportunityOwnerIfGoldPartner on Opportunity trigger event BeforeUpdate for [006R0000007Nuh1]
15:09:07.630 (6630037000)|ENTERING_MANAGED_PKG|HubSpot_Inc
15:09:07.630 (6630551000)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select Id, OpportunityId, ContactId from OpportunityContactRole where OpportunityId = :tmpVar1
15:09:07.631 (6631648000)|SOQL_EXECUTE_END|[4]|Rows:0
15:09:07.632 (6632176000)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Id, HubSpot_Inc__Contact__c, HubSpot_Inc__Lead__c, HubSpot_Inc__Changes__c, HubSpot_Inc__GUID__c, HubSpot_Inc__Has_Changes__c from HubSpot_Intelligence__c where Contact__c = :tmpVar1
15:09:07.635 (6635062000)|SOQL_EXECUTE_END|[12]|Rows:0
15:09:07.635 (6635374000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:0|select id, email, firstname, lastname from User where UserType = 'Standard'
15:09:07.637 (6637577000)|SOQL_EXECUTE_END|[17]|Rows:11
15:09:07.639 (6639447000)|WF_TIME_TRIGGERS_BEGIN
15:09:07.639 (6639604000)|WF_TIME_TRIGGER|[Maintenance Renewal: test Opportuntiy3 006R0000007Nuh1]|0 after trigger date|Opportunity Created 01Q60000000B2VD|15:09:06.189
15:09:07.643 (6643943000)|WF_ACTIONS_END| Field Update: 1; Email Alert: 1;
15:09:07.643 (6643953000)|CODE_UNIT_FINISHED|Workflow:Opportunity
15:09:07.669 (6669757000)|DML_END|[39]
15:09:07.674 (6674708000)|METHOD_ENTRY|[1]|01pR00000005YO9|getAllRecords.getAllRecords()
15:09:07.674 (6674733000)|METHOD_EXIT|[1]|getAllRecords
15:09:07.674 (6674782000)|CONSTRUCTOR_ENTRY|[43]|01pR00000005YO9|<init>(ApexPages.StandardController)
15:09:07.674 (6674830000)|CONSTRUCTOR_EXIT|[43]|01pR00000005YO9|<init>(ApexPages.StandardController)
15:09:07.674 (6674867000)|METHOD_ENTRY|[45]|01pR00000005YO9|getAllRecords.getDuePastDue()
15:09:07.674 (6674896000)|METHOD_ENTRY|[24]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.674 (6674942000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
15:09:07.674 (6674959000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
15:09:07.692 (6692219000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
15:09:07.702 (6702131000)|SOQL_EXECUTE_END|[9]|Rows:0
15:09:07.702 (6702185000)|METHOD_EXIT|[24]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.702 (6702208000)|SYSTEM_CONSTRUCTOR_ENTRY|[25]|<init>()
15:09:07.702 (6702230000)|SYSTEM_CONSTRUCTOR_EXIT|[25]|<init>()
15:09:07.702 (6702301000)|METHOD_EXIT|[45]|01pR00000005YO9|getAllRecords.getDuePastDue()
15:09:07.702 (6702318000)|METHOD_ENTRY|[46]|01pR00000005YO9|getAllRecords.getFiveThirty()
15:09:07.702 (6702342000)|METHOD_ENTRY|[39]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.702 (6702357000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
15:09:07.702 (6702363000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
15:09:07.702 (6702898000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
15:09:07.707 (6707189000)|SOQL_EXECUTE_END|[9]|Rows:0
15:09:07.707 (6707226000)|METHOD_EXIT|[39]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.707 (6707244000)|SYSTEM_CONSTRUCTOR_ENTRY|[40]|<init>()
15:09:07.707 (6707261000)|SYSTEM_CONSTRUCTOR_EXIT|[40]|<init>()
15:09:07.707 (6707312000)|METHOD_EXIT|[46]|01pR00000005YO9|getAllRecords.getFiveThirty()
15:09:07.707 (6707325000)|METHOD_ENTRY|[47]|01pR00000005YO9|getAllRecords.getOverSixty()
15:09:07.707 (6707346000)|METHOD_ENTRY|[50]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.707 (6707361000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
15:09:07.707 (6707367000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
15:09:07.707 (6707880000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
15:09:07.712 (6712085000)|SOQL_EXECUTE_END|[9]|Rows:0
15:09:07.712 (6712125000)|METHOD_EXIT|[50]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.712 (6712143000)|SYSTEM_CONSTRUCTOR_ENTRY|[51]|<init>()
15:09:07.712 (6712161000)|SYSTEM_CONSTRUCTOR_EXIT|[51]|<init>()
15:09:07.712 (6712213000)|METHOD_EXIT|[47]|01pR00000005YO9|getAllRecords.getOverSixty()
15:09:07.712 (6712229000)|METHOD_ENTRY|[48]|01pR00000005YO9|getAllRecords.getThirtySixty()
15:09:07.712 (6712250000)|METHOD_ENTRY|[61]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.712 (6712264000)|SYSTEM_CONSTRUCTOR_ENTRY|[7]|<init>()
15:09:07.712 (6712271000)|SYSTEM_CONSTRUCTOR_EXIT|[7]|<init>()
15:09:07.712 (6712795000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Name, Contract_Owner__c, Amount, CloseDate from Opportunity where (AccountId IN (select AccountId from User where username = :tmpVar1) and (Stagename = 'Baseline' or Stagename = 'Review' or Stagename = 'Execution')) order by CloseDate
15:09:07.716 (6716998000)|SOQL_EXECUTE_END|[9]|Rows:0
15:09:07.717 (6717035000)|METHOD_EXIT|[61]|01pR00000005YO9|getAllRecords.getRecordDetail()
15:09:07.717 (6717053000)|SYSTEM_CONSTRUCTOR_ENTRY|[62]|<init>()
15:09:07.717 (6717070000)|SYSTEM_CONSTRUCTOR_EXIT|[62]|<init>()
15:09:07.717 (6717120000)|METHOD_EXIT|[48]|01pR00000005YO9|getAllRecords.getThirtySixty()
15:09:06.267 (6717151000)|CUMULATIVE_LIMIT_USAGE
15:09:06.267|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 23 out of 100
  Number of query rows: 19 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 7 out of 150
  Number of DML rows: 7 out of 10000
  Number of script statements: 74 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10
15:09:06.267|CUMULATIVE_LIMIT_USAGE_END

15:09:07.717 (6717183000)|CODE_UNIT_FINISHED|TestgetAllRecords.myTest
15:09:07.717 (6717190000)|EXECUTION_FINISHED

 I added the code as suggested by the link you provided.

 

It changed nothing.

 

I agree that there is an issue with my data not being present, therefore there is nothing for the IF statements to evaluate.

 

The method in question is indeed directed to Partner Portal users to capture the name of the company, strip out the white spaces of their company name and sandwich it between Logos/(added variable from query).jpg so I can add an image to my VF page based on the log in of the partner portal user.  It works when tested in the sandbox, but I cant deploy this to my production org without the Test method working.

 

I am at my wits end.  I have been working on this for two weeks.

 

Do you have any syntax that you can add to help me out?

 

Thank you!

Jake GmerekJake Gmerek

It sucks, but you just have to dig through it.  For Example:

 

15:09:07.631 (6631648000)|SOQL_EXECUTE_END|[4]|Rows:0
15:09:07.632 (6632176000)|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Id, HubSpot_Inc__Contact__c, HubSpot_Inc__Lead__c, HubSpot_Inc__Changes__c, HubSpot_Inc__GUID__c, HubSpot_Inc__Has_Changes__c from HubSpot_Intelligence__c where Contact__c = :tmpVar1
15:09:07.635 (6635062000)|SOQL_EXECUTE_END|[12]|Rows:0

 You can see in the query that it is looking at HubSpot_Intelligence__c so you may have to insert a record into there so that there is a contact__c that matches your newly created contact.  Essentially, you just look at things like that till your querys are returning data, then if your if's still are not covered, you have to check and make sure that the data you are entering evualates to TRUE so that the code inside the statement will run.  It is hard to give you exact code though because I do not even know what that object is or does or even if I am on the right track on where contact__c comes from.  I can show you one shortcut though that will make your code easier to read.  This:

 

Contact testcontact = new Contact();
                    testcontact.LastName = 'test';
                    testcontact.AccountId = testaccount.Id;

 can be rewritten as this:

 

Contact testContact = new Contact(LastName = 'test', AccountId = testaccount.id);

 It is good practice as well as it will save you statements towards your governor limits in longer pieces of code.  If you have specific questions on this, let me know and I will do what I can to help.

Rajesh SriramuluRajesh Sriramulu

Hi

 

In ur test class try to add the opputunity like below

 

Opportunity testrenewal =  new Opportunity();
                    testrenewal.accountid = testaccount.Id;
                    testrenewal.Amount = 100.00;

                    testrenewal.name='test';

                    testrenewal.Contract_Owner__c= //here u put the owner of the contract id.
                    testrenewal.Closedate = testdate;
                    testrenewal.Description = 'test';
                    testrenewal.Name =  'test';
                    testrenewal.Stagename = 'Baseline';
                    testrenewal.Probability = 100;
                    testrenewal.OwnerId = UserInfo.getUserId();
                    testrenewal.Coverage_Start_Date__c = testdate;
                    testrenewal.Coverage_End_Date__c = testdate;
                    insert testrenewal;

 

Regards,

Rajesh.