Test Custom APIs
In Oracle Mobile Hub you can test your custom APIs before they are deployed by using mock data. You can also test your REST connectors using the test page that supports two modes: Standard testing, and Advanced testing.
Test API Endpoints Using Mock Data
You can provide mock data in your request and response message bodies during the design phase of your API configuration. This lets you examine the context of each call without having to use real-time data or interact with a real-time service. For example, to test whether your code correctly handles an invalid ID, you can add an example in your request body with mock data that contains an invalid ID. When you finish the test, you can replace the example with other code to test some other aspect of the method.
contact
resource in the FixItFast example:{
"id": 20934,
"title": "Lynn's Leaking Water Heater",
"contact": {
"name": "Lynn Adams",
"street": "45 O'Connor Street",
"city": "Ottawa",
"postalcode": "ala1a1"
"username":"johneta"
}
"status": "new",
"driveTime": 30,
"priority": "high",
"createdon": "2015-04-23 18:12:03 EDT"
}
When you create a custom API, a mock implementation is created automatically. The mock implementation lets you invoke the API from your mobile application before you implement the custom code. This lets you develop and test the mobile applications and the custom code simultaneously. If you’re satisfied with the configuration, you can add a real implementation.
Until you create your first implementation, the default implementation is the mock implementation. After you create a real implementation, it becomes the default implementation for the API.
Click the Implementations navigation link to upload an implementation or to see any existing implementations. You can change the default implementation on the Implementations page. After you upload an implementation, you see a list of existing implementations, which includes the mock implementation.
Test the REST Connector API
Now that you've defined your REST Connector API and saved the configuration, you'll want to verify that you’re able to send a request and receive the expected results from the web service. Testing a connection is an optional step but can save you time by identifying and fixing problems now before you finalize the connector API. The Test page lets you test one endpoint at a time.
If you provided a descriptor, you have two testing modes to choose from:
-
Standard testing
If you provided descriptor metadata, the standard testing mode is displayed in which the request and response bodies are generated from the descriptive metadata and displayed in the Request and Response tabs. All you have to do is select the parameters to test with for GET methods and include any HTTP headers that you want to test with.
-
Advanced testing
You can refine your testing by selecting Testing in Advanced Mode (the test mode you enter if you provided a remote service URL). Without descriptive metadata, you select the method and resource to test, include any HTTP headers you want to include, and manually create the JSON body.