-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
3Questions
-
0Replies
How do I test a class that inserts objects.
I've created a class that is used to insert a new account when a contact is created (via a before insert trigger on the contact object). It works, however it will not pass testing because of the query (I think) I am using in the test method. What is the best way to test that the account was created successfully?
static testMethod void validateNewContactWithNewAccount() {
Contact c = new Contact();
c.firstname = 'Phillip';
c.lastname = 'Cave';
c.Temp_Organization_Name__c = 'Jackson River';
c.Temp_Address_Line_1__c = '129 Bally Shannon Way';
c.Temp_City__c = 'Apex';
c.Temp_State__c = 'NC';
c.Temp_Zip_Code__c = '27539';
c.Temp_Overview__c = 'This is the organization overview';
c.Temp_Website__c = 'http://www.jacksonriver.com';
//c.Organization_Type__c = 'Pimphouse';
// test our insert trigger
insert c;
Account b = [select id, name, shippingstreet, shippingcity from account where id = :c.accountid];
System.assertEquals(b.id, c.accountid);
System.assertEquals('Jackson River', b.name);
System.assertEquals('129 Bally Shannon Way', b.ShippingStreet);
System.assertEquals('Apex', b.ShippingCity);
}
-
- pcave
- September 25, 2009
- Like
- 0
- Continue reading or reply
Are blank sObject fields an empty string or NULL
I'm writing some apex code that needs to check to see if a contact has an account assigned via the AccountId field. Do I need to check for an empty or null value? as in?
if (c.AccountId != NULL)
or
if (c.Account != '')
Thanks,
Phillip
-
- pcave
- September 24, 2009
- Like
- 1
- Continue reading or reply
Apex governor limits
Hello, I'm doing some intergartion work through the salesforce api and I recently got the following warning.
Operation: insert.npe03__Recurring_Donation__c
By user/organization: 00580000001snmg/00D80000000cnJ5
Caused the following Apex resource warnings:
npe03:Number of DML rows: 128 out of 200
I'm not really sure what this means as I know I'm not doing 128 inserts at once.
Does the 200 limit apply to a certain timespan?
Any help is appreciated.
Thanks,
Phillip
-
- pcave
- September 09, 2009
- Like
- 0
- Continue reading or reply
Are blank sObject fields an empty string or NULL
I'm writing some apex code that needs to check to see if a contact has an account assigned via the AccountId field. Do I need to check for an empty or null value? as in?
if (c.AccountId != NULL)
or
if (c.Account != '')
Thanks,
Phillip
-
- pcave
- September 24, 2009
- Like
- 1
- Continue reading or reply