Skip to Content

Test the Extended Incident Management Application with the Business Partner API

Learn how to test the extended Incident Management application with a local mock server.
You will learn
  • How to increase your development speed by running and testing your implementation in a local environment.
  • How to set up and use a local mock server for running your development tests for the extended Incident Management application.
slavipandeSvetoslav PandelievAugust 27, 2025
Created by
slavipande
June 17, 2024
Contributors
slavipande

Prerequisites

This tutorial follows the guidance provided in the SAP BTP Developer’s Guide.

  • Step 1

    Since you already have a SQLite in-memory database that was automatically created in the previous step, let’s now fill it in with some test data.

    1. Navigate to the Incident Management application project and create a new folder data in the srv/external folder.

    2. In the data folder, create a new file API_BUSINESS_PARTNER-A_BusinessPartner.csv and add the following data to it:

      csv
      Copy
      BusinessPartner;FirstName;LastName;BusinessPartnerName;BusinessPartnerIsBlocked;
      1004155;Daniel;Watts;Daniel Watts;false
      1004161;Stormy;Weathers;Stormy Weathers;false
      1004100;Sunny;Sunshine;Sunny Sunshine;true
      
    3. In the data folder, create a new file API_BUSINESS_PARTNER-A_BusinessPartnerAddress.csv and add the following data to it:

      csv
      Copy
      BusinessPartner;AddressID;
      1004155;123
      1004161;345
      1004100;456
      
    4. In the data folder, create a new file API_BUSINESS_PARTNER-A_AddressEmailAddress.csv and add the following data to it:

      csv
      Copy
      AddressID;EmailAddress;Person;OrdinalNumber
      123;test@demo.com;Williams;123
      345;testjohn@demo.com;Smith;222
      456;testhencry@demo.com;johnson;333
      
    5. In the data folder, create a new file API_BUSINESS_PARTNER-A_AddressPhoneNumber.csv and add the following data to it:

      csv
      Copy
      AddressID;PhoneNumber;Person;OrdinalNumber
      123;+44-555-123;Daniel;123
      345;+01-555-688;Stormy;222
      456;+01-555-789;Sunny;333
      
  • Step 2
    1. Install dependencies.

      bash
      Copy
      npm i
      
    2. Run the mock server locally.

      bash
      Copy
      cds mock API_BUSINESS_PARTNER
      
    3. In the terminal, you see the following output:

      cds
      Copy
      [cds] - connect using bindings from: { registry: '~/.cds-services.json' }
      [cds] - connect to db > sqlite { url: ':memory:' }
         > init from db/data/sap.capire.incidents-Urgency.csv 
         > init from db/data/sap.capire.incidents-Status.csv 
         > init from db/data/sap.capire.incidents-Incidents.csv 
         > init from db/data/sap.capire.incidents-Customers.csv 
         > init from db/data/sap.capire.incidents-Conversations.csv 
         > init from srv/external/data/API_BUSINESS_PARTNER-A_BusinessPartnerAddress.csv 
         > init from srv/external/data/API_BUSINESS_PARTNER-A_BusinessPartner.csv 
         > init from srv/external/data/API_BUSINESS_PARTNER-A_AddressPhoneNumber.csv 
         > init from srv/external/data/API_BUSINESS_PARTNER-A_AddressEmailAddress.csv  
      

      If the API_BUSINESS_PARTNER doesn’t show up, remove the .cds-services.json file that resides in the user root folder, for example, /home/user/.cds-services.json.

    4. Open a new terminal and run cds watch. This command starts the application connected to the running mock server.

    5. Open a browser and open the server URL: http://localhost:4004.

    6. Choose /launchpage.html under Web Applications.

      CAP index page

      /launchpage.html uses a local launchpage, while /incidents/webapp/index.html uses the index.html from ui5 app.

    7. Choose the Incident Management tile.

      Incident Management tile on the launchpage
    8. When you’re prompted to authenticate, use the following credentials:

      • Username: alice
      • Password: Empty / No Password
      Log in

      You find the user settings in the .cdsrc.json file.

    9. Choose Create to start creating a new incident.

      Create a new incident
    10. Open the value help for the Customer field.

      Value help for Customer field
    11. Verify that customer data is fetched from the mock server.

      Data in value help

      To test the scenario, the value help for customers loads data from the mock server while creating a new incident.

    By using a local mock server, you can easily test your implementation in a local environment. Find more details at Local Mocking in the CAP documentation.

    Which command starts the mock server locally?

Back to top