• Kameswara Rao Addepalli
  • NEWBIE
  • 0 Points
  • Member since 2018
  • Mr
  • TCS

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Here is my Test class

@isTest
public class accountExplorer_Test {

    private static testMethod void test() {
       
        accountExplorer hadlerObj = new accountExplorer();
        hadlerObj.accountCollect();
        Transaction__c tansObj = new Transaction__c();
        tansObj=accountExplorer.transDeatils();
        accountExplorer.transNameHandler();
    }    
}

Here is Apex Class:
public class accountExplorer {
   public accountExplorer(){
        system.debug('Inside Constructor');
    }
    //Non Static method : Variable declaration
    List<Account> accountCollectVar = new List<Account>();
    
    //Non-Static method declaration and its body : Account details displayer
    public Account accountCollect(){
        accountCollectVar = [SELECT ID, Name, AccountNumber FROM Account WHERE name='addepalli' OR name='katru'];
        system.debug('Account Details in non-statis method:' +accountCollectVar);
        return accountCollectVar[1];
     }
    //Static Method : Variables declaration Note: Static method not allowing variables to be declared inside methoid body??  ?
    Static Set<Transaction__c> transDetailsVar = new Set<Transaction__c>();
    Static List<Transaction__c> transDetailsVarList = new List<Transaction__c>();
    
    //Metho declaration with method body : Displays all transaction names and its type
    public static Transaction__c transDeatils(){
        transDetailsVarList = [SELECT Name, TransactionType__c FROM Transaction__c WHERE TransactionType__c = 'deposit'];
        transDetailsVar.addAll(transDetailsVarList);
        system.debug('Transaction details:'+transDetailsVar);
        return transDetailsVarList[1];
       
    } 
   
   // Static method, with string return type : Display transaction Name
   //Static string transName{get;set;}
    public static string transNameHandler(){
            Transaction__c transObject = new Transaction__c();
            transObject = [SELECT Name from Transaction__c WHERE TransactionType__c = 'deposit' LIMIT 1];
            system.debug('Transaction name :' +transObject.name);
            return transObject.name;
        }
}
 
Here is my Test class

@isTest
public class accountExplorer_Test {

    private static testMethod void test() {
       
        accountExplorer hadlerObj = new accountExplorer();
        hadlerObj.accountCollect();
        Transaction__c tansObj = new Transaction__c();
        tansObj=accountExplorer.transDeatils();
        accountExplorer.transNameHandler();
    }    
}

Here is Apex Class:
public class accountExplorer {
   public accountExplorer(){
        system.debug('Inside Constructor');
    }
    //Non Static method : Variable declaration
    List<Account> accountCollectVar = new List<Account>();
    
    //Non-Static method declaration and its body : Account details displayer
    public Account accountCollect(){
        accountCollectVar = [SELECT ID, Name, AccountNumber FROM Account WHERE name='addepalli' OR name='katru'];
        system.debug('Account Details in non-statis method:' +accountCollectVar);
        return accountCollectVar[1];
     }
    //Static Method : Variables declaration Note: Static method not allowing variables to be declared inside methoid body??  ?
    Static Set<Transaction__c> transDetailsVar = new Set<Transaction__c>();
    Static List<Transaction__c> transDetailsVarList = new List<Transaction__c>();
    
    //Metho declaration with method body : Displays all transaction names and its type
    public static Transaction__c transDeatils(){
        transDetailsVarList = [SELECT Name, TransactionType__c FROM Transaction__c WHERE TransactionType__c = 'deposit'];
        transDetailsVar.addAll(transDetailsVarList);
        system.debug('Transaction details:'+transDetailsVar);
        return transDetailsVarList[1];
       
    } 
   
   // Static method, with string return type : Display transaction Name
   //Static string transName{get;set;}
    public static string transNameHandler(){
            Transaction__c transObject = new Transaction__c();
            transObject = [SELECT Name from Transaction__c WHERE TransactionType__c = 'deposit' LIMIT 1];
            system.debug('Transaction name :' +transObject.name);
            return transObject.name;
        }
}