You need to sign in to do that
Don't have an account?

Test class for Json method
Hi Experts,
Can anyone help me how to write test class for the below method.
public override void onCommit(){
OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
Map<String, List<SObject>> accObjects = OM_WorkService.getSObjects(accJSON);
Account acc = (Account)accObjects.get('Account')[0];
if(acc!= null){
upsert acc;
super.onCommit();
}
Below is the OM_WorkService.getJSONAttribut
public static String getJSONAttribute(String jsonStr, String attr){
Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
if(m.containsKey(attr))
return (String)m.get(attr);
return null;
}
Can anyone help me how to write test class for the below method.
public override void onCommit(){
OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
Map<String, List<SObject>> accObjects = OM_WorkService.getSObjects(accJSON);
Account acc = (Account)accObjects.get('Account')[0];
if(acc!= null){
upsert acc;
super.onCommit();
}
Below is the OM_WorkService.getJSONAttribut
public static String getJSONAttribute(String jsonStr, String attr){
Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
if(m.containsKey(attr))
return (String)m.get(attr);
return null;
}
Then you have to call the commit method within the test method. If you can send definition for svc from OM_ManageService class and the name of the class where onCommit method exists. So I can send you more code regarding this.