• Cesinco
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 12
    Replies

Hi all,

 

After struggling with the intricacies of  setting up a sandbox, writing my trigger, then writing the test class, and finally have it pass in my sandbox, when I tried to validate the deployment in our production environment, it failed with the message:

 

Failure Message: "System.Exception: Assertion Failed", Failure Stack Trace: "Class.chatterFollowBatchCaller.testchatterFollowBatchCaller: line 176, column 1"

 

As best as I can tell, during validation, it is trying to runt he tesMethod testchatterFollowBatchCaller and failing on line 176, i.e.

 

system.assert(afterFollows.size()>0);

 

but I honestly have no idea why that is, nor why it's failing (well, it falis because the size is 0, rather than > 0 - that much I know).

 

Why would someone else's code want to run a test when I am trying to validate my own code? More importantly, how do I avoid this validation, at least until I can deploy my own code?

Hi folks,

 

Trying to deploy a really simple trigger and getting into problems - hope someone "out there" can help.

 

BTW, the Collaboration Group named "Technology Roadmap" does indeed exist in both sandbox and production envirtonments so the chatterGroups List variable should contain the single CollaborationGroup object. Instead, the test class errors with the message:

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PostToChatterOnNewTechRoadmap: execution of AfterInsert caused by: System.ListException: List index out of bounds: 0 Trigger.PostToChatterOnNewTechRoadmap: line 9, column 1: []", Failure Stack Tra...

 

Trigger code:

 

trigger PostToChatterOnNewTechRoadmap on Technology_Roadmap__c (after insert) {

	CollaborationGroup chatterGroup;
	List<CollaborationGroup> chatterGroups = [SELECT Id FROM CollaborationGroup WHERE Name=:'Technology Roadmap' LIMIT 1];
	//if (chatterGroups.isEmpty()) {
	//	chatterGroup = new CollaborationGroup();
	//	chatterGroup.id = '0F9W0000000Cch3KAC';
	//} else {
		chatterGroup = chatterGroups[0];
	//}

	for (Technology_Roadmap__c trm : Trigger.new) {
		FeedItem fitem = new FeedItem();
		fitem.type = 'LinkPost'; //'TextPost,';
		fitem.ParentId = chatterGroup.id; //'0F9W0000000Ccge' = Sandbox; //'0F920000000PItQ' = Production;
		fitem.LinkUrl = '/' + trm.id;
		fitem.Title = 'New Technology Roadmap: ' + trm.Name;
		fitem.Body = 'Design Discipline: ' + ((trm.Design_Discipline__c != null) ? trm.Design_Discipline__c : 'Not specified')
					+ '\nCircuit Application: ' + ((trm.Circuit_Application__c != null) ? trm.Circuit_Application__c : 'Not specified')
					+ '\nSegment: ' + ((trm.Segment__c != null) ? trm.Segment__c + ((trm.Subsegment__c != null) ? ' => ' + trm.Subsegment__c : '') : 'Not specified');
		insert fitem;
	}

}

 

Test class:

 

@isTest
public class Test_trig_PostToChatterOnNewTechRoadmap{

	static testMethod void verifyPostToChatterOnNewTechRoadmap() {

		//CollaborationGroup chatterGroup = [SELECT Id FROM CollaborationGroup WHERE Name='Technology Roadmap' LIMIT 1];

		CollaborationGroup chatterGroup;
		List<CollaborationGroup> chatterGroups = [SELECT Id FROM CollaborationGroup WHERE Name=:'Technology Roadmap' LIMIT 1];
		if (chatterGroups.isEmpty()) {
			chatterGroup = new CollaborationGroup();
			chatterGroup.id = '0F9W0000000Cch3KAC';
		} else {
			chatterGroup = chatterGroups[0];
		}

		List<Technology_Roadmap__c> ltrm = new List<Technology_Roadmap__c>{};
		for (integer i=0; i<10; i++) {
			Technology_Roadmap__c trm = new Technology_Roadmap__c(Name = 'trigCoverageTest_' + i);
			trm.Design_Discipline__c = 'AC';
			System.debug('Name: ' + trm.Name);
			System.debug('Design Discipline: ' + trm.Design_Discipline__c);
			ltrm.add(trm);
		}

		test.startTest();
		insert ltrm;
		test.stopTest();

		List<FeedItem> lfi = [SELECT Title, Body FROM FeedItem WHERE ParentId = :chatterGroup.id ORDER BY Title];

		integer j = 0;
		string assTitle;
		for (FeedItem fi : lfi) {
			assTitle = 'New Technology Roadmap: trigCoverageTest_' + j++;
			System.debug(fi.Title);
			System.assertEquals(assTitle, fi.Title);
		}
	}
}

 

 

 

I start by going to the developer console and Choosing "Triggers" within the Setup Entity Type, then below, I choose a Type from the selection list and click the "New" button to the left of the list. After thinking for a few seconds, the platform responds with a window that looks like:

 

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

ENTITY_IS_LOCKED

 

Can not create Apex Trigger on an active organization.

 

OK

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

 

This message is really meaningless to me. Can anyone help decipher it?

 

Hi folks,

 

Trying to deploy a really simple trigger and getting into problems - hope someone "out there" can help.

 

BTW, the Collaboration Group named "Technology Roadmap" does indeed exist in both sandbox and production envirtonments so the chatterGroups List variable should contain the single CollaborationGroup object. Instead, the test class errors with the message:

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PostToChatterOnNewTechRoadmap: execution of AfterInsert caused by: System.ListException: List index out of bounds: 0 Trigger.PostToChatterOnNewTechRoadmap: line 9, column 1: []", Failure Stack Tra...

 

Trigger code:

 

trigger PostToChatterOnNewTechRoadmap on Technology_Roadmap__c (after insert) {

	CollaborationGroup chatterGroup;
	List<CollaborationGroup> chatterGroups = [SELECT Id FROM CollaborationGroup WHERE Name=:'Technology Roadmap' LIMIT 1];
	//if (chatterGroups.isEmpty()) {
	//	chatterGroup = new CollaborationGroup();
	//	chatterGroup.id = '0F9W0000000Cch3KAC';
	//} else {
		chatterGroup = chatterGroups[0];
	//}

	for (Technology_Roadmap__c trm : Trigger.new) {
		FeedItem fitem = new FeedItem();
		fitem.type = 'LinkPost'; //'TextPost,';
		fitem.ParentId = chatterGroup.id; //'0F9W0000000Ccge' = Sandbox; //'0F920000000PItQ' = Production;
		fitem.LinkUrl = '/' + trm.id;
		fitem.Title = 'New Technology Roadmap: ' + trm.Name;
		fitem.Body = 'Design Discipline: ' + ((trm.Design_Discipline__c != null) ? trm.Design_Discipline__c : 'Not specified')
					+ '\nCircuit Application: ' + ((trm.Circuit_Application__c != null) ? trm.Circuit_Application__c : 'Not specified')
					+ '\nSegment: ' + ((trm.Segment__c != null) ? trm.Segment__c + ((trm.Subsegment__c != null) ? ' => ' + trm.Subsegment__c : '') : 'Not specified');
		insert fitem;
	}

}

 

Test class:

 

@isTest
public class Test_trig_PostToChatterOnNewTechRoadmap{

	static testMethod void verifyPostToChatterOnNewTechRoadmap() {

		//CollaborationGroup chatterGroup = [SELECT Id FROM CollaborationGroup WHERE Name='Technology Roadmap' LIMIT 1];

		CollaborationGroup chatterGroup;
		List<CollaborationGroup> chatterGroups = [SELECT Id FROM CollaborationGroup WHERE Name=:'Technology Roadmap' LIMIT 1];
		if (chatterGroups.isEmpty()) {
			chatterGroup = new CollaborationGroup();
			chatterGroup.id = '0F9W0000000Cch3KAC';
		} else {
			chatterGroup = chatterGroups[0];
		}

		List<Technology_Roadmap__c> ltrm = new List<Technology_Roadmap__c>{};
		for (integer i=0; i<10; i++) {
			Technology_Roadmap__c trm = new Technology_Roadmap__c(Name = 'trigCoverageTest_' + i);
			trm.Design_Discipline__c = 'AC';
			System.debug('Name: ' + trm.Name);
			System.debug('Design Discipline: ' + trm.Design_Discipline__c);
			ltrm.add(trm);
		}

		test.startTest();
		insert ltrm;
		test.stopTest();

		List<FeedItem> lfi = [SELECT Title, Body FROM FeedItem WHERE ParentId = :chatterGroup.id ORDER BY Title];

		integer j = 0;
		string assTitle;
		for (FeedItem fi : lfi) {
			assTitle = 'New Technology Roadmap: trigCoverageTest_' + j++;
			System.debug(fi.Title);
			System.assertEquals(assTitle, fi.Title);
		}
	}
}

 

 

 

I start by going to the developer console and Choosing "Triggers" within the Setup Entity Type, then below, I choose a Type from the selection list and click the "New" button to the left of the list. After thinking for a few seconds, the platform responds with a window that looks like:

 

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

ENTITY_IS_LOCKED

 

Can not create Apex Trigger on an active organization.

 

OK

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

 

This message is really meaningless to me. Can anyone help decipher it?