In this section:

This tutorial will walk you through the following DTP Workflow examples and describe how they are used to send email notifications based on DTP Events:

  • DTP Data Collector Error notification email
  • Static Analysis Violation metadata update notification email

The following DTP REST APIs are used in this example:

  • GET /v1/staticAnalysisViolations/{{event.message.ids.0}}/prioritization/events
  • GET /v1.3/services?relativePath=true

Requirements

  1. DTP and Extension Designer must be configured correctly. See Server Settings.
  2. An SMTP email server must be configured. See SMTP Settings.
  3. DTP should have collected static analysis data from a Parasoft code analysis and test execution tool (i.e., C/C++test, dotTEST, or Jtest). This requirement is so that you have violations metadata to edit. 

Setup

  1. Create a new service in the DTP Workflow category (see Working with Services) and create new flow (see Working with Flows). You can also add a new flow to an existing service. 
  2. Import and deploy the following two flows from the library:
    • Data Collector Error Email
    • Violation Assignment Email

When the Data Collector Error Email flow is imported, it is labeled with the Send an Email when a Report Fails to Processes comment node. When the Violation Assignment Email flow is imported, it is labeled with a Changes to your assigned violations Notification comment node.

Example 1 - DTP Data Collector Error Email Notification

The DTP DataCollector topic notifies subscribers about events created from Data Collector. The topic supports three different events:

  • ReceivedEvent: Event is thrown when Data Collector receives the report and starts to process it.
  • ProcessedEvent: Event is thrown when Data Collector successfully finishes processing the report.
  • ErroredEvent: Event is thrown when Data Collector encounters an error while processing the report.

See Event Topics for more information.

Double-click the DataCollector/ErroredEvent node. This is an Event In node and is used in this example to subscribe to the DataCollector topic and listen for the JMS ErrorEvent event. This DataCollector/ErrorEvent event is triggered when Data Collector notifies subscribers that it has received an error and won't be able to process reported test results. 

The node forwards payload data to the msg.event, which contains detailed information about the event.

Double-click the Prepare email body node. This is a Template node and it provides an easy way to create an email body template. In this example, the email body includes the data received from the event.  

The Info tab contains details on how to configure this node. Choose View> Show Sidebar from the menu.  

You can add a Debug node after the Event node to see the payload from the event.

This allows you to capture the payload and customize the template as needed.

Double-click the Send Email to Team Lead node. This is an Email node used in this example to set up the recipient email address and subject of the email. 

With successful email transmission, you will get non-error response at the end.

Example 2 - Static Analysis Violation metadata update notification email

This example flow only applies to the static analysis violations metadata update event. Although developers can download static analysis changes to their IDEs, DTP does not automatically notify users when there have been changes. This example sends an email notification when the assignee has been changed.

Double-click the AnalysisMetadata/violations node. The node is configured to listen the AnalysisMetadata/violations event and pass the data to a msg.event object.

The event may pass multiple violations, but this flow only handles a single violation. You can configure the flow so that it passes a violation ID to the Get Event Details node one at a time. See How to Update Violation Metadata Tutorial for additional information. 

Double-click the Get Event Details node.This is a DTP REST API node that exposes the undocumented /v1/staticAnalysisViolations/<violationID>/prioritization/events endpoint used in this flow to get the change details.

Double-click the Process Data from DTP function node and review the JavaScript. The node checks the events payload for new assignee values and returns the user name of the new assignee.

 

Double-click the Find Assignee's email address node. This is a Get User node that finds the user's email address from DTP. If the user doesn't have email address, the flow will exit with error at the end. See User Administration.

Double-click the DTP Server Info node. This node retrieves DTP server URL information from Extension Designer (see Server Settings) and retrieves Explorer Views URLs from DTP by calling the /v1.3/services API. 

Double click the Prepare email body node. This Template node contains a simple email body.

The Prepare email body connects to the Send Email node to deliver the email.

  • No labels