• Veena Gopal
  • NEWBIE
  • 83 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 3
    Likes Given
  • 11
    Questions
  • 41
    Replies
the question in the challenge is:The method must return the ID and Name for the requested record and all associated contacts with their ID and Name.

but ppl have passed the trailhead by using similar code:
Account result =  [Select Id,Name ,(Select Id, Name From Contacts) From Account where Id = :accId];
        return result;

When i put this in the execute anonymous window:-
Account result =  [Select Id,Name ,(Select Id, Name From Contacts) From Account where Id = '00128000005ee4zAAA'];
system.debug(result);

I get only the account id i do not get the contact ids related to it.
How to go about doing it?
Please help. 
In the Developer Intermediate ----> Apex Integration Services ------>apex soap callouts, 
a test example is given class name is AwesomeCalculatorTest.
@isTest
private class AwesomeCalculatorTest {
    @isTest static void testCallout() {              
        // This causes a fake response to be generated
        Test.setMock(WebServiceMock.class, new CalculatorCalloutMock());
        // Call the method that invokes a callout
        Double x = 1.0;
        Double y = 2.0;
        Double result = AwesomeCalculator.add(x, y);
        // Verify that a fake result is returned
        System.assertEquals(3.0, result); 
    }
}
This one tests the add functionality of the generated wsdl class.
The below is the test class for mock callout and below is the wsdl class
@isTest
global class CalculatorCalloutMock implements WebServiceMock {
   global void doInvoke(
           Object stub,
           Object request,
           Map<String, Object> response,
           String endpoint,
           String soapAction,
           String requestName,
           String responseNS,
           String responseName,
           String responseType) {
        // start - specify the response you want to send
        calculatorServices.doAddResponse response_x = 
            new calculatorServices.doAddResponse();
        response_x.return_x = 3.0;
        // end
        response.put('response_x', response_x); 
   }
}
 
//Generated by wsdl2apex

public class calculatorServices {
    public class doDivideResponse {
        public Double return_x;
        private String[] return_x_type_info = new String[]{'return','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
    public class doMultiply {
        public Double arg0;
        public Double arg1;
        private String[] arg0_type_info = new String[]{'arg0','http://calculator.services/',null,'0','1','false'};
        private String[] arg1_type_info = new String[]{'arg1','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'arg0','arg1'};
    }
    public class doAdd {
        public Double arg0;
        public Double arg1;
        private String[] arg0_type_info = new String[]{'arg0','http://calculator.services/',null,'0','1','false'};
        private String[] arg1_type_info = new String[]{'arg1','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'arg0','arg1'};
    }
    public class doAddResponse {
        public Double return_x;
        private String[] return_x_type_info = new String[]{'return','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
    public class doDivide {
        public Double arg0;
        public Double arg1;
        private String[] arg0_type_info = new String[]{'arg0','http://calculator.services/',null,'0','1','false'};
        private String[] arg1_type_info = new String[]{'arg1','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'arg0','arg1'};
    }
    public class doSubtract {
        public Double arg0;
        public Double arg1;
        private String[] arg0_type_info = new String[]{'arg0','http://calculator.services/',null,'0','1','false'};
        private String[] arg1_type_info = new String[]{'arg1','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'arg0','arg1'};
    }
    public class doSubtractResponse {
        public Double return_x;
        private String[] return_x_type_info = new String[]{'return','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
    public class doMultiplyResponse {
        public Double return_x;
        private String[] return_x_type_info = new String[]{'return','http://calculator.services/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://calculator.services/','false','false'};
        private String[] field_order_type_info = new String[]{'return_x'};
    }
    public class CalculatorImplPort {
        public String endpoint_x = 'https://th-apex-soap-service.herokuapp.com/service/calculator';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://calculator.services/', 'calculatorServices'};
        public Double doDivide(Double arg0,Double arg1) {
            calculatorServices.doDivide request_x = new calculatorServices.doDivide();
            request_x.arg0 = arg0;
            request_x.arg1 = arg1;
            calculatorServices.doDivideResponse response_x;
            Map<String, calculatorServices.doDivideResponse> response_map_x = new Map<String, calculatorServices.doDivideResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://calculator.services/',
              'doDivide',
              'http://calculator.services/',
              'doDivideResponse',
              'calculatorServices.doDivideResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
        public Double doSubtract(Double arg0,Double arg1) {
            calculatorServices.doSubtract request_x = new calculatorServices.doSubtract();
            request_x.arg0 = arg0;
            request_x.arg1 = arg1;
            calculatorServices.doSubtractResponse response_x;
            Map<String, calculatorServices.doSubtractResponse> response_map_x = new Map<String, calculatorServices.doSubtractResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://calculator.services/',
              'doSubtract',
              'http://calculator.services/',
              'doSubtractResponse',
              'calculatorServices.doSubtractResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
        public Double doMultiply(Double arg0,Double arg1) {
            calculatorServices.doMultiply request_x = new calculatorServices.doMultiply();
            request_x.arg0 = arg0;
            request_x.arg1 = arg1;
            calculatorServices.doMultiplyResponse response_x;
            Map<String, calculatorServices.doMultiplyResponse> response_map_x = new Map<String, calculatorServices.doMultiplyResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://calculator.services/',
              'doMultiply',
              'http://calculator.services/',
              'doMultiplyResponse',
              'calculatorServices.doMultiplyResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
        public Double doAdd(Double arg0,Double arg1) {
            calculatorServices.doAdd request_x = new calculatorServices.doAdd();
            request_x.arg0 = arg0;
            request_x.arg1 = arg1;
            calculatorServices.doAddResponse response_x;
            Map<String, calculatorServices.doAddResponse> response_map_x = new Map<String, calculatorServices.doAddResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://calculator.services/',
              'doAdd',
              'http://calculator.services/',
              'doAddResponse',
              'calculatorServices.doAddResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.return_x;
        }
    }
}

I want to test all the add, divide, multiply, subtract in one go for which i have to change the class CalculatorCalloutMock and AwesomeCalculatorTest. When i make changes in the CalculatorCalloutMock class, it gives me error response_x and return_x duplicate since it is the same variable used in all the doResponse. 
Please help how i can test all functionality in one test class to achieve 100% coverage.
 
https://help.salesforce.com/articleView?id=knowledge_articles.htm&type=0
The above link shows article and knowledge tabs but not able to see the same in my developer edition.
Pls help
when using json2apex-http://json2apex.herokuapp.com

i got different codes for different json strings.
{"size":141,"totalSize":141,"done":true,"queryLocator":null,"entityTypeName":"ApexCodeCoverageAggregate","records":[{"attributes":{"type":"ApexCodeCoverageAggregate","url":"/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715000000LxWDAA0"},"Id":"715000000LxWDAA0","ApexClassOrTrigger":{"attributes":{"type":"Name","url":"/services/data/v33.0/tooling/sobjects/ApexClass/01p000000C8J2AAK"},"Name":"MyCustomClass1"},"NumLinesCovered":0,"NumLinesUncovered":10},{"attributes":{"type":"ApexCodeCoverageAggregate","url":"/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715e0000000LxWEAA0"},"Id":"710000000LxWEAA0","ApexClassOrTrigger":{"attributes":{"type":"Name","url":"/services/data/v33.0/tooling/sobjects/ApexClass/01pe0000000C8JCAA0"},"Name":"MyCustomClass2"},"NumLinesCovered":7,"NumLinesUncovered":5}]}
for above json string i get
public static JSON2Apex parse(String json) {        
return new JSON2Apex(System.JSON.createParser(json));}
for below json string
{"animal":{"id":1,"name":"chicken","eats":"chicken food","says":"cluck cluck"}}
i get
public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
    }
please help me in understanding why is there so much difference in both the return statements which is in the end of parse code.
According to blog http://blog.adityanaag.com/22/Parsing+JSON+the+easy+way+using+Apex
when parsing a string 
{"size":141,"totalSize":141,"done":true,"queryLocator":null,"entityTypeName":"ApexCodeCoverageAggregate","records":[{"attributes":{"type":"ApexCodeCoverageAggregate","url":"/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715000000LxWDAA0"},"Id":"715000000LxWDAA0","ApexClassOrTrigger":{"attributes":{"type":"Name","url":"/services/data/v33.0/tooling/sobjects/ApexClass/01p000000C8J2AAK"},"Name":"MyCustomClass1"},"NumLinesCovered":0,"NumLinesUncovered":10},{"attributes":{"type":"ApexCodeCoverageAggregate","url":"/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715e0000000LxWEAA0"},"Id":"710000000LxWEAA0","ApexClassOrTrigger":{"attributes":{"type":"Name","url":"/services/data/v33.0/tooling/sobjects/ApexClass/01pe0000000C8JCAA0"},"Name":"MyCustomClass2"},"NumLinesCovered":7,"NumLinesUncovered":5}]}

produces below class
public class JSON2Apex {

	public class Attributes {
		public String type;
		public String url;
	}

	public class Records {
		public Attributes attributes;
		public String Id;
		public ApexClassOrTrigger ApexClassOrTrigger;
		public Integer NumLinesCovered;
		public Integer NumLinesUncovered;
	}

	public class ApexClassOrTrigger {
		public Attributes attributes;
		public String Name;
	}

	public Integer size;
	public Integer totalSize;
	public Boolean done;
	public Object queryLocator;
	public String entityTypeName;
	public List records;

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

but when i use json2apex to parse the same string i get as below:
//
// Generated by JSON2Apex http://json2apex.herokuapp.com/
//
// The supplied json has fields with names that are reserved words in apex
// and so can only be parsed with explicitly generated code, this option
// was auto selected for you.



public class JSON2Apex {
	
public static void consumeObject(JSONParser parser) {
		
Integer depth = 0;
		
do {
			
JSONToken curr = parser.getCurrentToken();
			
if (curr == JSONToken.START_OBJECT || 
curr == JSONToken.START_ARRAY) 
{

				depth++;
			} 
else if (curr == JSONToken.END_OBJECT || 
curr == JSONToken.END_ARRAY) {
	
		depth--;
			}
		} 
while (depth > 0 && parser.nextToken() != null);
	}

	
public class ApexClassOrTrigger {
		
public Attributes attributes {get;set;} 
		
public String Name {get;set;} 

		
public ApexClassOrTrigger(JSONParser parser) {
			
while (parser.nextToken() != JSONToken.END_OBJECT) {
				
if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
					
String text = parser.getText();
					
if (parser.nextToken() != JSONToken.VALUE_NULL) {
						
if (text == 'attributes') {
							
attributes = new Attributes(parser);
						} 
else if (text == 'Name') {
							
Name = parser.getText();
						} 
else {
							
System.debug(LoggingLevel.WARN, 'ApexClassOrTrigger consuming unrecognized property: '+text);
							consumeObject(parser);
						
}
					
}
				
}
			
}
		
}
	
}
	
	
public class JSON2Apex {
		
public Integer size {get;set;} 
		
public Integer totalSize {get;set;} 
		
public Boolean done {get;set;} 
		
public Object queryLocator {get;set;} 
		
public String entityTypeName {get;set;} 
		
public List<Records> records {get;set;} 


		
public JSON2Apex(JSONParser parser) {
			
while (parser.nextToken() != JSONToken.END_OBJECT) {
				
if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
					
String text = parser.getText();
					
if (parser.nextToken() != JSONToken.VALUE_NULL) {
						
if (text == 'size') {
							
size = parser.getIntegerValue();
						} 
else if (text == 'totalSize') {
							
totalSize = parser.getIntegerValue();
						} 
else if (text == 'done') {
							
done = parser.getBooleanValue();
						} 
else if (text == 'queryLocator') {
							
queryLocator = new Object(parser);
						} 
else if (text == 'entityTypeName') {
							
entityTypeName = parser.getText();
						} 
else if (text == 'records') {
							
records = new List<Records>();
							
while (parser.nextToken() != JSONToken.END_ARRAY) {
								
records.add(new Records(parser));
							}
						} else {
							
System.debug(LoggingLevel.WARN, 'JSON2Apex consuming unrecognized property: '+text);
							consumeObject(parser);
						}
					}
				}
			}
		}
	}
	
	
public class Attributes {
		
public String type_Z {get;set;} // in json: type
		
public String url {get;set;} 

		
public Attributes(JSONParser parser) {
			
while (parser.nextToken() != JSONToken.END_OBJECT) {
				
if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
					
String text = parser.getText();
					
if (parser.nextToken() != JSONToken.VALUE_NULL) {
						
if (text == 'type') {
							
type_Z = parser.getText();
						} 
else if (text == 'url') {
							
url = parser.getText();
						} 
else {
							
System.debug(LoggingLevel.WARN, 'Attributes consuming unrecognized property: '+text);
							consumeObject(parser);
						}
					}
				}
			}
		}
	}
	
	
public class Records {
		
public Attributes attributes {get;set;} 
		
public String Id {get;set;} 
		
public ApexClassOrTrigger ApexClassOrTrigger {get;set;} 
		
public Integer NumLinesCovered {get;set;} 
		
public Integer NumLinesUncovered {get;set;} 

		
public Records(JSONParser parser) {
			
while (parser.nextToken() != JSONToken.END_OBJECT) {
				
if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
					
String text = parser.getText();
					
if (parser.nextToken() != JSONToken.VALUE_NULL) {
						
if (text == 'attributes') {
							
attributes = new Attributes(parser);
						} 
else if (text == 'Id') {
							
Id = parser.getText();
						} 
else if (text == 'ApexClassOrTrigger') {
							
ApexClassOrTrigger = new ApexClassOrTrigger(parser);
						} 
else if (text == 'NumLinesCovered') {
							
NumLinesCovered = parser.getIntegerValue();
						} 
else if (text == 'NumLinesUncovered') {
							
NumLinesUncovered = parser.getIntegerValue();
						} 
else {
							
System.debug(LoggingLevel.WARN, 'Records consuming unrecognized property: '+text);
							consumeObject(parser);
						}
					}
				}
			}
		}
	}
	
	
	
public static JSON2Apex parse(String json) {
		
return new JSON2Apex(System.JSON.createParser(json));
	}
}

can anyone please help me in understanding how the blogger cleaned his code and came to such a simple code.​
rest callout trailhead test using static resource
I am getting the following error for a particular line. This is just a example given in the trailhead rest callouts testclass using static resource.
Line:Test.setMock(HttpCalloutMock.class, mock);
Error:Method does not exist or incorrect signature: void setMock(System.Type, System.StaticResourceCalloutMock) from the type test

As given in other posts, i have checked if there is a duplicate class named StaticResourceCalloutMock but i do not have any.
also the name of the static resource i have mentioned in the test class is correct.
Please help.
The code is as below:
@isTest
private class AnimalsCalloutsTest {
@isTest static void testGetCallout() {
// Create the mock response based on a static resource
StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
mock.setStaticResource('GetAnimalResource');
mock.setStatusCode(200);
mock.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Associate the callout with a mock response
Test.setMock(HttpCalloutMock.class, mock); -----> this is the line which is giving error.
// Call method to test
HttpResponse result = AnimalsCallouts.makeGetCallout();
// Verify mock response is not null
System.assertNotEquals(null,result, 'The callout returned a null response.');
// Verify status code
System.assertEquals(200,result.getStatusCode(), 'The status code is not 200.');
// Verify content type
System.assertEquals('application/json;charset=UTF-8', result.getHeader('Content-Type'), 'The content type value is not expected.');
// Verify the array contains 3 items
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(result.getBody());
List<Object> animals = (List<Object>) results.get('animals'); System.assertEquals(3, animals.size(), 'The array should only contain 3 items.');
}
}

Only genuine ppl answer my question.
I am getting the following error for a particular line. This is just a example given in the trailhead rest callouts testclass using static resource.
Line:Test.setMock(HttpCalloutMock.class, mock);
Error:Method does not exist or incorrect signature: void setMock(System.Type, System.StaticResourceCalloutMock) from the type test

As given in other posts, i have checked if there is a duplicate class named StaticResourceCalloutMock but i do not have any.
also the name of the static resource i have mentioned in the test class is correct.
Please help.
In Apex workbook in page 52, they have assigned a value to the field as below.
Units_Sold__c = (Double)(10*Math.random()+1));

what does this mean? what value will be stored in the field Units_Sold__c?
In the visualforce workbook the following example is given for constructor testing:
To test the constructor use the below code:-
// test the class constructor
static testMethod void testClassConstructor() {
Test.startTest();
WarehouseUtils utils = new WarehouseUtils(null);
Test.stopTest();
// We expect that utils is not null
System.assert(utils != null);
}
Why system assert has been checked for != null when null was actualy passed for the object?
Please let me know if you need more clarification on the question.
I am getting the following error for a particular line. This is just a example given in the trailhead rest callouts testclass using static resource.
Line:Test.setMock(HttpCalloutMock.class, mock);
Error:Method does not exist or incorrect signature: void setMock(System.Type, System.StaticResourceCalloutMock) from the type test

As given in other posts, i have checked if there is a duplicate class named StaticResourceCalloutMock but i do not have any.
also the name of the static resource i have mentioned in the test class is correct.
Please help.
the question in the challenge is:The method must return the ID and Name for the requested record and all associated contacts with their ID and Name.

but ppl have passed the trailhead by using similar code:
Account result =  [Select Id,Name ,(Select Id, Name From Contacts) From Account where Id = :accId];
        return result;

When i put this in the execute anonymous window:-
Account result =  [Select Id,Name ,(Select Id, Name From Contacts) From Account where Id = '00128000005ee4zAAA'];
system.debug(result);

I get only the account id i do not get the contact ids related to it.
How to go about doing it?
Please help. 
What is Synchronous and Asynchronous Apex ?
Hi Every one,
                     I have three check boxes and it have different input fields. When i select perticular checkbox respective amount field should display. same for other two also. So I have to check three conditions and respective field have to fetch.

Here is my formula:
IF(Travel_Request__r.Cash_Advance__c ==True, Travel_Request__r.Amount__c ,0,
Else If(Travel_Request__r.Travel_Card_Loaded__c ==True,  Travel_Request__r.Travel_card_Amount__c , 0 ),
Else if( Travel_Request__r.Travelers_Cheque__c ==True,( Travel_Request__r.Denomination__c * Travel_Request__r.Quantity__c),0))
)  

How can i do it with out else condition.
I'm newbie to coding !
So very basic question when i write test class, do I need to specify each field I wrote in trigger ?
I have a requirement where I need a text field to update with a specific value based on other picklist field values selected.
I need it to be configured using a trigger as there is already another trigger running on the same object. I have already configured this in process builder but I am getting an unhandled error message due to the existing trigger.
So what I need is the follow

Picklist_1__c = CIF
Picklist_2__c = Air

Text_Field__c = 4%
Hi All,

  I have created an Action with Action Type as 'Custom Visualforce' for a Custom object. Once I click on the the action button from my record details page the specified visualforce is invoked, which has an extension controller class that does my requirement. In my controller I am redirecting to specific URL based on some condition. I am able to see a pop up window even if I am redirecting the page to another URL/same record URL. How can I avoid this?

Is there any way to hide the pop-up window/action modal in case of redirecting the page?(I am not using Lightning component).
 
Can anyone suggest on the below scenario can be achieved via configuration or not:
I have Grand Parent(Custom Object) Parent(Opportunity) and Child(Child Opportunity),
Now,if Grand Parent's Record Type == Child Opportunity Record Type and date is greater than today then stamp this grand parent into child opportunity.
There is also a lookup relationship in this cutom object and opportunity.
https://help.salesforce.com/articleView?id=knowledge_articles.htm&type=0
The above link shows article and knowledge tabs but not able to see the same in my developer edition.
Pls help
when using json2apex-http://json2apex.herokuapp.com

i got different codes for different json strings.
{"size":141,"totalSize":141,"done":true,"queryLocator":null,"entityTypeName":"ApexCodeCoverageAggregate","records":[{"attributes":{"type":"ApexCodeCoverageAggregate","url":"/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715000000LxWDAA0"},"Id":"715000000LxWDAA0","ApexClassOrTrigger":{"attributes":{"type":"Name","url":"/services/data/v33.0/tooling/sobjects/ApexClass/01p000000C8J2AAK"},"Name":"MyCustomClass1"},"NumLinesCovered":0,"NumLinesUncovered":10},{"attributes":{"type":"ApexCodeCoverageAggregate","url":"/services/data/v33.0/tooling/sobjects/ApexCodeCoverageAggregate/715e0000000LxWEAA0"},"Id":"710000000LxWEAA0","ApexClassOrTrigger":{"attributes":{"type":"Name","url":"/services/data/v33.0/tooling/sobjects/ApexClass/01pe0000000C8JCAA0"},"Name":"MyCustomClass2"},"NumLinesCovered":7,"NumLinesUncovered":5}]}
for above json string i get
public static JSON2Apex parse(String json) {        
return new JSON2Apex(System.JSON.createParser(json));}
for below json string
{"animal":{"id":1,"name":"chicken","eats":"chicken food","says":"cluck cluck"}}
i get
public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
    }
please help me in understanding why is there so much difference in both the return statements which is in the end of parse code.
I am getting the following error for a particular line. This is just a example given in the trailhead rest callouts testclass using static resource.
Line:Test.setMock(HttpCalloutMock.class, mock);
Error:Method does not exist or incorrect signature: void setMock(System.Type, System.StaticResourceCalloutMock) from the type test

As given in other posts, i have checked if there is a duplicate class named StaticResourceCalloutMock but i do not have any.
also the name of the static resource i have mentioned in the test class is correct.
Please help.
Hi Everyone,

I would like to know can we return Multiple datatypes from single method in apex, Can anyone please help me .

Thanks.
Hi Everyone,

I would like to know can we return Multiple datatypes from single method in apex, Can anyone please help me .

Thanks.
In the Challenge it is requested to make a call to https://th-apex-http-callout.herokuapp.com/animals/:id.

Question is are they expecting a GET call or POST call. Most probably a GET call. But suppose integet pass to the method getAnimalNameById is "45678". How are we to formulate the URL.

Is it Option 1> replace id with value i.e https://th-apex-http-callout.herokuapp.com/animals/:45678
Option 2> pass using equal sign i.e https://th-apex-http-callout.herokuapp.com/animals/:id=45678.

Regardless i am getting the following response {"animal": {"id": 0,"name": "","eats": "","says": ""}}. I want some test data to verify the code is working does any body has that
Here my requirement is how to use the  
public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
        }
in my test class
my test class is following here
@istest(seeAllData = true)
public class allPatntsRcrdsCtrlr_Test
{
    public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
        }
   public static testmethod void test()
   {
      test.startTest();
     //inserting a record into the Account object
     Account acc = new Account();
     acc.Name = 'Sample Account';
     insert acc;
     
     //Inserting a Record into contact object
     Contact c = new Contact();
     c.Accountid = acc.id;
     c.Department = 'Testing';
     c.LastName = 'Test';
     insert c;
     
     //inserting a record into the Paitent object
     Patient__c pt = new Patient__c();
     pt.BlueStarID__c = 'fdsrt1224565';
     pt.Name = 'Sample'; 
     pt.Patient_First_Name__c = 'Test'; 
     pt.Patient_Id__c= 'sder45789'; 
     pt.Patient_Last_Name__c='Sample1'; 
     pt.ExternalID__c= 'sader22244578'; 
     pt.ProviderName__c= ''; 
     pt.SRType__c= 'Yes'; 
     pt.SampleCode__c= 'No'; 
     pt.ServiceRequestID__c= 12456789; 
     pt.UserID__c= 2456789;
     insert pt;
     //calling a pagereference in testclass
     PageReference pg = page.allPatientRecords;
     pg.getparameters().put('id',string.valueOf(pt.id));
     test.setcurrentpage(pg); 
     
     //calling the controller name
     allPatntsRcrdsCtrlr aprc = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc.strBody = 'Plain';
     aprc.idv = 'Test';
     aprc.searchVal = '';
     aprc.searchFields = 'ProviderName';
     aprc.labeling = 'ProviderName';
     aprc.show = false;
     aprc.lstrecdstb1 = false;
     aprc.queryflds = true;
     aprc.pdfrendered = false;
     aprc.showmessage = true;
     aprc.wordRendered = true;
     aprc.xlRendered  = true;
     //calling methods in testcalss
     
      allPatntsRcrdsCtrlr aprc1 = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc1.strBody = 'Rectangle';
     aprc1.idv = 'Test';
     aprc1.searchVal = '';
     aprc1.searchFields = 'BlueStarID';
     aprc1.labeling = 'BlueStarID';
     aprc1.show = false;
     
     aprc1.lstrecdstb1 = false;
     aprc1.queryflds = true;
     aprc1.pdfrendered = false;
     aprc1.showmessage = true;
     aprc1.wordRendered = true;
     aprc1.xlRendered  = true;
     
     allPatntsRcrdsCtrlr aprc2 = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc2.strBody = 'Square';
     aprc2.idv = 'Test';
     aprc2.searchVal = 'Test';
     aprc2.searchFields = 'Patient_First_Name__c';
     aprc2.labeling = 'Patient_First_Name__c';
     aprc2.show = false;
     /*
     aprc2.lstrecdstb1 = false;
     aprc2.queryflds = true;
     aprc2.pdfrendered = true;
     aprc2.showmessage = true;
     aprc2.wordRendered = true;
     aprc2.xlRendered  = true;
     */
     allPatntsRcrdsCtrlr aprc3 = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc3.strBody = 'square';
     aprc3.idv = 'Test';
     aprc3.searchVal = 'Sample1';
     aprc3.searchFields = 'Patient_Last_Name__c';
     aprc3.labeling = 'Patient_Last_Name__c';
     aprc3.show = false;
     
     aprc3.lstrecdstb1 = false;
     aprc3.queryflds = true;
     aprc3.pdfrendered = false;
     aprc3.showmessage = true;
     aprc3.wordRendered = true;
     aprc3.xlRendered  = true;
     
     
     aprc.clear();
     //aprc.patinfo();
     //aprc.PatientData();
     aprc.retrieve();
     
     //aprc.doSearch();
     //aprc.ExpXL();
    
     aprc.ExpPDF();
     aprc.ExpWord();
     aprc.getlabeling();
     aprc.getsearchFields();
     
      allPatntsRcrdsCtrlr.oAuthRecords ar = new allPatntsRcrdsCtrlr.oAuthRecords();
          ar.BlueStarID = '';
          ar.HubCode    = 'asd145789jjhgdrt';
          ar.PatientName = 'Pointing';
          ar.PatientFirstName = 'John';
          ar.PatientID   = 'serer45789dfh';
          ar.PatientLastName = 'Ricky';
          ar.ProviderName   = '';
          
          ar.SRType = 'Active';
          ar.SampleCode = 'Yes';
          ar.ExternalID = '1245gggtder214578';
          ar.ServiceRequestID = 20001457;
          ar.UserID  = 457896321;
      allPatntsRcrdsCtrlr.JSON2Apex ja = new allPatntsRcrdsCtrlr.JSON2Apex();
      ja.access_token = 'hfert45778969jhgt';
     List<Apexpages.Message> pageMessages = ApexPages.getMessages();
     test.stopTest();
   }
}