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

hi everybody, can any body write test coverage for these two methods

//class creation
public with sharing class UploadAssetController

//cunstrutor creation
public UploadAssetController ()
selObject = 'Asset';
//Fetching hard coded 'IT Equipment' classification for default to all assets
List<ServoTerraClassification__c> classificationList = [select id, name from ServoTerraClassification__c where name ='IT Equipment'];
if(classificationList != null && classificationList.size() > 0){
ITClassificationObject = classificationList.get(0);
//**************************write test classes for these below two methods**********************************************************************
//create all asset components
public void createAssetComponent(sevro_Terra_Asset__c assetObject, string componentName ,string componentValue){
string componentId = getComponentId(componentName, assetObject.servo_Terra_Category__c);
string componentValueId = getComponentValueId(componentId , componentValue);
//create new component object
createComponentObject(assetObject, componentId,componentValueId);


//create single asset component object
public void createComponentObject(sevro_Terra_Asset__c assetObject, string componentId, string componentValueId)
String assetId =;
if(assetComponentsMap !=null && assetComponentsMap.size() > 0 && assetComponentsMap.get(assetId+fieldSep+componentId+fieldSep+componentValueId) != null){
return ;
//Creates new component object
servo_Terra_Asset_Component__c componentObject = new servo_Terra_Asset_Component__c();
componentObject.sevroTerraAsset__c = assetId;
componentObject.servoTerraComponent__c = componentId;
componentObject.servoTerraComponentValue__c = componentValueId;
here the objects are
sevro_Terra_Asset__c ,servo_Terra_Category__c, servoTerraComponent__c 








These methods are looking like normal methods you can try to write the test classes.

If you have any problem while writing the test classes, please post the code and problem here so that you will get good response and answers from board.


Any way am giving the skeleton of Test classes which will help you to write the test class and complete those and let us know if you have any difficulties in writing those.


private class TestUploadAssetController
   static testMethod void test createAssetComponent() 
   //create test data whatever required
   // call that method like below
   UploadAssetController uac = new UploadAssetController()
   uac.createAssetComponent()// here pass required data/parameters which you have inserted before calling this method 
  //if you calll above method then this method will call the secod method(provide prover test data)