• Jay Srinivasan
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi all, 

I am trying to get my quotes to autosync to the opportunity upon creation.  I have the following controller, trigger, and test class:

controller:
public class QuoteAutoSyncUtil
    {
        @future
        public static void syncQuote(Map<Id, Id> quoteMap)
        {
            List<Opportunity> oppList = new List<Opportunity>();
           
            for(Id currentQuote : quoteMap.keyset())
            {
                Opportunity opp = new Opportunity();
                opp.Id = quoteMap.get(currentQuote);
                opp.SyncedQuoteId = currentQuote;
                oppList.add(opp);
            }

            update oppList;
     
        }
       
    }


Trigger:
trigger QuoteAutoSync on Quote (after insert)
    {
        Map<Id, Id> quoteMap = new Map<Id, Id>();
        for(Quote currentQuote : Trigger.New)
        {
              quoteMap.put(currentQuote.Id, currentQuote.OpportunityId);
        }
       
        QuoteAutoSyncUtil.syncQuote(quoteMap);
    }


Test Class:
@isTest
    private class TestQuoteAutoSync
    {
        static testMethod void insertQuote()
        {
            Opportunity opp = new Opportunity();
            opp.Name = 'Test Opportunity';
            opp.StageName = 'Prospecting';
            opp.CloseDate = system.today();
            insert opp;
           
            Quote quo = new Quote();
            quo.Name = 'Test Quote';
            quo.OpportunityId = opp.Id;        
           
            Test.startTest();
            insert quo;
            Test.stopTest();
           
            Opportunity o = [select SyncedQuoteId from opportunity where id=:opp.Id];
            system.assert(o.SyncedQuoteId != null);
                   
        }
    }

It is functioning properly in Sandbox and clears tests with 100% coverage but when I try to push to Production I get the following error with the test class:

System.AssertException: Assertion Failed
Stack Trace: Class.TestQuoteAutoSync.insertQuote: line 21, column 1

*Line 21 = system.assert(o.SyncedQuoteId != null);


Any ideas what I am missing? 

Thanks!
 

Hi,

   I have this field (xyz)of type input text area on my visualforce page as <apex:inputField  value ="{!Opportunity.xyz__c}"/>. If i give characters more than the default limit of  text area type, Then it gives an error message , which should happen. But instead of one I am getting two error messages below that field. Can anyone please suggest me a way to rectify this issue?