[SalesForce] Method does not exist or incorrect signature: void parse(String) from the type or_propertyJSONTest

I am new to apex callouts and trying to do some JSON parsing. I used the online tool https://www.adminbooster.com/tool/json2apex which worked great.

I got a class and a testclass from the adminbooster. I am calling the class as an object in my testclass but get folowwing error:

Method does not exist or incorrect signature: void parse(String) from
the type or_propertyJSONTest.

My Class:

public class or_propertyJSON{
public ..
public ..

class cls_photos {
}
class cls_bedTypes {
    public ..
    public ..
}
public static or_propertyJSON parse(String json){
    return (or_propertyJSON) System.JSON.deserialize(json, or_propertyJSON.class);
}

}

My testclass:

    @isTest
public class or_propertyJSONTest {
    static testMethod void testParse() {
        String json= '{"..":"..",".."}';
        or_propertyJSON obj = parse(json);
        System.assert(obj != null);
    }
}

Best Answer

Since you are calling the parse method which is static so className.methodName() or_propertyJSON.parse(json) should be used.

@isTest
public class or_propertyJSONTest {
    static testMethod void testParse() {
        String json= '{"..":"..",".."}';
        or_propertyJSON obj = or_propertyJSON.parse(json);
        System.assert(obj != null);
    }
}
Related Topic