Auto-generating the CaslRestLib-Wc for your test project

By using the CaslRest generator utility (CaslRestBuilder), you can include your own customized WebSphere Commerce REST services into the CaslRest library. Then, you can test your custom REST services by using the CaslRest framework.

Before you begin

Procedure

  1. In your Eclipse-based environment, open the Java perspective.
  2. Update the CaslRestBuilder metadata with your new REST resources.
    1. In the project explorer pane, expand the CaslRestBuilder project.
    2. Click config > generators. Open the RestServicesSupp.json file.
    3. At the top of the restHandlersComponentMap array, add an item for every new REST resource you added.
      The following is a code example of how a line might look:
      {"componentName":"giftcenter", "type":"Wcs", "restType":"Bod", "handlers":[{"name":"UserContext"}]},
    4. For the component name, replace the giftcenter with the name that you want to refer your resource to in Java. This is generally a camel case version of the name, starting with a lowercase letter, and without any underscores.
      For example, the resource "my_resource" in Swagger would become "myResource". The name is arbitrary, so you can use what you want.
    5. For the handlers list, replace the UserContext with what the resource is called in the Swagger documentation.
      Note: You must make it camel case and remove any underscores, using an uppercase for the first letter.
      For example, the same "my_resource" resource would be "MyResource" for the handler name.
    6. Putting it all together in an example, a Swagger resource called "my_resource" would look like the following line of code:
      {"componentName":"MyResource", "type":"Wcs", "restType":"Bod", "handlers":[{"name":"MyResource"}]},
    7. Repeat these steps for every one new REST resource.
  3. Run the generator utility against your WebSphere Commerce Server.
    1. In the project explorer pane, expand the CaslRestBuilder project.
    2. Right-click on CaslRestBuilder project, click Run as > Run Configurations.
    3. In the left pane, scroll up, and click Java Applications.
    4. From the top pane, click the New Launch icon.
      A new run configuration is created for the generator.
    5. From the Main tab, click Search... for the Main class.
    6. Search for WebServicesApiParser, click the result, then click OK.
    7. Click Augments.
    8. Enter the program augments, replacing WC_HOST with your host name:
      -wcHost WC_HOST --refresh-wc-lib --create-project -outputDir ../CaslRestLib-Wc -product wc
  4. Click Run.
    Wait for the execution to complete.
  5. Refresh the CaslRestLib-Wc project to synchronize the changes in your development environment.