• karan p
  • 5 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
  • 0
Hello all

I have "contaminats" Object as a related list for Cases and the field in the objects were as follows (Name, Feed(CheckBox), Regeneration medium(CheckBox)). i need to Auto create 6 contaminats (oxygen,CO,H2,Olefins,Sulfur  components,Chloride components) upon case creation as unchecked
Can any one help me with a class to create these contaminats .
hello all

Below is my apex class could you please help me out to correct my test class to improve my code coverage 

public class callmeetings
    public Map<Id, Call_Meeting__c> cmMap {get; set;}
    public String selectedcm{get; set;}
    public String tuId;
    public callmeetings()
        tuId = ApexPages.currentPage().getParameters().get('tId');        
        cmMap = new Map<Id, Call_Meeting__c>([Select Id, Name, User__c, User__r.Name, Treating_Unit__c from Call_Meeting__c WHERE Treating_Unit__c = null]);
    public PageReference selectThis() {
            Call_Meeting__c tempMeeting = cmMap.get(selectedcm);
            tempMeeting.Treating_Unit__c = tuId;
            update tempMeeting;
            return (new PageReference('/'+tuId));
            return null;

Test class 

private class callmeetingsTest
    static testMethod void updateCallmeeting()
        id uopAccountId;
        Schema.DescribeSObjectResult d1 = Schema.SObjectType.Account;
        Map<String,Schema.RecordTypeInfo> rtMap1 = d1.getRecordTypeInfosByName();
        Schema.RecordTypeInfo uoprt =rtMap1.get('UOP Accounts');
        ContactRecordType__c rectype = new ContactRecordType__c();
        insert rectype;
        Profile p=[select id from Profile where Name='UOP - Business'];
        UOP_Profiles__c up=new UOP_Profiles__c();
        up.Name='UOP Profile ID List';
        insert up;
        sales_district__c sd=new sales_district__c();
        insert sd;
        system.debug('*******sales district********'+sd);
        Uop_geo_region__c ur=new Uop_geo_region__c ();
        ur.Name='INDIAN SUBCONTINENT';
        insert ur;
        SAP_Customer_Info__c testcustomer = new SAP_Customer_Info__c();       
        testcustomer.UOP_Company_Name__c='AGIPPETROIL SPA';
        testcustomer.UOP_Address1__c='DEVKARAN MANSION IIND FLR';
        testcustomer.UOP_Address2__c='79 PRINCESS STREET';
        insert testcustomer; 
        Country__c c=new Country__c();
        insert c;
        Account acc=new Account();
        acc.Name='Test Name';
        acc.BillingStreet ='sfdc';
        acc.BillingState ='sfdc';
        acc.BillingCountry ='INDIA';
        insert acc;

        acc= [Select OwnerID, Owner.ID From Account where ID = :acc.id];
        Treating_Units__c TU = New Treating_Units__c ();
        TU.Carrier_Stream__c='Natural GAS';
        insert TU;
        Call_Meeting__c CM = New Call_Meeting__c ();
        CM.Company__c= acc.ID;
        CM.Due_Date__c = Datetime.newInstance(2016, 8, 16);
        insert CM; 
Hello as i am new to test classes Could  any one let me know how to write a test class for my utility class that is declared in my trigger.
. the purpose of the below code is we wanted to clone an opportunity with related old opportunity related class

public class treatingDatabaseTrigger_UtilityClass  
    public static void treatingDatabase(List<opportunity> newRecord)
        Set<Id> recordTypeIds = new Set<Id>();
        Set<Id> oldOppIds = new Set<Id>();
        recordTypeIds.add(Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Child Opportunity').getRecordTypeId());
        recordTypeIds.add(Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('CA&S Opportunity').getRecordTypeId());
        List<treating__c> insertList = new List<treating__c>();
        for(Opportunity opp : newRecord)
            if((opp.ID__c != null) && (recordTypeIds.contains(opp.RecordTypeId)))
            Map<Id, Opportunity> oldOppMap = new Map<Id, Opportunity>([Select Id, (Select Id, Opportunity__c, Treating_Unit__c from Treating_Databases__r) from Opportunity WHERE Id IN :oldOppIds]);
            for(Opportunity opp : newRecord)
                    for(treating__c eachtreating : oldOppMap.get(opp.ID__c).Treating_Databases__r)
                        treating__c newtreating = new treating__c();
                        newtreating.Treating_Unit__c = eachtreating.Treating_Unit__c;
                        newtreating.Opportunity__c = opp.Id;
            insert insertList;
public class LeadRLinAccountController
  public Account acc;
  public List<lead> leadRec {get; set;}
  public List<Lead> shortViewLst {get; set;}
  public boolean shortview {get; set;}
  public LeadRLinAccountController(ApexPages.standardController stdCon)
    shortview = TRUE;
    leadRec=[select id,convertedAccountId,Lead_name_link__c, createdDate,email, Company, LeadSource, Status,ConvertedDate FROM Lead where convertedAccountId=:acc.id  and  isConverted=true];
    shortViewLst = new List<Lead>();
        for(integer i=0; i<leadRec.size(); i++)
  public PageReference relatedRecords()
    shortview = FALSE;
    return null;