{"id":534,"date":"2024-06-05T14:24:39","date_gmt":"2024-06-05T14:24:39","guid":{"rendered":"https:\/\/beinthecloud.biz\/sfdc\/1\/?p=534"},"modified":"2024-06-05T14:27:04","modified_gmt":"2024-06-05T14:27:04","slug":"example-of-an-apex-class-to-get-account-details-and-its-corresponding-test-class","status":"publish","type":"post","link":"https:\/\/beinthecloud.biz\/sfdc\/1\/2024\/06\/05\/example-of-an-apex-class-to-get-account-details-and-its-corresponding-test-class\/","title":{"rendered":"Example of an Apex class to get account details and its corresponding test class"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>public class AccountDetails {\n    \/\/ Method to retrieve account details based on account Id\n    public static Account getAccountDetails(Id accId) {\n        return &#91;SELECT Id, Name, Industry, Type, Phone, Website FROM Account WHERE Id = :accId];\n    }\n}\n\n\nHere's the corresponding test class:\n\n@isTest\npublic class AccountDetailsTest {\n    \/\/ Test method to verify account details retrieval\n    @isTest\n    static void testGetAccountDetails() {\n        \/\/ Create test account\n        Account testAccount = new Account(Name='Test Account', Industry='Technology', Type='Customer', Phone='1234567890', Website='www.example.com');\n        insert testAccount;\n\n        \/\/ Retrieve the test account details using the method\n        Account retrievedAccount = AccountDetails.getAccountDetails(testAccount.Id);\n\n        \/\/ Verify if the retrieved account details match the expected values\n        System.assertEquals(testAccount.Name, retrievedAccount.Name);\n        System.assertEquals(testAccount.Industry, retrievedAccount.Industry);\n        System.assertEquals(testAccount.Type, retrievedAccount.Type);\n        System.assertEquals(testAccount.Phone, retrievedAccount.Phone);\n        System.assertEquals(testAccount.Website, retrievedAccount.Website);\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":535,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[17],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-content\/uploads\/2024\/06\/Learning-Apex-Salesforce.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts\/534"}],"collection":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/comments?post=534"}],"version-history":[{"count":1,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts\/534\/revisions"}],"predecessor-version":[{"id":536,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/posts\/534\/revisions\/536"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/media\/535"}],"wp:attachment":[{"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/media?parent=534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/categories?post=534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beinthecloud.biz\/sfdc\/1\/wp-json\/wp\/v2\/tags?post=534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}