Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AccountRelatedContacts {
- public id tobeEdited{get; set;}
- public String selectedcouId{get;set;}
- public String selectedAccId{get;set;}
- public string conid{get;set;}
- public boolean showPopup{ get; set; }
- public boolean isDownload {get;set;}
- public list<contact> lstcontact{get;set;}
- public List<SelectOption> getCountryNames() {
- List<SelectOption> couOptions= new List<SelectOption>();
- couOptions.add( new SelectOption('','--Select--'));
- list<Country__c> cut = [select Id,name from Country__c];
- for( Country__c cou : cut ) {
- couOptions.add( new SelectOption(cou.Id,cou.name));
- }
- return couOptions;
- }
- public List<SelectOption> getAccountNames() {
- system.debug('country ID'+selectedcouid);
- List<SelectOption> accOptions= new List<SelectOption>();
- List<SelectOption> options = new List<SelectOption>();
- if(selectedcouId != null){
- list<account> act = [select Id,name,Country__c from account where Country__c=:selectedcouId order by name ASC ];
- for( Account acc : act ) {
- accOptions.add( new SelectOption(acc.Id,acc.name));
- }
- }
- else
- {
- accOptions.add( new SelectOption('--None--','--None--'));
- }
- return accOptions;
- }
- public pagereference Submit(){
- lstcontact= new List<contact>();
- lstcontact= [SELECT ID,name, Firstname,lastname,email,phone,account.name from contact WHERE accountId=:selectedaccid order by name ASC];
- return null;
- }
- }
- public class testCountryAccountRelatedContacts {
- private static testmethod void testgetCountryNames() {
- country__C c = new country__c();
- insert c;
- CountryAccountRelatedContacts controller = new CountryAccountRelatedContacts();
- controller.selectedcouId = c . id;
- List<SelectOption> sp = controller.getCountryNames();
- system.assertEquals(sp.size(),2);
- }
- private static testMethod void testgetaccountNames()
- {
- country__C c = new country__c();
- insert c;
- account acc = new account(Country__c=c.id,name = 'test');
- insert acc;
- CountryAccountRelatedContacts controllers = new CountryAccountRelatedContacts();
- List<SelectOption> sp1 = controllers.getaccountNames();
- controllers.selectedcouId = c.id;
- controllers.selectedAccId = acc.id;
- string getselectedcouId = controllers.selectedcouId;
- string getsselectedAccId = controllers.selectedAccId;
- List<SelectOption> sp2 = controllers.getaccountNames();
- system.assertEquals(sp2.size(),2);
- }
- }
- USER_DEBUG [33]|DEBUG|country IDnull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement