How to test the below : Please help me test the below code..can anyone tell what parameter should be passes while calling this method in test class

public static String getFieldListAsCSV(sObjectType sobject_type) {
        Map<String, Schema.SObjectField> field_map = getObjectFields(sobject_type);
        return String.join(new List<String>(field_map.keySet()), ',');

Parameter would be anysObject.sObjectType

For eg. Contact.sObjectType

This method should give you a comma separated String which would contain the fields name of given sObject type.Although i'm not sure it's syntactically correct or not.

  • this worked, thank you. Can you please help me with below too : 1. public static void populateFields(Sobject currObj, Map<string, object> fieldValues) 2. public static string findKeyPrefix(Schema.sObjectType currSobjectType) – wizard Jun 7 '16 at 5:01
  • In first one you can pass any sObjectReference like Contact con and with that you need to pass a map.In second one the parameter given in answer has to be passed. – Mr.Frodo Jun 7 '16 at 5:08
  • can you please help me with above – wizard Jun 7 '16 at 5:08
  • Util.populateFields(Account acc,Map<'abc',account>); Util.findKeyPrefix(Account.sObjectType); I am getting error in 1st one – wizard Jun 7 '16 at 5:11
  • You don't pass parameters like this way dear. you are only passing the type in second parameter and not the actual map. – Mr.Frodo Jun 7 '16 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.