You need to sign in to do that
Don't have an account?
Anish Mahadik 1
Unable to create a test class for readonlyfieldmap fields in apex class
Hi All,
Following is the apex code for which i am unable to create test class for readonlyfieldmap. Please help me.
public void doQuery( String recId) {
String query='SELECT Id,RecordType.Name '+formQuery()+' FROM Test_Tool__c WHERE ID =:recId';
edaoTest = new Test_Tool__c(); edaoTest =Database.query(query); selectedTestType =edaoTest.Test_Type__c; if(edaoTest.Issue_Status__c == 'Submitted' || edaoTest.Issue_Status__c == 'Under Review' ||edaoTest.Issue_Status__c == 'IMP to be worked') { // isRerouteEnabledOnStatus = true; readOnlyFieldsMap.put('Test_Name__c',false); } // else if(edaoTest.Issue_Status__c == 'IMP to be worked') // { // readOnlyFieldsMap.put('Test_Name__c',false); // isRerouteEnabledOnStatus = false; // } else if(edaoTest.Issue_Status__c == 'Test Complete') { readOnlyFieldsMap.put('Actual_Hours__c',true); // readOnlyFieldsMap.put('CEO_Strategic_Priority__c',true); readOnlyFieldsMap.put('Issue_Status__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('TestsonValidationStatus__c',true); readOnlyFieldsMap.put('Tests_on_Withdrawn_Status__c',true); readOnlyFieldsMap.put('IMP_Test__c',true); readOnlyFieldsMap.put('IMP_Test_2__c',true); readOnlyFieldsMap.put('IMP_Test_3__c',true); readOnlyFieldsMap.put('IMP_Test_4__c',true); readOnlyFieldsMap.put('IMP_Test_5__c',true); readOnlyFieldsMap.put('Estimated_Start_Date__c',true); readOnlyFieldsMap.put('Estimated_Completion_Date__c',true); // readOnlyFieldsMap.put('New_or_Modified_UDA__c',true); // readOnlyFieldsMap.put('Governance_Approval_Granted__c',true); // readOnlyFieldsMap.put('Data_Sensitivity__c',true); // readOnlyFieldsMap.put('Data_Sources_Utilized__c',true); // readOnlyFieldsMap.put('Other_Tool_Technology_Utilitzed__c',true); readOnlyFieldsMap.put('Other_Type_of_Service__c',true); // readOnlyFieldsMap.put('Collaboration_Entities__c',true); // readOnlyFieldsMap.put('Collaborative_Test_Indicator__c',true); readOnlyFieldsMap.put('Ent_Test_Hrs__c',true); // readOnlyFieldsMap.put('Testected_Hours_Change_Reason__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',true); // readOnlyFieldsMap.put('Tools_Technologies_Utilized__c',true); // readOnlyFieldsMap.put('Testect_ID__c',false); readOnlyFieldsMap.put('What_Test_is_Testing_this__c',true); readOnlyFieldsMap.put('What_Business_Unit_is_Testing_this__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Type_of_Works_Performed__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',true); readOnlyFieldsMap.put('Test_Learn_Phase__c',true); readOnlyFieldsMap.put('EBS_Priority__c',true); readOnlyFieldsMap.put('Planned_or_unplanned__c',true); readOnlyFieldsMap.put('Link_to_previous_Test__c',true); readOnlyFieldsMap.put('Test__c',true); readOnlyFieldsMap.put('Total_Hrs__c',true); readOnlyFieldsMap.put('Testected_Hours__c',true); readOnlyFieldsMap.put('Actual_Hours_History__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Testected_Hours_History__c',true); // readOnlyFieldsMap.put('ReRoute_History__c',true); // readOnlyFieldsMap.put('Reroute_Date__c',true); readOnlyFieldsMap.put('Initiated_Date__c',true); readOnlyFieldsMap.put('In_Progress__c',true); readOnlyFieldsMap.put('In_Validation__c',true); readOnlyFieldsMap.put('Validation_Completed_on__c',true); readOnlyFieldsMap.put('Completed__c',true); readOnlyFieldsMap.put('Withdrawn__c',true); readOnlyFieldsMap.put('On_Hold__c',true); readOnlyFieldsMap.put('TestInitiated__c',true); readOnlyFieldsMap.put('TestInQueue__c',true); readOnlyFieldsMap.put('TestValidating__c',true); readOnlyFieldsMap.put('TestWorking__c',true);
} else { // isRerouteEnabledOnStatus = false; readOnlyFieldsMap.put('Test_Name__c',false); }
/* if(edaoTest.Issue_Status__c =='Tester Validation' || edaoTest.Issue_Status__c == 'Validation Complete'|| edaoTest.Issue_Status__c == 'Result Not Valid') { readOnlyFieldsMap.put('Validation_Status__c',false); }*/ if(edaoTest.Issue_Status__c=='On Hold' ||edaoTest.Issue_Status__c=='Withdrawn')
{ // readOnlyFieldsMap.put('Testect_ID__c',true); readOnlyFieldsMap.put('Link_to_previous_Test__c',true); // readOnlyFieldsMap.put('UDA_Catalog_ID__c',true); readOnlyFieldsMap.put('Test__c',true); } else { readOnlyFieldsMap.put('Validation_Status__c',true); }
/* if(edaoTest.What_Test_is_Testing_this__c =='Other' ||edaoTest.What_Business_Unit_is_Testing_this__c =='Not Listed') { readOnlyFieldsMap.put('Other_Type_of_Service__c',false); }
*/ if(edaoTest.Issue_Status__c != 'Test Complete' && relatedListFlag == False) { readOnlyFieldsMap.put('Actual_Hours__c',true); // readOnlyFieldsMap.put('CEO_Strategic_Priority__c',true); readOnlyFieldsMap.put('Issue_Status__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('TestsonValidationStatus__c',true); readOnlyFieldsMap.put('Tests_on_Withdrawn_Status__c',false); readOnlyFieldsMap.put('IMP_Test__c',true); readOnlyFieldsMap.put('IMP_Test_2__c',true); readOnlyFieldsMap.put('IMP_Test_3__c',true); readOnlyFieldsMap.put('IMP_Test_4__c',true); readOnlyFieldsMap.put('IMP_Test_5__c',true); readOnlyFieldsMap.put('Estimated_Start_Date__c',true); readOnlyFieldsMap.put('Estimated_Completion_Date__c',true); // readOnlyFieldsMap.put('New_or_Modified_UDA__c',true); // readOnlyFieldsMap.put('Governance_Approval_Granted__c',true); // readOnlyFieldsMap.put('Data_Sensitivity__c',true); // readOnlyFieldsMap.put('Data_Sources_Utilized__c',true); // readOnlyFieldsMap.put('Other_Tool_Technology_Utilitzed__c',true); readOnlyFieldsMap.put('Other_Type_of_Service__c',true); // readOnlyFieldsMap.put('Collaboration_Entities__c',true); // readOnlyFieldsMap.put('Collaborative_Test_Indicator__c',true); readOnlyFieldsMap.put('Ent_Test_Hrs__c',true); // readOnlyFieldsMap.put('Testected_Hours_Change_Reason__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',true); // readOnlyFieldsMap.put('Tools_Technologies_Utilized__c',true); // readOnlyFieldsMap.put('Testect_ID__c',false); readOnlyFieldsMap.put('What_Test_is_Testing_this__c',true); readOnlyFieldsMap.put('What_Business_Unit_is_Testing_this__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Type_of_Works_Performed__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',false); readOnlyFieldsMap.put('Test_Learn_Phase__c',true); readOnlyFieldsMap.put('EBS_Priority__c',true); readOnlyFieldsMap.put('Planned_or_unplanned__c',true); readOnlyFieldsMap.put('Link_to_previous_Test__c',true); readOnlyFieldsMap.put('Test__c',true); readOnlyFieldsMap.put('Total_Hrs__c',true); readOnlyFieldsMap.put('Testected_Hours__c',true); readOnlyFieldsMap.put('Actual_Hours_History__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Testected_Hours_History__c',true); // readOnlyFieldsMap.put('ReRoute_History__c',true); // readOnlyFieldsMap.put('Reroute_Date__c',true); readOnlyFieldsMap.put('Initiated_Date__c',true); readOnlyFieldsMap.put('In_Progress__c',true); readOnlyFieldsMap.put('In_Validation__c',true); readOnlyFieldsMap.put('Validation_Completed_on__c',true); readOnlyFieldsMap.put('Completed__c',true); readOnlyFieldsMap.put('Withdrawn__c',true); readOnlyFieldsMap.put('On_Hold__c',true); readOnlyFieldsMap.put('TestInitiated__c',true); readOnlyFieldsMap.put('TestInQueue__c',true); readOnlyFieldsMap.put('TestValidating__c',true); readOnlyFieldsMap.put('TestWorking__c',true); readOnlyFieldsMap.put('Description__c',true); readOnlyFieldsMap.put('Test_Name__c',true);
readOnlyFieldsMap.put('What_is_the_Business_Benefit__c',true);
readOnlyFieldsMap.put('Priority__c',true);
readOnlyFieldsMap.put('Document_Link__c',true);
}
readOnlyFieldsMap.put('Test_Type__c',true); readOnlyFieldsMap.put('Opt_in_for_Email_notification__c',true); readOnlyFieldsMap.put('Tests_History__c',true); }
Thanks,
Anish
Following is the apex code for which i am unable to create test class for readonlyfieldmap. Please help me.
public void doQuery( String recId) {
String query='SELECT Id,RecordType.Name '+formQuery()+' FROM Test_Tool__c WHERE ID =:recId';
edaoTest = new Test_Tool__c(); edaoTest =Database.query(query); selectedTestType =edaoTest.Test_Type__c; if(edaoTest.Issue_Status__c == 'Submitted' || edaoTest.Issue_Status__c == 'Under Review' ||edaoTest.Issue_Status__c == 'IMP to be worked') { // isRerouteEnabledOnStatus = true; readOnlyFieldsMap.put('Test_Name__c',false); } // else if(edaoTest.Issue_Status__c == 'IMP to be worked') // { // readOnlyFieldsMap.put('Test_Name__c',false); // isRerouteEnabledOnStatus = false; // } else if(edaoTest.Issue_Status__c == 'Test Complete') { readOnlyFieldsMap.put('Actual_Hours__c',true); // readOnlyFieldsMap.put('CEO_Strategic_Priority__c',true); readOnlyFieldsMap.put('Issue_Status__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('TestsonValidationStatus__c',true); readOnlyFieldsMap.put('Tests_on_Withdrawn_Status__c',true); readOnlyFieldsMap.put('IMP_Test__c',true); readOnlyFieldsMap.put('IMP_Test_2__c',true); readOnlyFieldsMap.put('IMP_Test_3__c',true); readOnlyFieldsMap.put('IMP_Test_4__c',true); readOnlyFieldsMap.put('IMP_Test_5__c',true); readOnlyFieldsMap.put('Estimated_Start_Date__c',true); readOnlyFieldsMap.put('Estimated_Completion_Date__c',true); // readOnlyFieldsMap.put('New_or_Modified_UDA__c',true); // readOnlyFieldsMap.put('Governance_Approval_Granted__c',true); // readOnlyFieldsMap.put('Data_Sensitivity__c',true); // readOnlyFieldsMap.put('Data_Sources_Utilized__c',true); // readOnlyFieldsMap.put('Other_Tool_Technology_Utilitzed__c',true); readOnlyFieldsMap.put('Other_Type_of_Service__c',true); // readOnlyFieldsMap.put('Collaboration_Entities__c',true); // readOnlyFieldsMap.put('Collaborative_Test_Indicator__c',true); readOnlyFieldsMap.put('Ent_Test_Hrs__c',true); // readOnlyFieldsMap.put('Testected_Hours_Change_Reason__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',true); // readOnlyFieldsMap.put('Tools_Technologies_Utilized__c',true); // readOnlyFieldsMap.put('Testect_ID__c',false); readOnlyFieldsMap.put('What_Test_is_Testing_this__c',true); readOnlyFieldsMap.put('What_Business_Unit_is_Testing_this__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Type_of_Works_Performed__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',true); readOnlyFieldsMap.put('Test_Learn_Phase__c',true); readOnlyFieldsMap.put('EBS_Priority__c',true); readOnlyFieldsMap.put('Planned_or_unplanned__c',true); readOnlyFieldsMap.put('Link_to_previous_Test__c',true); readOnlyFieldsMap.put('Test__c',true); readOnlyFieldsMap.put('Total_Hrs__c',true); readOnlyFieldsMap.put('Testected_Hours__c',true); readOnlyFieldsMap.put('Actual_Hours_History__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Testected_Hours_History__c',true); // readOnlyFieldsMap.put('ReRoute_History__c',true); // readOnlyFieldsMap.put('Reroute_Date__c',true); readOnlyFieldsMap.put('Initiated_Date__c',true); readOnlyFieldsMap.put('In_Progress__c',true); readOnlyFieldsMap.put('In_Validation__c',true); readOnlyFieldsMap.put('Validation_Completed_on__c',true); readOnlyFieldsMap.put('Completed__c',true); readOnlyFieldsMap.put('Withdrawn__c',true); readOnlyFieldsMap.put('On_Hold__c',true); readOnlyFieldsMap.put('TestInitiated__c',true); readOnlyFieldsMap.put('TestInQueue__c',true); readOnlyFieldsMap.put('TestValidating__c',true); readOnlyFieldsMap.put('TestWorking__c',true);
} else { // isRerouteEnabledOnStatus = false; readOnlyFieldsMap.put('Test_Name__c',false); }
/* if(edaoTest.Issue_Status__c =='Tester Validation' || edaoTest.Issue_Status__c == 'Validation Complete'|| edaoTest.Issue_Status__c == 'Result Not Valid') { readOnlyFieldsMap.put('Validation_Status__c',false); }*/ if(edaoTest.Issue_Status__c=='On Hold' ||edaoTest.Issue_Status__c=='Withdrawn')
{ // readOnlyFieldsMap.put('Testect_ID__c',true); readOnlyFieldsMap.put('Link_to_previous_Test__c',true); // readOnlyFieldsMap.put('UDA_Catalog_ID__c',true); readOnlyFieldsMap.put('Test__c',true); } else { readOnlyFieldsMap.put('Validation_Status__c',true); }
/* if(edaoTest.What_Test_is_Testing_this__c =='Other' ||edaoTest.What_Business_Unit_is_Testing_this__c =='Not Listed') { readOnlyFieldsMap.put('Other_Type_of_Service__c',false); }
*/ if(edaoTest.Issue_Status__c != 'Test Complete' && relatedListFlag == False) { readOnlyFieldsMap.put('Actual_Hours__c',true); // readOnlyFieldsMap.put('CEO_Strategic_Priority__c',true); readOnlyFieldsMap.put('Issue_Status__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('TestsonValidationStatus__c',true); readOnlyFieldsMap.put('Tests_on_Withdrawn_Status__c',false); readOnlyFieldsMap.put('IMP_Test__c',true); readOnlyFieldsMap.put('IMP_Test_2__c',true); readOnlyFieldsMap.put('IMP_Test_3__c',true); readOnlyFieldsMap.put('IMP_Test_4__c',true); readOnlyFieldsMap.put('IMP_Test_5__c',true); readOnlyFieldsMap.put('Estimated_Start_Date__c',true); readOnlyFieldsMap.put('Estimated_Completion_Date__c',true); // readOnlyFieldsMap.put('New_or_Modified_UDA__c',true); // readOnlyFieldsMap.put('Governance_Approval_Granted__c',true); // readOnlyFieldsMap.put('Data_Sensitivity__c',true); // readOnlyFieldsMap.put('Data_Sources_Utilized__c',true); // readOnlyFieldsMap.put('Other_Tool_Technology_Utilitzed__c',true); readOnlyFieldsMap.put('Other_Type_of_Service__c',true); // readOnlyFieldsMap.put('Collaboration_Entities__c',true); // readOnlyFieldsMap.put('Collaborative_Test_Indicator__c',true); readOnlyFieldsMap.put('Ent_Test_Hrs__c',true); // readOnlyFieldsMap.put('Testected_Hours_Change_Reason__c',true); readOnlyFieldsMap.put('Validation_Status__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',true); // readOnlyFieldsMap.put('Tools_Technologies_Utilized__c',true); // readOnlyFieldsMap.put('Testect_ID__c',false); readOnlyFieldsMap.put('What_Test_is_Testing_this__c',true); readOnlyFieldsMap.put('What_Business_Unit_is_Testing_this__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Type_of_Works_Performed__c',true); readOnlyFieldsMap.put('Withdraw_the_Test__c',false); readOnlyFieldsMap.put('Test_Learn_Phase__c',true); readOnlyFieldsMap.put('EBS_Priority__c',true); readOnlyFieldsMap.put('Planned_or_unplanned__c',true); readOnlyFieldsMap.put('Link_to_previous_Test__c',true); readOnlyFieldsMap.put('Test__c',true); readOnlyFieldsMap.put('Total_Hrs__c',true); readOnlyFieldsMap.put('Testected_Hours__c',true); readOnlyFieldsMap.put('Actual_Hours_History__c',true); readOnlyFieldsMap.put('TestsonIssueStatus__c',true); readOnlyFieldsMap.put('Testected_Hours_History__c',true); // readOnlyFieldsMap.put('ReRoute_History__c',true); // readOnlyFieldsMap.put('Reroute_Date__c',true); readOnlyFieldsMap.put('Initiated_Date__c',true); readOnlyFieldsMap.put('In_Progress__c',true); readOnlyFieldsMap.put('In_Validation__c',true); readOnlyFieldsMap.put('Validation_Completed_on__c',true); readOnlyFieldsMap.put('Completed__c',true); readOnlyFieldsMap.put('Withdrawn__c',true); readOnlyFieldsMap.put('On_Hold__c',true); readOnlyFieldsMap.put('TestInitiated__c',true); readOnlyFieldsMap.put('TestInQueue__c',true); readOnlyFieldsMap.put('TestValidating__c',true); readOnlyFieldsMap.put('TestWorking__c',true); readOnlyFieldsMap.put('Description__c',true); readOnlyFieldsMap.put('Test_Name__c',true);
readOnlyFieldsMap.put('What_is_the_Business_Benefit__c',true);
readOnlyFieldsMap.put('Priority__c',true);
readOnlyFieldsMap.put('Document_Link__c',true);
}
readOnlyFieldsMap.put('Test_Type__c',true); readOnlyFieldsMap.put('Opt_in_for_Email_notification__c',true); readOnlyFieldsMap.put('Tests_History__c',true); }
Thanks,
Anish
public class LogicClass{
public Map<String,Boolean> readOnlyFieldsMap = new Map<String,Boolean>();
// other methods where you are using this map.
}
@isTest
private class TestClass {
static testMethod void testYourMethod() {
LogicClass A = new LogicClass()
A.readOnlyFieldsMap.put('Tests_History__c',true);
... so on
}
}
Please let me know if it helps you.
Regards,
Pawan Kumar
I tried with the format you mentioned but i am getting "Error: Compile Error: Missing ';' at 'A.readOnlyFieldsMap.put' at line 98 column 8" . I don't know why it is giving an error.
I used the same line
A.readOnlyFieldsMap.put('CFONewRequest.Actual_Hours__c',true);
Thanks,
Anish