• Darlene Blaney
  • NEWBIE
  • 25 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 13
    Replies
I have a visualforce page where I select student type of freshman and display highschool information fields (that works fine).  But I want to hide the highschool country if the person checks the homeschooled checkbox.  I can't seem to get that to work. I am trying to use javascript to hide the fields.  Any help would be greatly appreciated.
vfp code:
<apex:page Controller="RFIForm" showHeader="false" standardStylesheets="FALSE">
<apex:includeScript value="{!$Resource.jQuery}"/>
<apex:composition template="{!$Site.Template}">
<apex:define name="body">
<script>
        
$(document).ready(function() {

    HSReRender();
});
    
function HSReRender(){
    var studentType = $("[id$=studentType]").val();
    var HomeSchooled = $("[id$=homeSchooled]").val();
    
    //$(".hsPanelH").hide();
    alert(HomeSchooled);
    if (studentType == "Freshman"){
        $(".highSchoolPanelH").show();
        if (HomeSchooled.checked){
        $(".hsPanelH").hide();
        alert('testing homeschooled checked');}
        else{
        $(".hsPanelH").show();
        alert('testing homeschooled not checked');}
        alert('testing freshman first');
    } else {
        $(".highSchoolPanelH").hide();
        $(".hsPanelH").hide();
        alert('testing freshman else first');
        }
    
    if ($(("#homeSchooled").is(":checked"))){
        //    if (studentType2 == "Freshman" && (HomeSchooled == null || HomeSchooled == false)){
        $(".hsPanelH").hide();
        alert('testing freshman and homeschooled checked');
    } else if (studentType == "Freshman"){
        $(".hsPanelH").show();
        alert('testing just freshman');
        } else {
           $(".hsPanelH").hide();
            alert('testing else');
        }
}
</script>
    <apex:pageMessages ></apex:pageMessages>
<apex:form Id="form">
    <h1 id="page-title">Request for Information </h1>
    <div style="width:100%">
        <p>
           <span class="contentText">Please enter your information in the fields below. When completed click on the <b>Submit</b> button at the bottom of page. Please allow 3 to 5 business days for processing your request for information.</span>
        </p>
        <p>
           <span class="contentText"><strong>* Indicates a required field.</strong></span>
        </p>
    </div>
    <table border="0" cellspacing="3" width="100%">
        <tbody>
            <tr>
                 <th colspan="2">Name and Personal Data</th>
            </tr> 
            <tr>
                <td width="37%"><apex:outputText styleclass="req" value="*Type of Student:"/></td>
                <td width="63%">
                    <apex:selectList id="studentType" value="{!studentType}" multiselect="false" size="1" styleClass="inputRequired" onchange="HSReRender();">
                        <apex:selectOptions value="{!studentTypeOptions}"/>
                        <apex:actionSupport event="onchange" rerender="highSchoolPanel"/> 
                    </apex:selectList>
                </td>
            </tr>
        </tbody>
    </table>
    <table border="0" cellspacing="3" width="100%">
        <tbody>
            <tr class="highSchoolPanelH">
                <th colspan="2" class="highSchoolPanelH">High School Information</th>
            </tr>
            <tr class="highSchoolPanelH">
                <td width="37%" class="highSchoolPanelH">Home Schooled</td>
                <td width="63%" class="highSchoolPanelH" onchange="HSReRender()">
                    <apex:inputCheckbox id="homeSchooled" value="{!interest.Home_Schooled__c}">
                    <apex:actionSupport event="onclick" rerender="highSchoolPanel"/>
                    </apex:inputCheckbox>
                </td>
            </tr>
                
            </tbody> 
        </table>
    <table border="0" cellspacing="3" width="100%" id="highSchoolPanel" rendered="{!studentType=='Freshman' && (interest.Home_Schooled__c==null || interest.Home_Schooled__c==false)}">
        <tbody>
        <tr class="hsPanelH" rendered="{!studentType=='Freshman' && (interest.Home_Schooled__c==null || interest.Home_Schooled__c==false)}">
            <apex:outputText>  
              <td width="37%" class="hsPanelH" >*High School Country</td>
            </apex:outputText>
              <td width="63%" class="hsPanelH" rendered="{!studentType=='Freshman' && (interest.Home_Schooled__c==null || interest.Home_Schooled__c==false)}">
                  <apex:selectList id="hsPanelH" value="{!hscountry}" multiselect="False" size="1" styleClass="inputRequired">
                     <apex:selectOptions value="{!CountryOptions}"/>
                     <apex:actionSupport event="onchange" action="{!getHsStateRequired}" />
                  </apex:selectList>
              </td>
            </tr>
            </tbody>
        </table>
</apex:form>
</apex:define>
</apex:composition>
</apex:page> 
I am having a hard time getting the test class to fire part of the code.  I think the problem is with the owner of the custom object Territory__c, but can't figure out how to resolve it.  Any help will be greatly appreciated...

Here is the class:
public class TestScoreReviewClass {
/***************
 * When a new ACT or SAT test score is created, if
 * the student application decision is Decision Pending
 * or Postponed, create a task for the recruiter to
 * review the test scores
 ****************/
    Public static void sendTestScoreTask(Test_Score__c[] test_score){
        // Select the Contact.Id that ties to the Test_Score__c
        
        Set<string> contactId = new Set<string>();
        Set<ID> recID = new Set<ID>();
        
        for (Test_Score__c tz : test_score){
            if(tz.Contact__c != NULL) {
                contactid.add(tz.Contact__c);
            }
        }
        // Select the latest application tied to the new test score  
        Map<ID,Application__c> ApplInfo = new Map<ID,Application__c>([select Id, Student__c, Counselor_Id__c
                                  from application__c 
                                 where Student__r.Domestic_Or_International__c = 'Domestic' 
                                   and Application_Decision__c in ('Decision Pending','Postponed') 
                                   and Student__c in :contactid
                                 order by Entry_Term__c desc, Application_Date__c desc
                                  limit 1]);
      
   Date dt = Date.today();

   List<Task> followupTasks = new List<Task>();
// Generate a list of tasks to be generated

   Map<ID, List<Task> > tsks = New Map<ID, List<Task> >();
   
        
   List<Task> tsksadd = New List<Task>();
        
   For (Application__c c : ApplInfo.Values() )
   {
      //system.debug(c.Counselor_Id__c);
      recID.add(c.Counselor_Id__c);
       
      if (c.Student__c != null && c.Counselor_Id__c != null) 
      {
      
         List<Task> taskss = tsks.Get(c.Student__c);
         If (taskss == null)
         {

            Task tasks = new Task(
            WhoId = c.Student__c,
            OwnerId = c.Counselor_Id__c,
            Priority = 'Normal',
            Type = 'Email',
            ActivityDate = (dt.addDays(1)),
            Status = 'Not Started',
            Subject = 'Review New Test Score (ACT or SAT)');
      
            followupTasks.add(tasks);

          }
      }
   }

// insert the entire list
   if (followupTasks.size() > 0) {
      //system.debug(followupTasks.size());
      insert followupTasks;
   }
    }
}

Here is the test class:
@isTest
private class TestScoreReviewTest {

    static testMethod void myUnitTest() {        
    // Test Task
      test.startTest();
        
      Profile p = [SELECT Id FROM Profile WHERE Name='SNC Counselor Plus'];
      User u1 = new User(Alias = 'standa', Email='saplingstandarduser@testorg.com',
      EmailEncodingKey='ISO-8859-1', LastName='Testing', LanguageLocaleKey='en_US',
      LocaleSidKey='en_US', ProfileId = p.Id,
      TimeZoneSidKey='America/Mexico_City', UserName='saplingstandarduser@testorg.com');
       
        System.runAs(u1){
                
    // Create Territory
        Territory__c tr1 = new Territory__c(
                                Code__c = 'TestTerr',
                                County__c = 'Brown',
                                State__c = 'WI',
                                OwnerId = u1.Id);
        insert tr1;
        
    // Create Student
        Contact c1 = new Contact(
                    FirstName = 'Test',
                    LastName = 'TestStudent',
                    Domestic_Or_International__c = 'Domestic',
                    Territory__c = [Select t.Id from Territory__c t where t.Code__c = 'TestTerr' limit 1].Id);
            
        insert c1;    
        
    // Create Application
        Application__c a1 = new Application__c(
            Student__c = [Select c.Id from Contact c where c.LastName = 'TestStudent' limit 1].Id,
            Student_Type__c = 'First Time UG',
            Full_or_Part_Time__c = 'Full-Time',
            Active_Application__c = true,
            Application_Date__c = Date.today(),
            Application_Status__c = 'Decision Pending');
             
      insert a1;
        
    // Create Test_Score
        Test_Score__c t1 = new Test_Score__c(
            Contact__c = [Select c.Id from Contact c where c.LastName = 'TestStudent' limit 1].Id,
            Test_Date__c = '09/01/2016',
            Test_Type__c = 'School',
            ACT_Composite__c = 30,
            ACT_English__c = 16,
            ACT_Math__c = 16,
            ACT_Reading__c = 16,
            ACT_Science__c = 16
        );
        
        insert t1;
      
        test.stopTest();
        }
    }
}

Thank you for your time.

Darlene Blaney
St Norbert College
(920)403-3953
Hi all,

I have a simple trigger and class that recalculates a SAT recentered score.  The trigger works great, but I am having an issue with the test class.  Because there are so many possibilities, the best I can achieve is 50% coverage and I'm concerned about not being able to install into production.  I am including the test class for your viewing.  Any help would be greatly appreciated.

@isTest
private class ContactSATRecenteredTest {
    
    static testMethod void myUnitTest() {
        
        test.startTest();
        
        ContactSATRecentered controller = new ContactSATRecentered();
        
        Contact con = new Contact();
        Contact con1 = new Contact();
        Test_Score__c tst = new Test_Score__c();
        Test_Score__c tst1 = new Test_Score__c();
        
        con.FirstName = 'TestScore';
        con.LastName = 'NewTest';
        insert con;
        tst.Contact__c = con.Id;
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 800;
        insert tst;
        
        // Retrieve the new contact 36
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 790;
        update tst;
        
        // Retrieve the new contact 35
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 750;
        update tst;
        
        // Retrieve the new contact 34
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 730;
        update tst;
        
        // Retrieve the new contact 33
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 690;
        update tst;
        
        // Retrieve the new contact 32
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 660;
        update tst;
        
        // Retrieve the new contact 31
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 700;
        update tst;
        
        // Retrieve the new contact 30
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 690;
        update tst;
        
        // Retrieve the new contact 29
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 630;
        update tst;
        
        // Retrieve the new contact 28
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 600;
        update tst;
        
        // Retrieve the new contact 27
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 580;
        update tst;
        
        // Retrieve the new contact 26
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 530;
        update tst;
        
        // Retrieve the new contact 25
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 590;
        update tst;
        
        // Retrieve the new contact 24
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 560;
        update tst;
        
        // Retrieve the new contact 23
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 530;
        update tst;
        
        // Retrieve the new contact 22
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 500;
        update tst;
        
        // Retrieve the new contact 21
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 560;
        update tst;
        
        // Retrieve the new contact 20
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 500;
        update tst;
        
        // Retrieve the new contact 19
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 460;
        update tst;
        
        // Retrieve the new contact 18
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 420;
        update tst;
        
        // Retrieve the new contact 17
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 400;
        update tst;
        
        // Retrieve the new contact 16
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        tst.SAT_Math_Section_R__c = 450;
        update tst;
        
        // Retrieve the new contact 15
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        tst.SAT_Math_Section_R__c = 400;
        update tst;
        
        // Retrieve the new contact 14
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        //tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        //tst.SAT_Math_Section_R__c = 350;
        //update tst;
        
        // Retrieve the new contact 13
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        //tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        //tst.SAT_Math_Section_R__c = 300;
        //update tst;
        
        // Retrieve the new contact 12
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        tst.SAT_Math_Section_R__c = 250;
        update tst;
        
        // Retrieve the new contact 11
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
        
        con1.FirstName = 'TestScore';
        con1.LastName = 'OldTest';
        insert con1;
        tst1.Contact__c = con1.Id;
        tst1.SAT_Critical_Reading__c = 800;
        tst1.SAT_Math__c = 800;
        insert tst1;
        
        // Retrieve the new contact 36
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst1.SAT_Math_Section_R__c = 780;
        update tst1;
        
        // Retrieve the new contact 35
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst1.SAT_Math_Section_R__c = 720;
        update tst1;
        
        // Retrieve the new contact 34
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst1.SAT_Math_Section_R__c = 770;
        update tst1;
        
        // Retrieve the new contact 33
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst1.SAT_Math_Section_R__c = 720;
        update tst1;
        
        // Retrieve the new contact 32
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        //tst1.SAT_Math_Section_R__c = 680;
        //update tst1;
        
        // Retrieve the new contact 31
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        //tst1.SAT_Math_Section_R__c = 640;
        //update tst1;
        
        // Retrieve the new contact 30
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        //tst1.SAT_Math_Section_R__c = 600;
        //update tst1;
        
        // Retrieve the new contact 29
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 600;
        //tst1.SAT_Math_Section_R__c = 670;
        //update tst1;
        
        // Retrieve the new contact 28
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst1.SAT_Math_Section_R__c = 630;
        update tst1;
        
        // Retrieve the new contact 27
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];

        test.stopTest();
                
    }

}
Hi all,

Has anyone run into a similar situation to this? -
We ran into an issue with installing new custom Apex Classes saying the code coverage was < 75%.
After further review, I noticed that quite a few of our test classes for older classes are missing.
I know for a fact (because I built and installed most of them) that I would not have been able to install these classes without a test class.  Any ideas as to where to look?  I would open a ticket with Salesforce, but they changed the Developer support for Standard users to be this forum.

Any help would be greatly appreciated.

Thank you.
Darlene Blaney
St Norbert College
I would like to retrieve all of the picklist values I set up for a field on an object for display.  Does anyone know the object name to query to find this information?
I have a visualforce page where I select student type of freshman and display highschool information fields (that works fine).  But I want to hide the highschool country if the person checks the homeschooled checkbox.  I can't seem to get that to work. I am trying to use javascript to hide the fields.  Any help would be greatly appreciated.
vfp code:
<apex:page Controller="RFIForm" showHeader="false" standardStylesheets="FALSE">
<apex:includeScript value="{!$Resource.jQuery}"/>
<apex:composition template="{!$Site.Template}">
<apex:define name="body">
<script>
        
$(document).ready(function() {

    HSReRender();
});
    
function HSReRender(){
    var studentType = $("[id$=studentType]").val();
    var HomeSchooled = $("[id$=homeSchooled]").val();
    
    //$(".hsPanelH").hide();
    alert(HomeSchooled);
    if (studentType == "Freshman"){
        $(".highSchoolPanelH").show();
        if (HomeSchooled.checked){
        $(".hsPanelH").hide();
        alert('testing homeschooled checked');}
        else{
        $(".hsPanelH").show();
        alert('testing homeschooled not checked');}
        alert('testing freshman first');
    } else {
        $(".highSchoolPanelH").hide();
        $(".hsPanelH").hide();
        alert('testing freshman else first');
        }
    
    if ($(("#homeSchooled").is(":checked"))){
        //    if (studentType2 == "Freshman" && (HomeSchooled == null || HomeSchooled == false)){
        $(".hsPanelH").hide();
        alert('testing freshman and homeschooled checked');
    } else if (studentType == "Freshman"){
        $(".hsPanelH").show();
        alert('testing just freshman');
        } else {
           $(".hsPanelH").hide();
            alert('testing else');
        }
}
</script>
    <apex:pageMessages ></apex:pageMessages>
<apex:form Id="form">
    <h1 id="page-title">Request for Information </h1>
    <div style="width:100%">
        <p>
           <span class="contentText">Please enter your information in the fields below. When completed click on the <b>Submit</b> button at the bottom of page. Please allow 3 to 5 business days for processing your request for information.</span>
        </p>
        <p>
           <span class="contentText"><strong>* Indicates a required field.</strong></span>
        </p>
    </div>
    <table border="0" cellspacing="3" width="100%">
        <tbody>
            <tr>
                 <th colspan="2">Name and Personal Data</th>
            </tr> 
            <tr>
                <td width="37%"><apex:outputText styleclass="req" value="*Type of Student:"/></td>
                <td width="63%">
                    <apex:selectList id="studentType" value="{!studentType}" multiselect="false" size="1" styleClass="inputRequired" onchange="HSReRender();">
                        <apex:selectOptions value="{!studentTypeOptions}"/>
                        <apex:actionSupport event="onchange" rerender="highSchoolPanel"/> 
                    </apex:selectList>
                </td>
            </tr>
        </tbody>
    </table>
    <table border="0" cellspacing="3" width="100%">
        <tbody>
            <tr class="highSchoolPanelH">
                <th colspan="2" class="highSchoolPanelH">High School Information</th>
            </tr>
            <tr class="highSchoolPanelH">
                <td width="37%" class="highSchoolPanelH">Home Schooled</td>
                <td width="63%" class="highSchoolPanelH" onchange="HSReRender()">
                    <apex:inputCheckbox id="homeSchooled" value="{!interest.Home_Schooled__c}">
                    <apex:actionSupport event="onclick" rerender="highSchoolPanel"/>
                    </apex:inputCheckbox>
                </td>
            </tr>
                
            </tbody> 
        </table>
    <table border="0" cellspacing="3" width="100%" id="highSchoolPanel" rendered="{!studentType=='Freshman' && (interest.Home_Schooled__c==null || interest.Home_Schooled__c==false)}">
        <tbody>
        <tr class="hsPanelH" rendered="{!studentType=='Freshman' && (interest.Home_Schooled__c==null || interest.Home_Schooled__c==false)}">
            <apex:outputText>  
              <td width="37%" class="hsPanelH" >*High School Country</td>
            </apex:outputText>
              <td width="63%" class="hsPanelH" rendered="{!studentType=='Freshman' && (interest.Home_Schooled__c==null || interest.Home_Schooled__c==false)}">
                  <apex:selectList id="hsPanelH" value="{!hscountry}" multiselect="False" size="1" styleClass="inputRequired">
                     <apex:selectOptions value="{!CountryOptions}"/>
                     <apex:actionSupport event="onchange" action="{!getHsStateRequired}" />
                  </apex:selectList>
              </td>
            </tr>
            </tbody>
        </table>
</apex:form>
</apex:define>
</apex:composition>
</apex:page> 
I am having a hard time getting the test class to fire part of the code.  I think the problem is with the owner of the custom object Territory__c, but can't figure out how to resolve it.  Any help will be greatly appreciated...

Here is the class:
public class TestScoreReviewClass {
/***************
 * When a new ACT or SAT test score is created, if
 * the student application decision is Decision Pending
 * or Postponed, create a task for the recruiter to
 * review the test scores
 ****************/
    Public static void sendTestScoreTask(Test_Score__c[] test_score){
        // Select the Contact.Id that ties to the Test_Score__c
        
        Set<string> contactId = new Set<string>();
        Set<ID> recID = new Set<ID>();
        
        for (Test_Score__c tz : test_score){
            if(tz.Contact__c != NULL) {
                contactid.add(tz.Contact__c);
            }
        }
        // Select the latest application tied to the new test score  
        Map<ID,Application__c> ApplInfo = new Map<ID,Application__c>([select Id, Student__c, Counselor_Id__c
                                  from application__c 
                                 where Student__r.Domestic_Or_International__c = 'Domestic' 
                                   and Application_Decision__c in ('Decision Pending','Postponed') 
                                   and Student__c in :contactid
                                 order by Entry_Term__c desc, Application_Date__c desc
                                  limit 1]);
      
   Date dt = Date.today();

   List<Task> followupTasks = new List<Task>();
// Generate a list of tasks to be generated

   Map<ID, List<Task> > tsks = New Map<ID, List<Task> >();
   
        
   List<Task> tsksadd = New List<Task>();
        
   For (Application__c c : ApplInfo.Values() )
   {
      //system.debug(c.Counselor_Id__c);
      recID.add(c.Counselor_Id__c);
       
      if (c.Student__c != null && c.Counselor_Id__c != null) 
      {
      
         List<Task> taskss = tsks.Get(c.Student__c);
         If (taskss == null)
         {

            Task tasks = new Task(
            WhoId = c.Student__c,
            OwnerId = c.Counselor_Id__c,
            Priority = 'Normal',
            Type = 'Email',
            ActivityDate = (dt.addDays(1)),
            Status = 'Not Started',
            Subject = 'Review New Test Score (ACT or SAT)');
      
            followupTasks.add(tasks);

          }
      }
   }

// insert the entire list
   if (followupTasks.size() > 0) {
      //system.debug(followupTasks.size());
      insert followupTasks;
   }
    }
}

Here is the test class:
@isTest
private class TestScoreReviewTest {

    static testMethod void myUnitTest() {        
    // Test Task
      test.startTest();
        
      Profile p = [SELECT Id FROM Profile WHERE Name='SNC Counselor Plus'];
      User u1 = new User(Alias = 'standa', Email='saplingstandarduser@testorg.com',
      EmailEncodingKey='ISO-8859-1', LastName='Testing', LanguageLocaleKey='en_US',
      LocaleSidKey='en_US', ProfileId = p.Id,
      TimeZoneSidKey='America/Mexico_City', UserName='saplingstandarduser@testorg.com');
       
        System.runAs(u1){
                
    // Create Territory
        Territory__c tr1 = new Territory__c(
                                Code__c = 'TestTerr',
                                County__c = 'Brown',
                                State__c = 'WI',
                                OwnerId = u1.Id);
        insert tr1;
        
    // Create Student
        Contact c1 = new Contact(
                    FirstName = 'Test',
                    LastName = 'TestStudent',
                    Domestic_Or_International__c = 'Domestic',
                    Territory__c = [Select t.Id from Territory__c t where t.Code__c = 'TestTerr' limit 1].Id);
            
        insert c1;    
        
    // Create Application
        Application__c a1 = new Application__c(
            Student__c = [Select c.Id from Contact c where c.LastName = 'TestStudent' limit 1].Id,
            Student_Type__c = 'First Time UG',
            Full_or_Part_Time__c = 'Full-Time',
            Active_Application__c = true,
            Application_Date__c = Date.today(),
            Application_Status__c = 'Decision Pending');
             
      insert a1;
        
    // Create Test_Score
        Test_Score__c t1 = new Test_Score__c(
            Contact__c = [Select c.Id from Contact c where c.LastName = 'TestStudent' limit 1].Id,
            Test_Date__c = '09/01/2016',
            Test_Type__c = 'School',
            ACT_Composite__c = 30,
            ACT_English__c = 16,
            ACT_Math__c = 16,
            ACT_Reading__c = 16,
            ACT_Science__c = 16
        );
        
        insert t1;
      
        test.stopTest();
        }
    }
}

Thank you for your time.

Darlene Blaney
St Norbert College
(920)403-3953
Hi all,

I have a simple trigger and class that recalculates a SAT recentered score.  The trigger works great, but I am having an issue with the test class.  Because there are so many possibilities, the best I can achieve is 50% coverage and I'm concerned about not being able to install into production.  I am including the test class for your viewing.  Any help would be greatly appreciated.

@isTest
private class ContactSATRecenteredTest {
    
    static testMethod void myUnitTest() {
        
        test.startTest();
        
        ContactSATRecentered controller = new ContactSATRecentered();
        
        Contact con = new Contact();
        Contact con1 = new Contact();
        Test_Score__c tst = new Test_Score__c();
        Test_Score__c tst1 = new Test_Score__c();
        
        con.FirstName = 'TestScore';
        con.LastName = 'NewTest';
        insert con;
        tst.Contact__c = con.Id;
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 800;
        insert tst;
        
        // Retrieve the new contact 36
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 790;
        update tst;
        
        // Retrieve the new contact 35
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 750;
        update tst;
        
        // Retrieve the new contact 34
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 730;
        update tst;
        
        // Retrieve the new contact 33
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 690;
        update tst;
        
        // Retrieve the new contact 32
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst.SAT_Math_Section_R__c = 660;
        update tst;
        
        // Retrieve the new contact 31
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 700;
        update tst;
        
        // Retrieve the new contact 30
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 690;
        update tst;
        
        // Retrieve the new contact 29
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 630;
        update tst;
        
        // Retrieve the new contact 28
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 600;
        update tst;
        
        // Retrieve the new contact 27
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 580;
        update tst;
        
        // Retrieve the new contact 26
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst.SAT_Math_Section_R__c = 530;
        update tst;
        
        // Retrieve the new contact 25
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 590;
        update tst;
        
        // Retrieve the new contact 24
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 560;
        update tst;
        
        // Retrieve the new contact 23
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 530;
        update tst;
        
        // Retrieve the new contact 22
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst.SAT_Math_Section_R__c = 500;
        update tst;
        
        // Retrieve the new contact 21
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 560;
        update tst;
        
        // Retrieve the new contact 20
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 500;
        update tst;
        
        // Retrieve the new contact 19
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 460;
        update tst;
        
        // Retrieve the new contact 18
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 420;
        update tst;
        
        // Retrieve the new contact 17
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 500;
        tst.SAT_Math_Section_R__c = 400;
        update tst;
        
        // Retrieve the new contact 16
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        tst.SAT_Math_Section_R__c = 450;
        update tst;
        
        // Retrieve the new contact 15
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        tst.SAT_Math_Section_R__c = 400;
        update tst;
        
        // Retrieve the new contact 14
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        //tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        //tst.SAT_Math_Section_R__c = 350;
        //update tst;
        
        // Retrieve the new contact 13
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        //tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        //tst.SAT_Math_Section_R__c = 300;
        //update tst;
        
        // Retrieve the new contact 12
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
               
        tst.SAT_Evidence_Reading_Writing_Section__c = 400;
        tst.SAT_Math_Section_R__c = 250;
        update tst;
        
        // Retrieve the new contact 11
        //con = [select SAT_Super_Score_Recentered__c from contact where id = :con.id];
        
        con1.FirstName = 'TestScore';
        con1.LastName = 'OldTest';
        insert con1;
        tst1.Contact__c = con1.Id;
        tst1.SAT_Critical_Reading__c = 800;
        tst1.SAT_Math__c = 800;
        insert tst1;
        
        // Retrieve the new contact 36
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst1.SAT_Math_Section_R__c = 780;
        update tst1;
        
        // Retrieve the new contact 35
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 800;
        tst1.SAT_Math_Section_R__c = 720;
        update tst1;
        
        // Retrieve the new contact 34
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst1.SAT_Math_Section_R__c = 770;
        update tst1;
        
        // Retrieve the new contact 33
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        tst1.SAT_Math_Section_R__c = 720;
        update tst1;
        
        // Retrieve the new contact 32
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        //tst1.SAT_Math_Section_R__c = 680;
        //update tst1;
        
        // Retrieve the new contact 31
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        //tst1.SAT_Math_Section_R__c = 640;
        //update tst1;
        
        // Retrieve the new contact 30
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 700;
        //tst1.SAT_Math_Section_R__c = 600;
        //update tst1;
        
        // Retrieve the new contact 29
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        //tst1.SAT_Evidence_Reading_Writing_Section__c = 600;
        //tst1.SAT_Math_Section_R__c = 670;
        //update tst1;
        
        // Retrieve the new contact 28
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];
        
        tst1.SAT_Evidence_Reading_Writing_Section__c = 600;
        tst1.SAT_Math_Section_R__c = 630;
        update tst1;
        
        // Retrieve the new contact 27
        //con1 = [select SAT_Super_Score_Recentered__c from contact where id = :con1.id];

        test.stopTest();
                
    }

}
Hi all,

Has anyone run into a similar situation to this? -
We ran into an issue with installing new custom Apex Classes saying the code coverage was < 75%.
After further review, I noticed that quite a few of our test classes for older classes are missing.
I know for a fact (because I built and installed most of them) that I would not have been able to install these classes without a test class.  Any ideas as to where to look?  I would open a ticket with Salesforce, but they changed the Developer support for Standard users to be this forum.

Any help would be greatly appreciated.

Thank you.
Darlene Blaney
St Norbert College
I would like to retrieve all of the picklist values I set up for a field on an object for display.  Does anyone know the object name to query to find this information?