• Jose Boveda 6
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
I'm wondering what functionality is impacted by an expired self-signed certificate in Salesforce. We have SSO enabled for the organization, and the authentication is handled via SAML metadata. Should this certificate expire, would I still be able to log into my ORG via SSO?
Hi folks,
Found something interesting while researching regarding another posted bug:
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BYt2

I've got a trigger and a test class for it. The trigger basically takes a related list of values and concatenates it, saving it as part of the Account object. My test cases all fail, showing the following error:
Class.TMCR_testAccountInterestList.test_addInterest: line 51, column 1
14:18:05.697 (6697124228)|FATAL_ERROR|System.AssertException: Assertion Failed: Expected: foo
Interest0
Interest1
Interest2
, Actual: foo
Interest0
Interest1
Interest2

The data looks identical. Just to be sure, I put the strings through a hex conversion to compare their hex values and they are indeed different.

My question is what gives? Why are they different? The data going in should be the same.

For reference, here are is the Trigger:
trigger Account_UpdateAccountInterestsList on Interest__c (after delete, after insert, after undelete, 
after update) {
	Interest__c[] interests;
    if (Trigger.isDelete) 
        interests = Trigger.old;
    else
        interests = Trigger.new;
	Set<ID> affected_accounts = new Set<ID>();
	Map<ID, Set<String>> account_interests = new Map<ID, Set<String>>();
	for(Interest__c interest: interests){
		affected_accounts.add(interest.Account__c);
		account_interests.put(interest.Account__c, new Set<String>());
	}

	List<Interest__c> all_interests = [
		SELECT Id, Account__c, Interest__r.Name
		FROM Interest__c
		WHERE Account__c IN :affected_accounts
		ORDER BY Interest__r.Name
	];
	List<Account> accounts_to_update = [
		SELECT Id, Account_Interests_List__c
		FROM Account
		WHERE Id IN :affected_accounts
	];
	
	for(Interest__c interest: all_interests){
		account_interests.get(interest.Account__c).add(interest.Interest__r.Name);
	}
	for(Account account: accounts_to_update){
		account.Account_Interests_List__c = Util_TMCR.combineList(account_interests.get(account.Id));
	}
	
	update accounts_to_update;
}
Here is the test class:
@isTest
private class TMCR_testAccountInterestList {
	static Account getAccount(){
		Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
		Account acc = [
			SELECT Id, Account_Interests_List__c
			FROM Account WHERE Name = :account.get('name')
		];
		return acc;
	}
	static Interests__c addInterest(String name){
		Interests__c new_interest = new Interests__c(Name = name);
		insert new_interest;
		return new_interest;
	}
	static Interest__c addToAccount(Account acc, Interests__c interest){
		Interest__c acc_interest = new Interest__c(Interest__c = interest.Id, Account__c = acc.Id);
		insert acc_interest;
		return acc_interest;
	}
	
	@testSetup
	static void setup(){
		List<Interests__c> interests = new List<Interests__c>();
		List<Interest__c> account_interests = new List<Interest__c>();
		for(Integer i=0; i<3;i++){
			interests.add(addInterest('Interest' + i));
		}
		Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
		Account acc = account.generate();
		for(Interests__c interest: interests){
			account_interests.add(addToAccount(acc, interest));
		}
	}
	
    static testMethod void test_addInterest() {
		test.startTest();
		Account account = getAccount();
		Interests__c interest = addInterest('foo');
		Interest__c acc_interest = addToAccount(account, interest);
		test.stopTest();
		
		String concat = Util_TMCR.combineList(new List<String>{'foo', 'Interest0', 'Interest1', 'Interest2'});
		Account acc = getAccount();
		System.assertEquals(concat, acc.Account_Interests_List__c);
    }
    static testMethod void test_changeInterest() {
    	test.startTest();
		Interests__c interest = addInterest('foo');
		Interest__c acc_interest = [SELECT Id, Interest__c from Interest__c WHERE Interest__r.Name = 'Interest0' LIMIT 1];
		acc_interest.Interest__c = interest.Id;
		update acc_interest;
    	test.stopTest();
    	List<String> mylist = new List<String>{'foo', 'Interest1', 'Interest2'};
    	String concat = Util_TMCR.combineList(mylist);
    	Account acc = getAccount();
    	System.assertEquals(concat, acc.Account_Interests_List__c);
    }
    static testMethod void test_deleteInterest(){
    	test.startTest();
		Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
		delete interest;
    	test.stopTest();
    	List<String> mylist = new List<String>{'Interest1', 'Interest2'};
    	String concat = Util_TMCR.combineList(mylist);
    	Account acc = getAccount();
    	System.assertEquals(concat, acc.Account_Interests_List__c);
    }
    static testMethod void test_undeleteInterest(){
    	test.startTest();
		Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
		delete interest;
		undelete interest;
    	test.stopTest();
    	List<String> mylist = new List<String>{'Interest0', 'Interest1', 'Interest2'};
    	String concat = Util_TMCR.combineList(mylist);
    	Account acc = getAccount();
    	System.assertEquals(concat, acc.Account_Interests_List__c);
    }
}
Finally, here is the function that concatenates both the expected list and the actual list:
public static String combineList(List<String> items){
        String out = '';
        String delimiter = '\n';
        for(String val : items){
        	out = out + val;
        	if(val.right(1) != delimiter){
        		out = out + delimiter;
        	}
        }
        return out;
    }





 
Hi folks,
I developed a trigger for my production environment in the Eclipse IDE. When I go to save it to my environment, it shows an error that code coverage is 0%. I've developed a test class for this trigger, and when I run the test from the IDE, it shows test coverage for my trigger at 100% (0 lines not tested).

What gives? Is there another way to get my trigger to save onto my environment? I tried using the Development Console but that didn't work due to the 'Metadata can't be changed on an active environment' bug.

Any help is appreciated.

Trigger:
trigger Account_UpdateAccountInterestsList on Interest__c (after delete, after insert, after undelete, 
after update) {
	Interest__c[] interests;
    if (Trigger.isDelete) 
        interests = Trigger.old;
    else
        interests = Trigger.new;
	Set<ID> affected_accounts = new Set<ID>();
	Map<ID, List<String>> account_interests = new Map<ID, List<String>>();
	for(Interest__c interest: interests){
		affected_accounts.add(interest.Account__c);
		account_interests.put(interest.Account__c, new List<String>());
	}

	List<Interest__c> all_interests = [
		SELECT Id, Account__c, Interest__r.Name
		FROM Interest__c
		WHERE Account__c IN :affected_accounts
		ORDER BY Interest__r.Name
	];
	List<Account> accounts_to_update = [
		SELECT Id, Account_Interests_List__c
		FROM Account
		WHERE Id IN :affected_accounts
	];
	
	for(Interest__c interest: all_interests){
		account_interests.get(interest.Account__c).add(interest.Interest__r.Name + '\n');
	}
	for(Account account: accounts_to_update){
		account.Account_Interests_List__c = Util_TMCR.combineList(account_interests.get(account.Id));
	}
	
	update accounts_to_update;
}


Test class:
@isTest
private class TMCR_testAccountInterestList {
  /*
    Testing Account_UpdateAccountInterestsList trigger
  */
  static Account getAccount(){
    Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
    Account acc = [
      SELECT Id, Account_Interests_List__c
      FROM Account WHERE Name = :account.get('name')
    ];
    return acc;
  }
  static Interests__c addInterest(String name){
    Interests__c new_interest = new Interests__c(Name = name);
    insert new_interest;
    return new_interest;
  }
  static Interest__c addToAccount(Account acc, Interests__c interest){
    Interest__c acc_interest = new Interest__c(Interest__c = interest.Id, Account__c = acc.Id);
    insert acc_interest;
    return acc_interest;
  }
  
  @testSetup
  static void setup(){
    List<Interests__c> interests = new List<Interests__c>();
    List<Interest__c> account_interests = new List<Interest__c>();
    for(Integer i=0; i<3;i++){
      interests.add(addInterest('Interest' + i));
    }
    Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
    Account acc = account.generate();
    for(Interests__c interest: interests){
      account_interests.add(addToAccount(acc, interest));
    }
  }
  
    static testMethod void test_addInterest() {
    test.startTest();
    Account account = getAccount();
    Interests__c interest = addInterest('foo');
    Interest__c acc_interest = addToAccount(account, interest);
    test.stopTest();
    
    String concat = Util_TMCR.combineList(new List<String>{'foo', 'Interest0', 'Interest1', 'Interest2'});
    Account acc = getAccount();
    System.assertEquals(acc.Account_Interests_List__c, concat);
    }
    static testMethod void test_changeInterest() {
      test.startTest();
    Interests__c interest = addInterest('foo');
    Interest__c acc_interest = [SELECT Id, Interest__c from Interest__c WHERE Interest__r.Name = 'Interest0' LIMIT 1];
    acc_interest.Interest__c = interest.Id;
    update acc_interest;
      test.stopTest();
      List<String> mylist = new List<String>{'foo', 'Interest1', 'Interest2'};
      String concat = Util_TMCR.combineList(mylist);
      Account acc = getAccount();
      System.assertEquals(acc.Account_Interests_List__c, concat);
    }
    static testMethod void test_deleteInterest(){
      test.startTest();
    Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
    delete interest;
      test.stopTest();
      List<String> mylist = new List<String>{'Interest1', 'Interest2'};
      String concat = Util_TMCR.combineList(mylist);
      Account acc = getAccount();
      System.assertEquals(acc.Account_Interests_List__c, concat);
    }
    static testMethod void test_undeleteInterest(){
      test.startTest();
    Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
    delete interest;
    undelete interest;
      test.stopTest();
      List<String> mylist = new List<String>{'Interest0', 'Interest1', 'Interest2'};
      String concat = Util_TMCR.combineList(mylist);
      Account acc = getAccount();
      System.assertEquals(acc.Account_Interests_List__c, concat);
    }
}


 
I have a custom controller and a Visualforce page and every time I try to save the page, I get the error:
Error: Unknown property 'TMCR_AssocInventorController.inventors'
I can't seem to figure it out. My problem seems to be identical to another entry: https://developer.salesforce.com/forums/ForumsMain?id=906F000000096uoIAA however it's been of no use as I still get the error.

Any help is much appreciated!

Here's the Visualforce page:
<apex:page Controller="AssocInventorController" tabstyle="Case">
    <apex:pageBlock title="Associated Inventors" >
    <apex:pageBlockTable value="{!inventors}" var="ai">
        <apex:column headerValue="Id"><a href="/{!ai.Id}">{!ai.Id}</a></apex:column>
        <apex:column headerValue="Inventor"><a href="/{!ai.Inventor__c}">{!ai.Inventor__c}</a></apex:column>
        <apex:column headerValue="Inventor Type">{!ai.Inventor_Type__c}</apex:column>
        <apex:column headerValue="Role">{!ai.Role__c}</apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
And here's the Controller:
public with sharing class AssocInventorController {
	public List<Associated_Inventor__c> Inventors {get{
		if (Inventors = null){
			Inventors = getInventors();
		}
	}private set;}
	public List<Associated_Inventor__c> getInventors() {
		return [
			select id, Inventor__c, Inventor_Type__c, Role__c 
			from Associated_Inventor__c 
			where SF_ID__c = :System.currentPageReference().getParameters().get('id')
			group by Inventor__c
			order by Case_Filing__r.Name asc
		];
	}
}

 
Hi folks,
Found something interesting while researching regarding another posted bug:
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BYt2

I've got a trigger and a test class for it. The trigger basically takes a related list of values and concatenates it, saving it as part of the Account object. My test cases all fail, showing the following error:
Class.TMCR_testAccountInterestList.test_addInterest: line 51, column 1
14:18:05.697 (6697124228)|FATAL_ERROR|System.AssertException: Assertion Failed: Expected: foo
Interest0
Interest1
Interest2
, Actual: foo
Interest0
Interest1
Interest2

The data looks identical. Just to be sure, I put the strings through a hex conversion to compare their hex values and they are indeed different.

My question is what gives? Why are they different? The data going in should be the same.

For reference, here are is the Trigger:
trigger Account_UpdateAccountInterestsList on Interest__c (after delete, after insert, after undelete, 
after update) {
	Interest__c[] interests;
    if (Trigger.isDelete) 
        interests = Trigger.old;
    else
        interests = Trigger.new;
	Set<ID> affected_accounts = new Set<ID>();
	Map<ID, Set<String>> account_interests = new Map<ID, Set<String>>();
	for(Interest__c interest: interests){
		affected_accounts.add(interest.Account__c);
		account_interests.put(interest.Account__c, new Set<String>());
	}

	List<Interest__c> all_interests = [
		SELECT Id, Account__c, Interest__r.Name
		FROM Interest__c
		WHERE Account__c IN :affected_accounts
		ORDER BY Interest__r.Name
	];
	List<Account> accounts_to_update = [
		SELECT Id, Account_Interests_List__c
		FROM Account
		WHERE Id IN :affected_accounts
	];
	
	for(Interest__c interest: all_interests){
		account_interests.get(interest.Account__c).add(interest.Interest__r.Name);
	}
	for(Account account: accounts_to_update){
		account.Account_Interests_List__c = Util_TMCR.combineList(account_interests.get(account.Id));
	}
	
	update accounts_to_update;
}
Here is the test class:
@isTest
private class TMCR_testAccountInterestList {
	static Account getAccount(){
		Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
		Account acc = [
			SELECT Id, Account_Interests_List__c
			FROM Account WHERE Name = :account.get('name')
		];
		return acc;
	}
	static Interests__c addInterest(String name){
		Interests__c new_interest = new Interests__c(Name = name);
		insert new_interest;
		return new_interest;
	}
	static Interest__c addToAccount(Account acc, Interests__c interest){
		Interest__c acc_interest = new Interest__c(Interest__c = interest.Id, Account__c = acc.Id);
		insert acc_interest;
		return acc_interest;
	}
	
	@testSetup
	static void setup(){
		List<Interests__c> interests = new List<Interests__c>();
		List<Interest__c> account_interests = new List<Interest__c>();
		for(Integer i=0; i<3;i++){
			interests.add(addInterest('Interest' + i));
		}
		Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
		Account acc = account.generate();
		for(Interests__c interest: interests){
			account_interests.add(addToAccount(acc, interest));
		}
	}
	
    static testMethod void test_addInterest() {
		test.startTest();
		Account account = getAccount();
		Interests__c interest = addInterest('foo');
		Interest__c acc_interest = addToAccount(account, interest);
		test.stopTest();
		
		String concat = Util_TMCR.combineList(new List<String>{'foo', 'Interest0', 'Interest1', 'Interest2'});
		Account acc = getAccount();
		System.assertEquals(concat, acc.Account_Interests_List__c);
    }
    static testMethod void test_changeInterest() {
    	test.startTest();
		Interests__c interest = addInterest('foo');
		Interest__c acc_interest = [SELECT Id, Interest__c from Interest__c WHERE Interest__r.Name = 'Interest0' LIMIT 1];
		acc_interest.Interest__c = interest.Id;
		update acc_interest;
    	test.stopTest();
    	List<String> mylist = new List<String>{'foo', 'Interest1', 'Interest2'};
    	String concat = Util_TMCR.combineList(mylist);
    	Account acc = getAccount();
    	System.assertEquals(concat, acc.Account_Interests_List__c);
    }
    static testMethod void test_deleteInterest(){
    	test.startTest();
		Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
		delete interest;
    	test.stopTest();
    	List<String> mylist = new List<String>{'Interest1', 'Interest2'};
    	String concat = Util_TMCR.combineList(mylist);
    	Account acc = getAccount();
    	System.assertEquals(concat, acc.Account_Interests_List__c);
    }
    static testMethod void test_undeleteInterest(){
    	test.startTest();
		Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
		delete interest;
		undelete interest;
    	test.stopTest();
    	List<String> mylist = new List<String>{'Interest0', 'Interest1', 'Interest2'};
    	String concat = Util_TMCR.combineList(mylist);
    	Account acc = getAccount();
    	System.assertEquals(concat, acc.Account_Interests_List__c);
    }
}
Finally, here is the function that concatenates both the expected list and the actual list:
public static String combineList(List<String> items){
        String out = '';
        String delimiter = '\n';
        for(String val : items){
        	out = out + val;
        	if(val.right(1) != delimiter){
        		out = out + delimiter;
        	}
        }
        return out;
    }





 
Hi folks,
I developed a trigger for my production environment in the Eclipse IDE. When I go to save it to my environment, it shows an error that code coverage is 0%. I've developed a test class for this trigger, and when I run the test from the IDE, it shows test coverage for my trigger at 100% (0 lines not tested).

What gives? Is there another way to get my trigger to save onto my environment? I tried using the Development Console but that didn't work due to the 'Metadata can't be changed on an active environment' bug.

Any help is appreciated.

Trigger:
trigger Account_UpdateAccountInterestsList on Interest__c (after delete, after insert, after undelete, 
after update) {
	Interest__c[] interests;
    if (Trigger.isDelete) 
        interests = Trigger.old;
    else
        interests = Trigger.new;
	Set<ID> affected_accounts = new Set<ID>();
	Map<ID, List<String>> account_interests = new Map<ID, List<String>>();
	for(Interest__c interest: interests){
		affected_accounts.add(interest.Account__c);
		account_interests.put(interest.Account__c, new List<String>());
	}

	List<Interest__c> all_interests = [
		SELECT Id, Account__c, Interest__r.Name
		FROM Interest__c
		WHERE Account__c IN :affected_accounts
		ORDER BY Interest__r.Name
	];
	List<Account> accounts_to_update = [
		SELECT Id, Account_Interests_List__c
		FROM Account
		WHERE Id IN :affected_accounts
	];
	
	for(Interest__c interest: all_interests){
		account_interests.get(interest.Account__c).add(interest.Interest__r.Name + '\n');
	}
	for(Account account: accounts_to_update){
		account.Account_Interests_List__c = Util_TMCR.combineList(account_interests.get(account.Id));
	}
	
	update accounts_to_update;
}


Test class:
@isTest
private class TMCR_testAccountInterestList {
  /*
    Testing Account_UpdateAccountInterestsList trigger
  */
  static Account getAccount(){
    Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
    Account acc = [
      SELECT Id, Account_Interests_List__c
      FROM Account WHERE Name = :account.get('name')
    ];
    return acc;
  }
  static Interests__c addInterest(String name){
    Interests__c new_interest = new Interests__c(Name = name);
    insert new_interest;
    return new_interest;
  }
  static Interest__c addToAccount(Account acc, Interests__c interest){
    Interest__c acc_interest = new Interest__c(Interest__c = interest.Id, Account__c = acc.Id);
    insert acc_interest;
    return acc_interest;
  }
  
  @testSetup
  static void setup(){
    List<Interests__c> interests = new List<Interests__c>();
    List<Interest__c> account_interests = new List<Interest__c>();
    for(Integer i=0; i<3;i++){
      interests.add(addInterest('Interest' + i));
    }
    Util_TMCR_DataFactory.accounts account = new Util_TMCR_DataFactory.accounts();
    Account acc = account.generate();
    for(Interests__c interest: interests){
      account_interests.add(addToAccount(acc, interest));
    }
  }
  
    static testMethod void test_addInterest() {
    test.startTest();
    Account account = getAccount();
    Interests__c interest = addInterest('foo');
    Interest__c acc_interest = addToAccount(account, interest);
    test.stopTest();
    
    String concat = Util_TMCR.combineList(new List<String>{'foo', 'Interest0', 'Interest1', 'Interest2'});
    Account acc = getAccount();
    System.assertEquals(acc.Account_Interests_List__c, concat);
    }
    static testMethod void test_changeInterest() {
      test.startTest();
    Interests__c interest = addInterest('foo');
    Interest__c acc_interest = [SELECT Id, Interest__c from Interest__c WHERE Interest__r.Name = 'Interest0' LIMIT 1];
    acc_interest.Interest__c = interest.Id;
    update acc_interest;
      test.stopTest();
      List<String> mylist = new List<String>{'foo', 'Interest1', 'Interest2'};
      String concat = Util_TMCR.combineList(mylist);
      Account acc = getAccount();
      System.assertEquals(acc.Account_Interests_List__c, concat);
    }
    static testMethod void test_deleteInterest(){
      test.startTest();
    Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
    delete interest;
      test.stopTest();
      List<String> mylist = new List<String>{'Interest1', 'Interest2'};
      String concat = Util_TMCR.combineList(mylist);
      Account acc = getAccount();
      System.assertEquals(acc.Account_Interests_List__c, concat);
    }
    static testMethod void test_undeleteInterest(){
      test.startTest();
    Interests__c interest = [SELECT Id, Name FROM Interests__c WHERE Name = 'Interest0' LIMIT 1];
    delete interest;
    undelete interest;
      test.stopTest();
      List<String> mylist = new List<String>{'Interest0', 'Interest1', 'Interest2'};
      String concat = Util_TMCR.combineList(mylist);
      Account acc = getAccount();
      System.assertEquals(acc.Account_Interests_List__c, concat);
    }
}