• developer sri
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 13
    Replies

I have Bigmachine Custom Object

In this i have 3 Fields

1. Scope__c

2. Scope1__c

3. Scope2__c.

 

Scope1__c and Scope2__c are Formula fields and Scope__c field is Number and is summation of Scope1__c and Scope2__c.

 

Below trigger gives me proper Scope__c values.

 

Trigger generateFields on Bigmachine__c (before insert,before update) {       

Bigmachine__c big = Trigger.New[0];            

big.Scope__c=big.Scope1__c-der.Scope2__c;

}

 

When I am writing Test class for this Trigger I am getting this :

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, generateFields: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.generateFields: line 3, column 1: []

 

My Test class is:

 

@isTest(SeeAllData=true) public with sharing class generateFieldsTest {       

static testMethod void validatefields(){ 

Bigmachine__c big = new Bigmachine__c();

list<Bigmachine__c> bg = [select  Scope1__c, Scope2__c from Bigmachine__c];    

for(Bigmachine__c b : bg){       

if(b.Scope1__c !=null && b.Scope2__c != null)

{      

big.Scope__c = b.Scope1__c - b.Scope2__c;       

if(big.Scope__c > 0)

{        

try{            

insert big;             

}

catch(dmlexception de)

{

system.debug('!!!!!!' +de.getmessage());

throw de;            

}  

 }    

  }

  }  

 }

}

 

I am getting somehow code coverage but my test method is getting failed.

 

Can somebody please help me out to pass my test class and get the proper code coverage

 

Thanks in advance!!!!!!!!

I have Bigmachine Custom Object

In this i have 3 Fields

1. Scope__c

2. Scope1__c

3. Scope2__c.

 

Scope1__c and Scope2__c are Formula fields and Scope__c field is Number and is summation of Scope1__c and Scope2__c.

 

Below trigger gives me proper Scope__c values.

 

Trigger generateFields on Bigmachine__c (before insert,before update) {       

Bigmachine__c big = Trigger.New[0];            

big.Scope__c=big.Scope1__c-der.Scope2__c;

}

 

When I am writing Test class for this Trigger I am getting this :

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, generateFields: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.generateFields: line 3, column 1: []

 

My Test class is:

 

@isTest(SeeAllData=true)
public with sharing class generateFieldsTest { 
 
    static testMethod void validatefields(){ 

    Bigmachine__c big = new Bigmachine__c();

    list<Bigmachine__c> bg = [select  Scope1__c, Scope2__c from Bigmachine__c];
    for(Bigmachine__c b : bg){
      if(b.Scope1__c !=null && b.Scope2__c != null){
      big.Scope__c = b.Scope1__c - b.Scope2__c;
      if(big.Scope__c > 0){
        try{
            insert big;
             }catch(dmlexception de){
            system.debug('!!!!!!' +de.getmessage());
            throw de;
            }
          }
        }
     }
   }
}

 

I am getting somehow code coverage but my test method is getting failed.

 

Can somebody please help me out to pass my test class and get the proper code coverage

 

Thanks in advance!!!!!!!!

Hello Professionals!!!!!

 

Here i need one logic to populate the sum of field values... please help me out in this. I will be very thankful to you

 

I have Quote object, Structure__c object and Bigmachine__c object.

Quote -- Structure__c                         >>>> Master Detail relationship
Quote -- Bigmachine__c                   >>>> Lookup relationship
Structure__c -- Bigmachine__c       >>>> Lookup relationship

On Quote I can create multiple "Structure" records and on "Structure" object, i have "scope" field of number data type.
On "Bigmachine" object i have "Total scope" field which needs to be populated as the sum of all the "scope" field values.

 

 

Hoping a favorable response.

 

 

Thank you!!!!!!!!

Can somebody help me out in creating Test Class for the below class:

 

Main aim of my class is to create a "abc object" record on the creation of Quote record.

 

Relation between abc__c and Quote is lookup relationship:

 

trigger AA on Quote( after insert) {

List<abc__c> abcs = new List <abc__c>();

 List<Id> qtIdList = new List<id>();    

for(quote qt: Trigger.new)    

{        

if (Trigger.isUpdate && Trigger.isAfter)

{            

qtIdList.add(qt.id);        

}    

}                  

for(Quote qt: Trigger.new) {  

 if (Trigger.isInsert && Trigger.isAfter) {                    

abc__c abc = new abc__c();            

abc.opportunity__c = qt.OpportunityId;            

abc.Quote__c = qt.id;            

abc.name = qt.Name;            

abcs.add(abc);            

system.debug(LoggingLevel.DEBUG, '@@@@@ abc object created = ' + abc);

try{  

insert abcs;  

} catch (Dmlexception dmlE )

{        

system.debug(LoggingLevel.ERROR , 'DML exception while inserting opportunity related inserts =' + dmlE.getMessage());    

}    

system.debug(LoggingLevel.INFO, '@@@@@ Custom abc inserted = ' + abcs);

}

Hi.. Can someone suggest me writing test class for below enum class

 

my Enum class is :

 

public enum ProductType {   

Primary,   

Luxury,   

Sedan

}

 

Thank you

Hi.. Can someone suggest me writing test class for below enum class

 

my Enum class is :

 

public enum ProductType {
   Primary,
   Luxury,
   Sedan
}

 

I tried this but strucked in middle of this, need some help in making >75% code coverage for this.

 

@isTest
Public with sharing class ProductTypeTest{
    Public static testMethod void validateEnum(){
   
    }
}

 

Thanks in advance

 

 

can somebody help me writing Test class for below class:

 

public with sharing class classone {

 public static double getmethod1l( String param 1, 
       String param2, decimal param3){
       
        double method1Qty = 0;
        
       If ( param1.contains('32x2x33') && (param1.contains('pentium1') || 
         param1.contains('Core_')) && !param1.contains('AQ') && 
         !param1.contains('12W') && !param2.contains('LED')){
                                 
                method1Qty = param3;           
            
        }
        return method1Qty;
        
   } // end of getmethod1     

can someone please help me in writing test class for this class:

public with sharing class BigMachinecls { 

public static double getU(String BB, String Rools, String Foo, double qty, String teks){


double UQty = 0.0;

If ( (BB == null || BB == 'N') && (Rolls == null || Rolls == 'N') && (Foo == null || Foo == 'N') ){

UQty = qty /double.valueof(teks);

System.debug('@@@@@ inside getU method U : - Quantity - ' + UQty);


}
return UQty;

}//End of getU() method

public static double getMachineDetail( String machine1, String machineGroup, decimal qty, String checks){

double MachineDetailQuantity = 0;

If ( machine1.contains('tata') && (machine1.contains('Tek') || 
machine1.contains('X1')) && !machine1.contains('23HP') && 
!machine1.contains('125HP') && !machineGroup.contains('MECH_ALEN')){


MachineDetailQuantity = qty;

System.debug('@@@@@ inside getMachineDetail Qty : ' + MachineDetailQuantity );


}
return MachineDetailQuantity;

} // end of getMachineDetailQuantity method 


Thanks in advance

I have Bigmachine Custom Object

In this i have 3 Fields

1. Scope__c

2. Scope1__c

3. Scope2__c.

 

Scope1__c and Scope2__c are Formula fields and Scope__c field is Number and is summation of Scope1__c and Scope2__c.

 

Below trigger gives me proper Scope__c values.

 

Trigger generateFields on Bigmachine__c (before insert,before update) {       

Bigmachine__c big = Trigger.New[0];            

big.Scope__c=big.Scope1__c-der.Scope2__c;

}

 

When I am writing Test class for this Trigger I am getting this :

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, generateFields: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.generateFields: line 3, column 1: []

 

My Test class is:

 

@isTest(SeeAllData=true) public with sharing class generateFieldsTest {       

static testMethod void validatefields(){ 

Bigmachine__c big = new Bigmachine__c();

list<Bigmachine__c> bg = [select  Scope1__c, Scope2__c from Bigmachine__c];    

for(Bigmachine__c b : bg){       

if(b.Scope1__c !=null && b.Scope2__c != null)

{      

big.Scope__c = b.Scope1__c - b.Scope2__c;       

if(big.Scope__c > 0)

{        

try{            

insert big;             

}

catch(dmlexception de)

{

system.debug('!!!!!!' +de.getmessage());

throw de;            

}  

 }    

  }

  }  

 }

}

 

I am getting somehow code coverage but my test method is getting failed.

 

Can somebody please help me out to pass my test class and get the proper code coverage

 

Thanks in advance!!!!!!!!

I have Bigmachine Custom Object

In this i have 3 Fields

1. Scope__c

2. Scope1__c

3. Scope2__c.

 

Scope1__c and Scope2__c are Formula fields and Scope__c field is Number and is summation of Scope1__c and Scope2__c.

 

Below trigger gives me proper Scope__c values.

 

Trigger generateFields on Bigmachine__c (before insert,before update) {       

Bigmachine__c big = Trigger.New[0];            

big.Scope__c=big.Scope1__c-der.Scope2__c;

}

 

When I am writing Test class for this Trigger I am getting this :

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, generateFields: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.generateFields: line 3, column 1: []

 

My Test class is:

 

@isTest(SeeAllData=true)
public with sharing class generateFieldsTest { 
 
    static testMethod void validatefields(){ 

    Bigmachine__c big = new Bigmachine__c();

    list<Bigmachine__c> bg = [select  Scope1__c, Scope2__c from Bigmachine__c];
    for(Bigmachine__c b : bg){
      if(b.Scope1__c !=null && b.Scope2__c != null){
      big.Scope__c = b.Scope1__c - b.Scope2__c;
      if(big.Scope__c > 0){
        try{
            insert big;
             }catch(dmlexception de){
            system.debug('!!!!!!' +de.getmessage());
            throw de;
            }
          }
        }
     }
   }
}

 

I am getting somehow code coverage but my test method is getting failed.

 

Can somebody please help me out to pass my test class and get the proper code coverage

 

Thanks in advance!!!!!!!!

Can somebody help me out in creating Test Class for the below class:

 

Main aim of my class is to create a "abc object" record on the creation of Quote record.

 

Relation between abc__c and Quote is lookup relationship:

 

trigger AA on Quote( after insert) {

List<abc__c> abcs = new List <abc__c>();

 List<Id> qtIdList = new List<id>();    

for(quote qt: Trigger.new)    

{        

if (Trigger.isUpdate && Trigger.isAfter)

{            

qtIdList.add(qt.id);        

}    

}                  

for(Quote qt: Trigger.new) {  

 if (Trigger.isInsert && Trigger.isAfter) {                    

abc__c abc = new abc__c();            

abc.opportunity__c = qt.OpportunityId;            

abc.Quote__c = qt.id;            

abc.name = qt.Name;            

abcs.add(abc);            

system.debug(LoggingLevel.DEBUG, '@@@@@ abc object created = ' + abc);

try{  

insert abcs;  

} catch (Dmlexception dmlE )

{        

system.debug(LoggingLevel.ERROR , 'DML exception while inserting opportunity related inserts =' + dmlE.getMessage());    

}    

system.debug(LoggingLevel.INFO, '@@@@@ Custom abc inserted = ' + abcs);

}

Hi.. Can someone suggest me writing test class for below enum class

 

my Enum class is :

 

public enum ProductType {   

Primary,   

Luxury,   

Sedan

}

 

Thank you

Hi.. Can someone suggest me writing test class for below enum class

 

my Enum class is :

 

public enum ProductType {
   Primary,
   Luxury,
   Sedan
}

 

I tried this but strucked in middle of this, need some help in making >75% code coverage for this.

 

@isTest
Public with sharing class ProductTypeTest{
    Public static testMethod void validateEnum(){
   
    }
}

 

Thanks in advance

 

 

can someone please help me in writing test class for this class:

public with sharing class BigMachinecls { 

public static double getU(String BB, String Rools, String Foo, double qty, String teks){


double UQty = 0.0;

If ( (BB == null || BB == 'N') && (Rolls == null || Rolls == 'N') && (Foo == null || Foo == 'N') ){

UQty = qty /double.valueof(teks);

System.debug('@@@@@ inside getU method U : - Quantity - ' + UQty);


}
return UQty;

}//End of getU() method

public static double getMachineDetail( String machine1, String machineGroup, decimal qty, String checks){

double MachineDetailQuantity = 0;

If ( machine1.contains('tata') && (machine1.contains('Tek') || 
machine1.contains('X1')) && !machine1.contains('23HP') && 
!machine1.contains('125HP') && !machineGroup.contains('MECH_ALEN')){


MachineDetailQuantity = qty;

System.debug('@@@@@ inside getMachineDetail Qty : ' + MachineDetailQuantity );


}
return MachineDetailQuantity;

} // end of getMachineDetailQuantity method 


Thanks in advance