• Madhukar Reddy Vuradi
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
User-added image
I am confused with the term merged.
when i launch it shows this page
User-added image

when i install a package it shows me this

User-added image
The package is installing here.
When check for the challenge it is showing that the packae is not installed.
I'm very new to this and managed to write a trigger, preventing a duplicates on a custom object 'Time Estimating' and giving a customised error on screen.  Code is below.

The trigger works perfectly in Sandbox but I can't move the trigger into production as it doesn't include tests.  So I have written a separate apex class to test.  The code is also below.  When I debug I get the following error 'required (...)+ loop did not match anything at input '<EOF>'.  I have googled this to death with no helpful result. When I run tests I get 0% code coverage for the trigger.

Can anyone advise what I have done wrong?  

I'm using the Developer Console (can't install anything else).

Apex Trigger to check for duplicates (called PreventDuplicate)
trigger PreventDuplicate on Time_Estimating__c (before insert, before update){
 
    List<String> uniqueValueList = new List<String>();
    for(Time_Estimating__c a : Trigger.new){
        uniqueValueList.add(a.Unique_Year_Estimate__c);
    }

    List<Time_Estimating__c> acctList = [select id, name, Unique_Year_Estimate__c from Time_Estimating__c where Unique_Year_Estimate__c IN :uniqueValueList];
    Map<String,Time_Estimating__c> uniqueValueMap = new Map<String,Time_Estimating__c>();
    for(Time_Estimating__c a : acctList){
        uniqueValueMap.put(a.Unique_Year_Estimate__c,a);       
    }
 
    for(Time_Estimating__c a : Trigger.new){
        if(uniqueValueMap.containsKey(a.Unique_Year_Estimate__c)){
           
            if(trigger.isInsert || (trigger.isUpdate && a.id<>uniqueValueMap.get(a.Unique_Year_Estimate__c).id)){
                a.addError('A Time Estimate for the year you have specified already exists.  Please click the cancel button and update the existing time estimate.');
            }          
        }
    }
}

Apex class to test trigger (called PreventDuplicateTest)
@isTest

//test for PreventDuplicate trigger on Time Estimating
Public Class PreventDuplicateTest
{
   Static testMethod Void PreventDuplicate()
   {
      Boolean result = false;
      Time_Estimating__c firstAcc = new 
          Time_Estimating__c(Unique_Year_Estimate__c = 'test - 2015',Matter_Name__c = 'test');
      insert firstAcc;
      try{
           Time_Estimating__c secondAcc = new 
               Time_Estimating__c(Unique_Year_Estimate__c = 'test - 2015',Matter_Name__c = 'test');
           insert secondAcc;
       }catch(DmlException ex){ result = true;}
      System.assert(result);
   }
}

Many thanks for your help!