• anisha
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

 

public class BMGlobal {
    public static final String Test1= 'Test1';
    public static final String Test2 = 'Test2';
    public static final String Test3 = 'Test3';
     }

@istest
Private class BmglobalTest{
  Static testmethod void bm()
  {
     String s1 =BMGlobal.Test1;
     String s2 =BMGlobal.Test2;
     String s3 =BMGlobal.Test3;
    system.assertEquals(s1,'Test1');
   system.assertEquals(s2,'Test2');
   System.assertEquals(s3,'Test3');
  }
}

We have to write test class for Above Class.
Below one is Test class. while runnig test class we are not getting error but code covergae is 0.

 

Can you please help me how to increase code coverage.

Thanks in Advance

Nikhil

 

  • October 08, 2012
  • Like
  • 0

Hi

    We want to create a custom button for leadconvert and it will be converted to opportunity only(not account and contact) and it will check wheither the rating is hot or not.......plz help

 

My controller Class :

 

public class leadController
{
    Public lead lObj;
    Public Id leadId;
    public leadController(ApexPages.StandardController stdController)
    {
        leadId = ApexPages.currentPage().getParameters().get('id');
        lObj = (leadid == null) ? new Lead():[SELECT Name, Rating from lead where id =: leadid];
    }
    public PageReference autoRun()
    {
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(leadId);
        LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
        lc.setConvertedStatus(convertStatus.MasterLabel);
        if(lObj.Rating == 'Hot'){
        Database.LeadConvertResult lcr = Database.convertLead(lc);
        System.assert(lcr.isSuccess());
        Id oppId = lcr.getOpportunityId();
        PageReference Page = new PageReference('https://ap1.salesforce.com/'+oppId);
        Page.setRedirect(true);
        return Page;
        }
        else{
        lObj.addError('Lead cannot be converted without Product Selection !');
        lObj.addError('Please Select Atleast One Product');
        }
        return null;
    }
    Public PageReference RedirecttoLead(){
        PageReference Page = new PageReference('https://ap1.salesforce.com/'+leadId);
        Page.setRedirect(true);
        return Page;
    }
}

My Visualforce Page:

<apex:page standardController="lead" cache="true" action="{!autorun}" extensions="leadController" >
<br/><br/>
<apex:messages style="color:red; font-weight:bold; text-align:center;"/>
<apex:form >
<center>
<apex:commandLink value="Redirect to Lead" style="color:blue; font-weight:bold;" action="{!RedirecttoLead}"/>
</center>
</apex:form>
</apex:page>

  • December 26, 2011
  • Like
  • 0

Hi everyone,

I have small doubt, and I dont know how to solve it . Please help me to solve my issue. I'm new to salesforce

list<sObject> slist = new list<sObject>();

sList =[select TotalSize__c from sObject where id in : 90908908];

TotalSize__c is a Integer field.

 

How will I compare the value of TotalSize__c  that I got in sList to theTotalSize__c Integer data type as sList returns sObject data type.

I am trying to comapre using if conditon (if sList.get[0] == 4). it is throwing error as :

Compile Error: Initial term of field expression must be a concrete SObject: LIST<sObject> for the line number : (if sList.get[0] == 4).

  • May 02, 2013
  • Like
  • 0

 

public class BMGlobal {
    public static final String Test1= 'Test1';
    public static final String Test2 = 'Test2';
    public static final String Test3 = 'Test3';
     }

@istest
Private class BmglobalTest{
  Static testmethod void bm()
  {
     String s1 =BMGlobal.Test1;
     String s2 =BMGlobal.Test2;
     String s3 =BMGlobal.Test3;
    system.assertEquals(s1,'Test1');
   system.assertEquals(s2,'Test2');
   System.assertEquals(s3,'Test3');
  }
}

We have to write test class for Above Class.
Below one is Test class. while runnig test class we are not getting error but code covergae is 0.

 

Can you please help me how to increase code coverage.

Thanks in Advance

Nikhil

 

  • October 08, 2012
  • Like
  • 0

Hi,

 

Master Object > Master

Master Object Field > Detail

 

Child Object > Master__c

Child Object Field > Detail__c

 

 

 

 

to meet this requirement i have developed something like, i am able to update the master object field with the detail object field but not with the multiple detail object record. Please help....

 

trigger proposalstatus on Master__c (after insert,after update)
{

   List<Master> opps = new List<Master>();
   List<ID> masterIds = new List<ID>();
   Map<ID, String> childDetailMap = new Map<ID, String>();
  
   for(Master__c c: Trigger.new)
    {
      masterIds.add(c.RMG_Employee_Code__c);
      childDetailMap.put(c.RMG_Employee_Code__c, (c.Detail__c));
    }
    opps = [select id, Detail from Master where id in :masterIds];
 
   for(Master rem: opps)
    {
      rem.Detail = childDetailMap.get(rem.id);
    }
    if(opps.size() > 0)
    {
     Update opps;
     }
}

 

  • January 27, 2011
  • Like
  • 0