<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Testing Event-driven Applications with Automatically Generated Events</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Maximilian V¨olker</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Sankalita Mandal</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marcin Hewelt</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Hasso Plattner Institute at the University of Potsdam</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>To make use of the abundance of events produced by smart devices, social media, or the internet-of-things (IoT), implemented business processes need to integrate external events. Thus, processes are event-driven applications that need to be tested correspondingly. However, testing with real-world events is hard, because those events cannot be controlled. Therefore, we suggest to use generated events for testing and implement an event generator component and demonstrate our approach using an use case from the IoT domain. This demo is aimed at practitioners and academics working with event-driven applications.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>
        In today’s interconnected world more and more events are produced by smart
devices, sensors, in social media, via APIs, and IoT, that companies need to
take into account [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Event-driven application development is a paradigm of
software development, which bases its application logic on reacting to received
events [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Implemented business processes that are aware of and connected to
external event sources can be viewed as event-driven applications, because cases
are started when events occur, activities are aborted and so on.
      </p>
      <p>
        Testing is an essential part of software development ensuring that the software
operates as expected and no bugs are introduced during coding (regression testing).
In case of business processes running in a process engine we need to make sure
that new cases are started correctly, event-based gateways and intermediate
events work as expected, and that exception handling through boundary events
functions. When high-level events are employed [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], the aggregation of event
patterns needs to be tested as well.
      </p>
      <p>However, accessing real-world events for testing is problematic for several
reasons: a) the time when they occur and their content is hard to control, b)
exceptional events occur seldom or not at all during the test phase, c) sometimes
there is not enough event data available, and d) it can be costly to connect
to some event sources. To mitigate this problem of testability of event-driven
business processes, we suggest to automatically generate events, thus providing
a mock event stream for testing. Therefore, we extended our event processing
platform Unicorn1 with Event Generator, which is configurable and generates
events with random attribute values taken from various ranges and distributions.</p>
      <sec id="sec-1-1">
        <title>1 https://bpt.hpi.uni-potsdam.de/UNICORN</title>
        <p>We demonstrate our testing approach using a use case from the IoT domain.
The use case is implemented as a business process running in the Chimera engine2,
which is connected to Unicorn, listening for events.
2</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>Events in Business Processes</title>
      <p>
        Background. Business process management is the key for organizations to model,
execute, monitor and continuously improve their processes [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. A business process
is a sequence of activities collectively realizing a specific business goal. One process
can be used as the blueprint for several process instances. The de-facto standard
for modeling the processes is Business Process Model and Notation (BPMN
2.0) [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Besides activities and gateways, a process model contains constructs
to model events, which are either consumed (catching events) or produced
(throwing events) during process execution. Catching events are essentially the
environmental occurrences relevant for a process [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Depending on its usage, a
catching event can trigger a process (start event), initiate an exceptional path
(boundary event) or determine the branch to execute (event-based gateway).
      </p>
      <p>
        The catching events needed for process execution can be produced by other
processes or they can be generated from external sources [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Events can be atomic
or simple which does not take any time to occur, e.g., a sensor update. On the
other hand, complex events are the higher-level events produced by aggregating
the simple events, e.g., a traffic congestion which is lying ahead of a truck. Using
complex event processing (CEP) techniques different operations can be performed
on event streams from single or multiple sources [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. A CEP platform is able to
connect to multiple event sources, parse the events generated in different formats
and aggregate them based on some pre-defined rules [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Event consumers such
as process engines can subscribe to a CEP platform for certain events. Once
matching events occur, the subscribers are notified about it.
      </p>
      <p>Use Case Description. The use case shown in Figure 1 is taken from our project
partner who are involved in producing smart heating systems for home usage.</p>
      <p>After the heating system is installed, it is monitored for three months. If
there is no error report in these three months then the product is considered</p>
      <sec id="sec-2-1">
        <title>2 https://bptlab.github.io/chimera</title>
        <p>as tested in real scenario and product details are archived. In case there is an
error message, the error code is investigated and corresponding departments are
contacted to take action. The timer event and error event are shown as BPMN
boundary events. At occurrence, each of them interrupts the activity Monitor
Product and leads the process execution to the following exceptional path.</p>
        <p>Now, there can be two kinds of error reports, namely, Warning and Error and
either the maintenance department or the manufacturer is contacted respectively
as reaction to the event. Under the hood, the CEP platform collects the sensor
data sent by the heating systems and the complaints reported by the customers
in the product feedback website and aggregates them to produce the error reports.
For example, one rule for generating a Warning can be to receive more than
three technical failures within a week, whereas an Error might be produced if the
actual temperature differs from the temperature setting specified. Since we do
not expect the error reports to occur in real life but still want to make sure that
in case it happens the needed action is taken, we need to simulate the situation.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Event Generator</title>
      <p>The event generator is implemented as an extension of the event-processing
platform Unicorn. As Unicorn manages the structure of event types it processes,
the event generator can use the existing event information from Unicorn and
enrich the real-world event stream with artificial events.</p>
      <p>Architecture. The event generator in Unicorn is split into three components: a
handler for user input, a manager for attribute dependencies within event types
and the core logic of the event generator. The user input handler has data type
specific implementations, like String or Integer. It defines available computation
methods, validates input and generates attribute values based on user’s input and
the chosen method (see Features below). The dependency manager component is
responsible for managing dependencies between two attributes of an event type,
e.g. the error description depends on the error code. The event generator core
connects the other two components.</p>
      <p>For generating artificial testing events, the user first selects the event type and
number of events to generate. For each attribute of the selected event type possible
values can be specified to choose from during generation. Behind each attribute
an user input handler is defined. After submitting the form, these are passed to
the event generator. The event generator retrieves the values computed by the
handlers and combines them into new events, complying with the dependencies
configured for the event type. After a set of artificial events is created, they are
passed to the event replayer, an existing component of Unicorn. Considering
the events’ timestamps, it inserts the events into the event stream processed by
Unicorn. Therefore the artificial events do not need to be inserted all at once but
can be replayed like a real stream of events.</p>
      <p>Features. The current implementation allows to specify value ranges and
computation methods for each attribute separately (see Figure 2). Following the
implementation of Unicorn, the data types String, Integer, Float and Date are supported
and currently, values for all of them can be generated using uniform distribution.
Additionally, normally
distributed Float and Integer
attribute values can be
produced. To provide a fast
generation of test events, default
values are defined for each
data type. For more
realistic events, dependencies
between attributes can be
configured. They define that the
value of one attribute
depends on the value of
another attribute, in our use
case for example, the id of
an error can be connected
to a corresponding error
message. For example, error id
102 is mapped to error
mesGenerate events sage “No water”, while error
Export values ids 103-110 are mapped to
“generic error”. When
generating events, the
dependencies are evaluated and when
Fig. 2. Event generator interface a mapping rule matches the
value of the dependent
attribute is set accordingly. Finally, the event generator allows to export and
import its settings, which eases reuse and sharing, especially when working with
many attributes and dependencies or in a team.</p>
      <p>Discussion. The presented implementation is stable, tested and provides basic
features required for testing event-driven processes. We plan to further extend the
event generator to support various types of distributions, especially user-defined
distributions and configurable default values for event types. At the moment the
default values are defined globally independent of the event type. This might be
sufficient to generate events with a given structure but the default values are
seldom meaningful. Therefore configurable default values for each event type will
open the possibility to generate events fast without user input and with events
containing common values for the domain. To test or simulate certain scenarios a
normal or uniform distribution of values might not be enough, e.g., if 80% of the
events need to have normal values and 20% should be faulty, then this is only
possible if the user can define the probability of values manually.</p>
      <p>To use the event generator for test cases, the event set should not differ for
each execution. Here, the generator can be combined with the event replayer
again: by saving the event generator’s output, the same set of events can be
reused as needed by passing it to the event replayer. Now the tester can be
certain that the occurred events are the same as the last test execution and the
test result only depends on the code.</p>
      <p>
        The generated events are then aggregated based on pre-defined rules to create
higher-level events. The Chimera engine gets notification about these higher-level
or business events and reacts on them as prescribed in the model [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
4
      </p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion and Future Work</title>
      <p>The work focuses on the lack of events to test event-driven applications and
develops an event generator to address the problem. The event generator
component together with the event replayer increases the testability of event-driven
applications, and especially business processes relying on external events.</p>
      <p>However, event generation and replay is only a part of a testing framework
for event-driven business processes. Additionally, service calls, manual tasks, user
input and decisions, among others need to be tested. Also, as the generated events
are decoupled from their original event sources, it is necessary to test the correct
receiving and decoding of events from these sources separately. An integrated
testing framework for event-driven processes is left for future work. Furthermore,
we aim to make generated events more realistic by analyzing historical event
data and learning their distributions.</p>
      <p>The event generator is a mature and tested component of the Unicorn event
processing platform, available since release 1.6. The screencast is available at
https://bpt.hpi.uni-potsdam.de/UNICORN/EventGenerator.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Greengard</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>The internet of things</article-title>
          . MIT Press (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Hinze</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Buchmann</surname>
            ,
            <given-names>A.P.</given-names>
          </string-name>
          :
          <article-title>Principles and applications of distributed event-based systems</article-title>
          . Hershey,
          <source>PA : Information Science Reference</source>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Barros</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Decker</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grosskopf</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Complex events in business processes</article-title>
          .
          <source>In: Business Information Systems</source>
          , Springer (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Weske</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Business Process Management - Concepts</surname>
          </string-name>
          ,
          <source>Languages, Architectures, 2nd Edition</source>
          . Springer (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5. OMG:
          <article-title>Business Process Model and Notation (BPMN), Version 2</article-title>
          .0. http://www. omg.org/spec/BPMN/2.0/ (
          <year>January 2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Etzion</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Niblett</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          : Event Processing in Action. Manning
          <string-name>
            <surname>Publications</surname>
          </string-name>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Luckham</surname>
            ,
            <given-names>D.C.</given-names>
          </string-name>
          :
          <article-title>The Power of Events: An Introduction to Complex Event Processing in Distributed Enterprise Systems</article-title>
          . Addison-Wesley (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Herzberg</surname>
          </string-name>
          , N.,
          <string-name>
            <surname>Meyer</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weske</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>An event processing platform for business process management</article-title>
          .
          <source>In: EDOC</source>
          , IEEE (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Beyer</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kuhn</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hewelt</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mandal</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Weske</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Unicorn meets Chimera: Integrating External Events into Case Management</article-title>
          . In: BPM Demo Session, CEURWS.org (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>