Testing AppClient APIs
Appery.io provides a special AppClient Test Page, where you can try and test AppClient with your API Express services directly outside the mobile app. The page acts as an AppClient dashboard, where you can find the current AppClient state, cached data, offline actions that wait for synchronization, etc. Also, there are control panels that allow running the initialization process, changing AppClient state, and performing various operations with your API Express services.
This page can be useful, if you want to understand the AppClient workflow better, so, this is like the AppClient sandbox for manual testing. You can find more details about how to use AppClient Test Page in the following section.
AppClient Test Page
It’s just a visual representation of the AppClient API, so every button simply triggers certain AppClient functions.
For the test purposes, create a collection label with fields: label (String) and deleted (Boolean) in the Appery.io database:
or table label in a relational database (in the example below the SQL code of MySQL database):
CREATE TABLE label ( id int PRIMARY KEY NOT NULL, name varchar(45), deleted bit, modified DATETIME ON UPDATE CURRENT_TIMESTAMP )
Create a test project and create generated services label:
and empty custom service test:
Here you can specify basic settings and initialize AppClient:
- Type appery.io for Server.
- Copy the APIKey from API Express > Settings.
- Click Initialize to try to connect. If successful, you’ll see the models to choose from, and if something is wrong, the error message will be shown.
- If you check Allow only authenticated users to call REST under the API Express > Settings you should authenticate to perform actions. Type the credentials and click Login. If something is wrong, you will see the error.
SDK State Methods
- By using the SDK State Methods block, you can simulate the offline mode. All changes that were made in the offline mode will be shown in the bottom-left block.
- If you didn’t specify to use mandatory authentication, synchronization will be performed once Go online is clicked.
- Otherwise, synchronization should be started manually after going online by clicking Retry sync.
- Reset failed sync state will reset the synchronization failed state – in other words, all operations made offline will never be synchronized.
- Click Find to get the first 100 records from the table.
- You can type search filters in the light-yellow box (marked as WHERE), and clicking Find will return the results based on this filter.
- The Get Count button will simply return the number of records.
- You can retrieve any record by its ID. To do this, type the value of the id parameter in the ENTITY ID box. Click Get by id to test.
- You can delete the entity by id the same way by clicking Delete.
- To create a new record, provide JSON inside the light-green box and click Create (don’t specify id if auto-increment is turned on in your database).
- Specify record id in the ENTITY ID field and parameters to update in the ENTITY CONTENT fields. Click Update to update that record.
- By using the Custom service block, you can invoke custom services just typed the name of the service in the Service path field.
- Type custom/test in the Service path field and press the Invoke button.
Updated 11 months ago