• CK_Young123
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
global class tt {
    WebService static Boolean updateDB(Account[]  fList) {
    Boolean updateFlg = true;
    try{
          Database.SaveResult[] SR  = Database.update(fList,false);
          for(Database.SaveResult lsr:SR){
                if(!lsr.isSuccess()){
                   updateFlg = false;
                     break;   
                 }
           }        
    }catch (Exception e) {
           updateFlg = false;
    }
    return updateFlg;
}
 
     static testMethod void updateDB() {
 
          Account[] fList = [Select o.Name from Account o where o.Name = 'AAA2'];
         for (Account oli1 : fList ){
             oli1.name = 'd';
          }

           System.assertEquals(false, updateDB(fList ));
    }
}
 
 
 
how can i get the Exception not DMLException,how can i test it ?
 
anyway,Excepiton   can't  be appeared in my source?
 
now my coverage can't  be 100%?can someone can give a testmethode?
Thankyou
 
 
 
 
 
select Account.name from Account LEFT JOIN AccountPartner on Account.Id = AccountPartner.Id
 
left Join is unexpected token?

global class tt {
    WebService static Boolean sayHelloWorld(String name) {
 
        Boolean updateFlg = true;

        Account [] accountList = [Select a.Name from Account a where o.Name = name];

        for(Account oli : accountList ){
            oli.Name = '23';
        }

         Database.SaveResult[] SR = database.update(accountList);
             try{
                         for(Database.SaveResult lsr:SR){
                                if(!lsr.isSuccess()){
                                      updateFlg = false;
                                      break;
                                }
                          }
              }catch (System.Exception e) {

              }


          static testMethod void testHelloWorld() {
                System.assertEquals(false, sayHelloWorld('name1'));
         }
    }
}

i can't get the lsr.isSuccess())==false, how can i get it when update or insert the Datebase.