• SFDC Vaibhav
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Hi Friends,

I getting small problem while covering a test class. I am not able to call one method from controller to testclass. Could you please help to me.

------------------------------------------      Controller       -----------------------------------------


public with sharing class AccountDealOpportunity {

    public AccountDealOpportunity(ApexPages.StandardController controller)    // I Want to call This method

        
        lstOpp = new List<Opportunity__c>();
        AccId = ApexPages.currentPage().getParameters().get('id');
        Account iAcc = [SELECT id, Recordtype.Name, Name FROM Account WHERE Id =: AccId];
        String Query = 'SELECT id, Name, Originator__c, Investor__c, Interested_Products__c, Asset_Class__c, Investor_Category__c,'+
                        +'Amount__c,Valid_Till__c,RecordType.Name FROM Opportunity__c where ';
        if(iAcc.RecordType.Name == 'Investor')
        {
            query = query + 'Investor__c =: AccId';
        }
        else if(iAcc.RecordType.Name == 'Originator')
        {
            query = query + 'Originator__c =: AccId';
        }
        lstOpp = Database.query(query);
    }


    public List<Opportunity__c> lstOpp {get;set;}
    Public Boolean isShowOpp {get;set;}
    String AccId;
    
    public AccountDealOpportunity()
    {
        
    }
    
    public pageReference CreateDeal()
    {
        PageReference DealPage = new PageReference('/apex/CreateDeals?id=' + AccId);
        DealPage.setRedirect(true);
        return DealPage;
    }
    
    public pageReference OpportunitytoDeal()
    {
        return Null;
    }

}



-------------------------------------------------   Test Class   --------------------------------

/*-------------------------------------------------
Created Date  : 10/05/2017
Refered Class : AccountDealOpportunity.
------------------------------------------------- */

@IsTest(SeeAllData = True)
public class AccountDealOpportunityTest{

public static testMethod void AccountDealMethod(){
String AccId;
//List<Opportunity__c> lstOpp = new List<Opportunity__c>();

AccId = ApexPages.currentPage().getParameters().get('id');
   
    
    
/*Account Duplicate Values Fixed */
Account acc = New Account();
acc.Name = 'Test Account';
//acc.Recordtype.Name = 'Originator';
insert acc;

 /* String Query = 'SELECT id, Name, Originator__c, Investor__c, Interested_Products__c, Asset_Class__c, Investor_Category__c,'+
                        +'Amount__c,Valid_Till__c,RecordType.Name FROM Opportunity__c where ';
                        
   if(acc.RecordType.Name == 'Investor')
        {
            query = query + 'Investor__c = 00Np0000001FjCGEA0';
        }
        else if(acc.RecordType.Name == 'Originator')
        {
            query = query + 'Originator__c = 00Np0000001FjCL';
        }
           */                     


/*Opportunity Duplicate Values Fixed */
Opportunity__c opp = New Opportunity__c();
opp.name = 'Test Opportunity';
//opp.Originator__c = '00Np0000001FjCL';
//opp.Investor__c   = '00Np0000001FjCGEA0';
opp.Interested_Products__c = 'Term Loan';
opp.Asset_Class__c ='AHF';
opp.Investor_Category__c = 'NBFC';
opp.Amount__c = 1000;
opp.Valid_Till__c = date.parse('11/6/2017');
//opp.RecordType.Name = 'Originator';

insert opp;

AccountDealOpportunity accts = New AccountDealOpportunity();
accts.CreateDeal();
accts.OpportunitytoDeal();
//accts.AccountDealOpportunity();
AccountDealOpportunity(ApexPages.StandardController controller)  //
}
}


Error: Compile Error: expecting a right parentheses, found 'controller' at line 55 column 58



Many Thanks In Advance ......

Regards,
Soundar Rajan P
7418425418

I have a custom object "Projects__c" and standard "Opportunities" as a related list to projects via a lookup relationship. 

When a user creates a new Opportunity from the Projects__c object, I would like some values from the Project record to prepopulate in the opportunity when it is created. Is there a way to do this with a lookup relationship and Trigger? I know workflow and PB can only do this on save of the new record which would defeat the purpose, and am trying to avoid a URL hack. 

I don't know code other than the first two lines of the trigger, beyond that I get lost. Any suggestions?