• keerthana chowdhary
  • NEWBIE
  • 50 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 17
    Replies

    public static void insertException(Map<string, string> param)
    {   
@isTest
public class TestEnrolmentFormWarningPageController
 {
static testmethod void validateStandardController1(){
 Profile p = [SELECT Id FROM Profile WHERE Name='RMS Developer']; 
      User u2 = new User(Alias = 'newUser', Email='subramani.ramamurthy@cgi.com', 
         EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
         LocaleSidKey='en_US', ProfileId = p.Id, 
         TimeZoneSidKey='America/Los_Angeles', UserName='subramani.ramamurthy@cgi.com');

      System.runAs(u2) {
String str = [Select Id From RecordType Where SobjectType = 'EnrolmentForm__c' and Name ='ESS New Enrolment' LIMIT 1].Id;
EnrolmentForm__c enroll=new EnrolmentForm__c(Mobile__c='989898999',Email__c='sundhar@gmail.com',EnrolmentStatusCode__c='Unprocessed',Council_Area__c='maharastra',FormValidationFlag__c = true,RecordTypeId=str );
insert enroll;
     ApexPages.currentpage().getparameters().put('id', enroll.id);
        
   ApexPages.StandardController sc1 = new ApexPages.StandardController(enroll);
  EnrolmentFormWarningPageControllerExt cont = new EnrolmentFormWarningPageControllerExt(sc1);
EnrolmentForm__c enroll1=new EnrolmentForm__c(Mobile__c='989898999',Email__c='sundhar@gmail.com',EnrolmentStatusCode__c='Unprocessed',Council_Area__c='maharastra',FormValidationFlag__c = false,RecordTypeId=str );
insert enroll1;
     
     ApexPages.currentpage().getparameters().put('id', enroll1.id);
     ApexPages.StandardController sc2 = new ApexPages.StandardController(enroll1);
  EnrolmentFormWarningPageControllerExt cont1 = new EnrolmentFormWarningPageControllerExt(sc2);
  
  }
}
}
error

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301O00000009tJz. Contact your administrator for help.: []
public  class AUditingBatch implements Database.Batchable<sObject>,Database.Stateful
{
public Database.querylocator start(Database.BatchableContext BC){

string query1='SELECT Id,Action,DelegateUser,CreatedBy.Name,CreatedDate,Display,Section FROM SetupAuditTrail';
return Database.getQueryLocator(query1);
    }
public void execute(Database.BatchableContext BC, List<SetupAuditTrail> scope )
    {
  List<AUditTrial__c> auditList= new List<AUditTrial__c>();//INTIALZE CUSTOM OBJECT
        for(SetupAuditTrail t : scope){ 
        AUditTrial__c AU= new AUditTrial__c(
                   Action__c = t.Action,
                   Name= t.CreatedBy.Name,
                   CreatedBy__c= t.CreatedBy.Name,
                   CreatedDate__c = t.CreatedDate,
                   DelegateUser__c= t.DelegateUser,
                   Display__c= t.Display,
                   Section__c= t.Section);
               auditList.add(AU);
        }
    insert auditList;
    }
public void finish(Database.BatchableContext BC)
{
    system.debug('capture the setup audit trial Data finished');
  }
}

test class


@isTest 
public class TestAudingbatch {
static Testmethod void  testAU(){ 
string query = 'Select Action__c,Display__c,Section__c, CreatedBy__c, CreatedDate__c, DelegateUser__c From AUditTrial__c';
 AUditTrial__c[] m1=new List<AUditTrial__c>();

for (integer i=0; i<10;i++)
{
AUditTrial__c a1=new AUditTrial__c(
Action__c ='apexclass',
Display__c='modified',
Section__c='pagelayout');
 m1.add(a1);
}
insert m1;
    Database.QueryLocator QL;
    Database.BatchableContext BC;
    List <SetupAuditTrail> setup=new List<SetupAuditTrail>();
    List<AUditTrial__c> Auditt = new List<AUditTrial__c>();
    test.startTest();
    AUditingBatch AU = new AUditingBatch();
    QL = AU.start(bc);
    AU.finish(BC);
   AU.execute(BC,setup);


    test.stopTest();
}
public class AUditingBatch implements Database.Batchable<sObject>,Database.Stateful{
public String query;
    public AUditingBatch(){
 query = 'Select Action__c,Display__c,Section__c, CreatedBy__c, CreatedDate__c, DelegateUser__c From AUditTrial__c WHERE CreatedDate__c > YESTERDAY';
    }
public Database.querylocator start(Database.BatchableContext BC){
    
        return Database.getQueryLocator(query);
    }

public void execute(Database.BatchableContext BC, List<AUditTrial__c> scope )
    {
    List<AUditTrial__c> InsrtRecord = new List<AUditTrial__c>(); 
        SetupAuditTrail AU= new SetupAuditTrail();
     for(Sobject s : scope){
     AUditTrial__c obj = (AUditTrial__c) s;
     InsrtRecord.add(new AUditTrial__c(
                   
                   Action=obj .Action__c,
                   //CreatedBy = obj .CreatedBy__c,
                   CreatedDate = obj.CreatedDate__c,
                   //DelegateUser= obj.DelegateUser__c,
                   Display= obj .Display__c,
                   Section= obj .Section__c
               ));
     }
    insert InsrtRecord;
    }
public void finish(Database.BatchableContext BC)
{
    system.debug('JOB IS FINISHED');
  }
}
Is it possible to store audit trail information on reports ?if it is possible how can i enable the option allow reports/snapshnot on audit trail

public with sharing class sccQuestionList {
    
    Public Integer noOfRecords{get; set;}

    Public Integer size{get;set;}

    Public List<wrapperclass> wrapList{get;set;}

    Public boolean showFlagcheck{get;set;}

    public ApexPages.StandardSetController setCon {
        
 
        get{

            if(setCon == null){

                size = 10;
                
                Id UserId = UserInfo.getUserId();

                string queryString = 'Select Id,Name, 

Line_Of_Discipline_C__r.Name,Status_C__c,Priority_C__c,Owner.name,Line_Of_Discipline_Focal_Point__r.Name,Site__c,Title_C__c,CreatedDate,CreatedById  from Question__c 

where CreatedById =: UserId order by CreatedDate DESC';

                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));

                setCon.setPageSize(size);

                noOfRecords = setCon.getResultSize();

               wrapList = new List<wrapperclass>();

         
 
            }

            return setCon;

        }set;

    }

     
 
    /*Public Pagination_Demo(){

      wrapList = new List<wrapperclass>();

    } */

      
 
    Public List<Question__c> getQuestions(){

        List<Question__c> queList = new List<Question__c>();

        for(Question__c q : (List<Question__c>)setCon.getRecords())

            queList.add(q);

        return queList;

    }

     
 
    Public List<wrapperclass> getwrapListshow(){

        List<Question__c> queList = new List<Question__c>();

        wrapList = new List<wrapperclass>();

        for(Question__c q : (List<Question__c>)setCon.getRecords())
        {

            wrapList.add(new wrapperclass(q,false)) ;

            queList.add(q);

        }

        showFlagcheck = true;

        return wrapList ;

    }

     
 
    Public class wrapperclass{

         Public Question__c ques{get;set;}

         Public Boolean flagcheck{get;set;}

         Public wrapperclass(Question__c que,boolean checkBox){

           ques = que;

           flagcheck = checkbox;

 
 
         }   
 
    }

       
 
    public pageReference refresh() {

        setCon = null;

        getQuestions();

        setCon.setPageNumber(1);

        return null;

    }

    //This is called by action poller in visualforce page

    Integer count = 0;

    public PageReference incrementCounter() {

        count = setCon.getPageNumber();

        return null;

    }


}
can u please help me

my test class
@isTest
public class testsccQuestionlist {
static testmethod void ssc()
{
    Question__c  Q=new Question__c ();
    insert Q;
    
    PageReference pageRef = Page.conatactsaved;
    pageRef.getParameters().put('id', String.valueOf(Q.Id));
    Test.setCurrentPage(pageRef);
   sccQuestionList.wrapperclass sccQuestion = new sccQuestionList.wrapperclass(Q);
   //sccQuestion.getQuestions();
  }
}
public class fileAttach{
Public Attachment myfile{get;set;}
Public String VMfileName{get;set;}
public String ContactIds{get;set;}
public Contact con{get;set;}
public List<Contact> contacts{get;set;}
Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }
    
    public fileAttach(ApexPages.StandardController controller) {
       ContactIds= ApexPages.currentPage().getParameters().get('array');
      }
 Public Pagereference Savedoc()
    {
      if(ContactIds!= null || ContactIds!= ''){
         List<String> strConIds= ContactIds.split(',');
            for(Id conId:strConIds){
                Attachment a = new Attachment(parentId =conId,name=myfile.name, body = myfile.body);
                insert a;
                 }
}
 return null;
 }   
}
test class...

@isTest(seealldata=true)
public class testfileattach
{
    static testmethod void testfileattach()
    {
        Contact con=new Contact(LastName='Test Name',payroll__c='rakhul');
        insert con;
        Pagereference ref=page.conatactsaved;
        ref.getParameters().put('id', String.valueOf(con.id));//for page referenc
        Test.setcurrentpage(ref);
        ApexPages.StandardController cont = new ApexPages.StandardController(con);
        fileAttach fill=new fileAttach(cont);
        fill.VMfileName='';
        Attachment att=new Attachment();
        att=fill.getmyfile();
        fill.Savedoc();
    }
  }
test class passed with 50 %code coverage
but whenever i was calling pagerefence  savedoc method getting error that System.NullPointerException: Attempt to de-reference a null object
stack trace
Class.fileAttach.Savedoc: line 24, column 1
Class.testfileattach.testfileattach: line 16, column 1
this is my controller class
public with sharing class propertycontroller {
public account ppo {get; set;}


    public propertycontroller(ApexPages.StandardController controller)
    {
       ppo = (account)controller.getRecord();
    }

        public pageReference SaveA()
    {
        try{
         upsert ppo;
        PageReference pageRef = new PageReference('https://itroos-dev-ed--seit.na34.visual.force.com/apex/Property');
        pageRef.setRedirect(true);
        return pageRef;  

        }
        catch(Exception ex)
        {
           ApexPages.addMessages(ex);
         system.debug(ex);
         PageReference pageRef = new PageReference('https://itroos-dev-ed.my.salesforce.com/a01/o');
        pageRef.setRedirect(true);
        return pageRef; 
        }
    }
}

test class:::

@isTest
public class testpropertycontrol {
static testmethod void pro()
{
 Account acc=new Account(name='fd');
    try
        {
                   Database.INSERT(acc);
                    if(Test.isRunningTest())
                         
                         integer intTest =1/0;  
        } catch(exception ex)// exception handling
            {
               System.debug(ex.getMessage());
            }
    
        PageReference pageRef = Page.attachmen; // Adding VF page Name here
        pageRef.getParameters().put('id', String.valueOf(acc.id));//for page reference
        Test.setCurrentPage(pageRef);
        
        ApexPages.currentPage().getParameters().put('id',acc.id);//for pagereference
        
    ApexPages.StandardController sc = new ApexPages.standardController(acc);
    propertycontroller pro=new propertycontroller(sc);
    pro.SaveA();

}
  static testmethod void pro1()  
  {
      
        Account acc=new Account(name='fd');
    try
        {
                  Database.INSERT(acc);
                    if(Test.isRunningTest())
                          
                         integer intTest =1/0;  
        } catch(exception ex)// exception handling
            {
               System.debug(ex.getMessage());
            }
       PageReference pageRef = Page.attachmen; // Adding VF page Name here
        pageRef.getParameters().put('id', String.valueOf(acc.id));//for page reference
        Test.setCurrentPage(pageRef);
        
        ApexPages.currentPage().getParameters().put('id',acc.id);//for pagereference
        
          
    ApexPages.StandardController sc = new ApexPages.standardController(acc);
    propertycontroller pro=new propertycontroller(sc);
    pro.SaveA();
      
      
      
      
      
  }
    
}
getting code coverage 65 %i want to increase,the bold lines that have specified in controller class was not covering
 ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'account = null'));


my test code
 List<Apexpages.Message> pageMessages = ApexPages.getMessages();
    System.assertNotEquals(0, pageMessages.size());

// Check that the error message you are expecting is in pageMessages
Boolean messageFound = false;

for(ApexPages.Message message : pageMessages) {
    if(message.getSummary() == 'Your summary'
        && message.getDetail() == 'Your detail'
        && message.getSeverity() == ApexPages.severity.ERROR) {
        messageFound = true;        
    }
}

but iwas unable to cover these line any help
trigegr........
trigger updatedescription on Account (before insert) 
{
for(account a:trigger.new)
{
if(a.industry=='Technology')

a.description='Technology account'; 
    }
   }
------------------------------------
test class
@isTest
public class testupdateaccount {
static testmethod void testupdate()
{
     Account acct = new Account(Name='Test Account',description='hello salesforce');
        insert acct;
        Opportunity opp = new Opportunity(Name=acct.Name + ' Opportunity',
                                       StageName='Prospecting',
                                       CloseDate=System.today().addMonths(1),
                                       AccountId=acct.Id);
        insert opp;
       list<account> ad=new list<account>{[select id,name,description from account LIMIT 50 ]};

        }
}
------------
test class passed but code coverage getting 75 % i need 100% code coverage 
 
a.description='Technology account'; /this line was not covering any help
public class uploadattachedfiles 
{
    Public Attachment myfile;

Public Attachment getmyfile()
{
     myfile = new Attachment();
     return myfile;
}
   
Public Pagereference Savedoc()
{
    String accid = System.currentPagereference().getParameters().get('id');
    Attachment a = new Attachment();
    a.parentId='00128000005yJi7';
    a.name=myfile.name;
    a.body = myfile.body;
    insert a;
    return NULL;
}   
}

-----------------------------------------------------

@isTest
public class testuploadattachment {
    
static testmethod void testattached()
{
   // account ac=new account();
    //ac.name='sanfransico';
    //ac.phone='899899898';
     //insert ac;
    //opportunity op=new opportunity();
    //op.description='hello world';
    //op.Name='sundhar';
    //op.StageName='discriminating';
    //op.CloseDate=system.today();
     //insert op;
    //Attachment acd = new Attachment();
    //acd.name='atach';
   //Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
    //acd.body=bodyblob;
    //acd.parentId=ac.id;
    //insert acd;
    
   Test.startTest();
    // string businessName = ApexPages.currentPage().getParameters().put('businessValue', lstLineItems[0].name);
   //PageReference ref = page.uploadattachemntss; 
   //Test.setCurrentPage(ref);
    uploadattachedfiles upd = new uploadattachedfiles ();
   upd.getmyfile();
    upd.Savedoc();
   list<Attachment> ad=new list<Attachment>();
   ad=[select id,name,body from Attachment];    
   // upd.myfile=ad;
    test.stopTest();
   }
}

----------------------
error
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, Body]: [Name, Body]
hi i have a requirement that how to add document to notes and attachment while at that the time of creating a record and iam uploading the file using inputfile componet
hi i have a requirement that how to add document to notes and attachment while at that the time of creating a record and iam uploading the file using inputfile componet 
trigger percantageupdate on appraisal__c (after insert,after update)
{
 set<id> sd = new set<id>();
for (appraisal__c  a :trigger.new)    
{
    sd.add(a.appointments__c);
    
}
    list<appointments__c> app= new list<appointments__c>();
    app=[select id,of_increment__c,amount_increment__c,(select id,ctc__c from appraisal__c __r) from appointments__c where id IN: sd];
    for(appointments__c c: app )
    {
        c.of_increment__c=c.ctc__c;
        c.amount_increment__c=c.ctc__c;
    }
    update app;
}

help me urgent
how to assign cred permissions to users while at the time of creating a record
ex:i have 4 users .when i was trying to create a record on object...automatically assign the  cred permission for the 4 users
public  class AUditingBatch implements Database.Batchable<sObject>,Database.Stateful
{
public Database.querylocator start(Database.BatchableContext BC){

string query1='SELECT Id,Action,DelegateUser,CreatedBy.Name,CreatedDate,Display,Section FROM SetupAuditTrail';
return Database.getQueryLocator(query1);
    }
public void execute(Database.BatchableContext BC, List<SetupAuditTrail> scope )
    {
  List<AUditTrial__c> auditList= new List<AUditTrial__c>();//INTIALZE CUSTOM OBJECT
        for(SetupAuditTrail t : scope){ 
        AUditTrial__c AU= new AUditTrial__c(
                   Action__c = t.Action,
                   Name= t.CreatedBy.Name,
                   CreatedBy__c= t.CreatedBy.Name,
                   CreatedDate__c = t.CreatedDate,
                   DelegateUser__c= t.DelegateUser,
                   Display__c= t.Display,
                   Section__c= t.Section);
               auditList.add(AU);
        }
    insert auditList;
    }
public void finish(Database.BatchableContext BC)
{
    system.debug('capture the setup audit trial Data finished');
  }
}

test class


@isTest 
public class TestAudingbatch {
static Testmethod void  testAU(){ 
string query = 'Select Action__c,Display__c,Section__c, CreatedBy__c, CreatedDate__c, DelegateUser__c From AUditTrial__c';
 AUditTrial__c[] m1=new List<AUditTrial__c>();

for (integer i=0; i<10;i++)
{
AUditTrial__c a1=new AUditTrial__c(
Action__c ='apexclass',
Display__c='modified',
Section__c='pagelayout');
 m1.add(a1);
}
insert m1;
    Database.QueryLocator QL;
    Database.BatchableContext BC;
    List <SetupAuditTrail> setup=new List<SetupAuditTrail>();
    List<AUditTrial__c> Auditt = new List<AUditTrial__c>();
    test.startTest();
    AUditingBatch AU = new AUditingBatch();
    QL = AU.start(bc);
    AU.finish(BC);
   AU.execute(BC,setup);


    test.stopTest();
}
public class fileAttach{
Public Attachment myfile{get;set;}
Public String VMfileName{get;set;}
public String ContactIds{get;set;}
public Contact con{get;set;}
public List<Contact> contacts{get;set;}
Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }
    
    public fileAttach(ApexPages.StandardController controller) {
       ContactIds= ApexPages.currentPage().getParameters().get('array');
      }
 Public Pagereference Savedoc()
    {
      if(ContactIds!= null || ContactIds!= ''){
         List<String> strConIds= ContactIds.split(',');
            for(Id conId:strConIds){
                Attachment a = new Attachment(parentId =conId,name=myfile.name, body = myfile.body);
                insert a;
                 }
}
 return null;
 }   
}
test class...

@isTest(seealldata=true)
public class testfileattach
{
    static testmethod void testfileattach()
    {
        Contact con=new Contact(LastName='Test Name',payroll__c='rakhul');
        insert con;
        Pagereference ref=page.conatactsaved;
        ref.getParameters().put('id', String.valueOf(con.id));//for page referenc
        Test.setcurrentpage(ref);
        ApexPages.StandardController cont = new ApexPages.StandardController(con);
        fileAttach fill=new fileAttach(cont);
        fill.VMfileName='';
        Attachment att=new Attachment();
        att=fill.getmyfile();
        fill.Savedoc();
    }
  }
test class passed with 50 %code coverage
but whenever i was calling pagerefence  savedoc method getting error that System.NullPointerException: Attempt to de-reference a null object
stack trace
Class.fileAttach.Savedoc: line 24, column 1
Class.testfileattach.testfileattach: line 16, column 1
this is my controller class
public with sharing class propertycontroller {
public account ppo {get; set;}


    public propertycontroller(ApexPages.StandardController controller)
    {
       ppo = (account)controller.getRecord();
    }

        public pageReference SaveA()
    {
        try{
         upsert ppo;
        PageReference pageRef = new PageReference('https://itroos-dev-ed--seit.na34.visual.force.com/apex/Property');
        pageRef.setRedirect(true);
        return pageRef;  

        }
        catch(Exception ex)
        {
           ApexPages.addMessages(ex);
         system.debug(ex);
         PageReference pageRef = new PageReference('https://itroos-dev-ed.my.salesforce.com/a01/o');
        pageRef.setRedirect(true);
        return pageRef; 
        }
    }
}

test class:::

@isTest
public class testpropertycontrol {
static testmethod void pro()
{
 Account acc=new Account(name='fd');
    try
        {
                   Database.INSERT(acc);
                    if(Test.isRunningTest())
                         
                         integer intTest =1/0;  
        } catch(exception ex)// exception handling
            {
               System.debug(ex.getMessage());
            }
    
        PageReference pageRef = Page.attachmen; // Adding VF page Name here
        pageRef.getParameters().put('id', String.valueOf(acc.id));//for page reference
        Test.setCurrentPage(pageRef);
        
        ApexPages.currentPage().getParameters().put('id',acc.id);//for pagereference
        
    ApexPages.StandardController sc = new ApexPages.standardController(acc);
    propertycontroller pro=new propertycontroller(sc);
    pro.SaveA();

}
  static testmethod void pro1()  
  {
      
        Account acc=new Account(name='fd');
    try
        {
                  Database.INSERT(acc);
                    if(Test.isRunningTest())
                          
                         integer intTest =1/0;  
        } catch(exception ex)// exception handling
            {
               System.debug(ex.getMessage());
            }
       PageReference pageRef = Page.attachmen; // Adding VF page Name here
        pageRef.getParameters().put('id', String.valueOf(acc.id));//for page reference
        Test.setCurrentPage(pageRef);
        
        ApexPages.currentPage().getParameters().put('id',acc.id);//for pagereference
        
          
    ApexPages.StandardController sc = new ApexPages.standardController(acc);
    propertycontroller pro=new propertycontroller(sc);
    pro.SaveA();
      
      
      
      
      
  }
    
}
getting code coverage 65 %i want to increase,the bold lines that have specified in controller class was not covering
trigegr........
trigger updatedescription on Account (before insert) 
{
for(account a:trigger.new)
{
if(a.industry=='Technology')

a.description='Technology account'; 
    }
   }
------------------------------------
test class
@isTest
public class testupdateaccount {
static testmethod void testupdate()
{
     Account acct = new Account(Name='Test Account',description='hello salesforce');
        insert acct;
        Opportunity opp = new Opportunity(Name=acct.Name + ' Opportunity',
                                       StageName='Prospecting',
                                       CloseDate=System.today().addMonths(1),
                                       AccountId=acct.Id);
        insert opp;
       list<account> ad=new list<account>{[select id,name,description from account LIMIT 50 ]};

        }
}
------------
test class passed but code coverage getting 75 % i need 100% code coverage 
 
a.description='Technology account'; /this line was not covering any help
public class uploadattachedfiles 
{
    Public Attachment myfile;

Public Attachment getmyfile()
{
     myfile = new Attachment();
     return myfile;
}
   
Public Pagereference Savedoc()
{
    String accid = System.currentPagereference().getParameters().get('id');
    Attachment a = new Attachment();
    a.parentId='00128000005yJi7';
    a.name=myfile.name;
    a.body = myfile.body;
    insert a;
    return NULL;
}   
}

-----------------------------------------------------

@isTest
public class testuploadattachment {
    
static testmethod void testattached()
{
   // account ac=new account();
    //ac.name='sanfransico';
    //ac.phone='899899898';
     //insert ac;
    //opportunity op=new opportunity();
    //op.description='hello world';
    //op.Name='sundhar';
    //op.StageName='discriminating';
    //op.CloseDate=system.today();
     //insert op;
    //Attachment acd = new Attachment();
    //acd.name='atach';
   //Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
    //acd.body=bodyblob;
    //acd.parentId=ac.id;
    //insert acd;
    
   Test.startTest();
    // string businessName = ApexPages.currentPage().getParameters().put('businessValue', lstLineItems[0].name);
   //PageReference ref = page.uploadattachemntss; 
   //Test.setCurrentPage(ref);
    uploadattachedfiles upd = new uploadattachedfiles ();
   upd.getmyfile();
    upd.Savedoc();
   list<Attachment> ad=new list<Attachment>();
   ad=[select id,name,body from Attachment];    
   // upd.myfile=ad;
    test.stopTest();
   }
}

----------------------
error
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name, Body]: [Name, Body]
hi i have a requirement that how to add document to notes and attachment while at that the time of creating a record and iam uploading the file using inputfile componet
HI,
I need to write test class for empty class

public class Active{
    public Active(){
    }
}
Need to code coverage 100%
how to assign cred permissions to users while at the time of creating a record
ex:i have 4 users .when i was trying to create a record on object...automatically assign the  cred permission for the 4 users
i have one scenario please help me
Take two picklists in one object (one is controlled for states and other one is dependent for districts )

In visual force page I want to show these two as multi select Pick lists .I need a provision of selecting multiple states at the same time so It'll show all the districts belongs to the selected states in multiselect picklist.

Note:- I don't want any hardcoded values in apex class

can any one help me how to do it