<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: hiclab</title>
    <description>The latest articles on DEV Community by hiclab (@hiclab).</description>
    <link>https://dev.to/hiclab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F361235%2F5e7b8dfe-fc68-40bf-80bd-6e3eb7413f1e.jpg</url>
      <title>DEV Community: hiclab</title>
      <link>https://dev.to/hiclab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hiclab"/>
    <language>en</language>
    <item>
      <title>Message Throttling with Apache Camel Master Component</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Sat, 22 Nov 2025 18:00:31 +0000</pubDate>
      <link>https://dev.to/hiclab/message-throttling-with-apache-camel-master-component-166p</link>
      <guid>https://dev.to/hiclab/message-throttling-with-apache-camel-master-component-166p</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;When managing events, it's common to encounter a rapid succession of events within a brief period. For instance, within an application driven by events, creating an entity can trigger multiple events like EntityAdded, EntityChanged, SubEntityAdded, etc. However, if the primary objective is to monitor changes in a specific entity item, processing all these events to dispatch a notification or outbound message to downstream systems might be unnecessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Based on the problem described above, we are often interested in only knowing that an update has occurred at a certain moment, rather than communicating every single change. This can be effectively managed within a short predefined timeframe, typically 5 to 10 seconds.&lt;/p&gt;

&lt;p&gt;This pattern is particularly common when dealing with primary business objects. While each change can generate multiple events, downstream systems don’t need to process all updates individually, they only need to know that an object was modified and should fetch the latest state.&lt;/p&gt;

&lt;p&gt;The goal is to inform interested parties that an update has occurred while avoiding unnecessary system load, especially to external systems. One approach is to implement a throttling mechanism leveraging Apache Camel components.&lt;/p&gt;

&lt;p&gt;Apache Camel's Master component provides an elegant solution for implementing this throttling mechanism, especially in clustered environments. The Master component ensures that only one node in a cluster actively consumes from an endpoint, preventing duplicate processing when multiple application instances are running. However, the Master component alone is not sufficient and it requires a transport mechanism that supports distributed messaging. This is where message queue services like Amazon SQS, JMS-compliant brokers (such as ActiveMQ), or other similar messaging platforms or distributed cache systems become essential to enable proper coordination across the cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why SQS Over Direct Component?
&lt;/h2&gt;

&lt;p&gt;While it might be logical to use Camel's direct component for internal routing, this approach has significant limitations in clustered environments. This component only works within a single JVM, making it unsuitable for distributed deployments. When using direct with the Master component, only the elected leader route will work properly while the other routes in other nodes will fail when attempting to consume messages from that endpoint, as the direct endpoint simply doesn't exist in their JVM context.&lt;br&gt;
Using Amazon SQS solves this problem by providing a centralized message store where all cluster nodes can access the same message queue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4610c8k2jnrauattxjpg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4610c8k2jnrauattxjpg.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementation Pattern
&lt;/h2&gt;

&lt;p&gt;Here is how to implement throttling with the Master component and SQS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"master:notification:aws2-sqs://queue-1"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;routeId&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="n"&gt;throttlingRoute&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;aggregate&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;exchangeProperty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;ENTITY_ID_PROPERTY&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;completionTimeout&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;aggregationStrategy&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;UseLatestAggregationStrategy&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;to&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nl"&gt;direct:&lt;/span&gt;&lt;span class="n"&gt;notify&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multiple messages are sent to the SQS queue.&lt;/li&gt;
&lt;li&gt;Those messages arrive at the SQS queue in an interval of a few seconds.&lt;/li&gt;
&lt;li&gt;The Master component ensures only the elected leader route consumes the messages.&lt;/li&gt;
&lt;li&gt;The aggregation strategy discards all but the latest message.&lt;/li&gt;
&lt;li&gt;After the completion timeout is reached, only the latest message proceeds to the notification process.&lt;/li&gt;
&lt;li&gt;If the leader route fails, another route in another node is automatically elected and continues processing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The pattern described above is particularly valuable for status update handlers and any scenario where notifying about one state among various that occurred at almost the same time, or the most recent state, is more important than notifying every intermediate change.&lt;/p&gt;

</description>
      <category>camel</category>
      <category>sqs</category>
      <category>master</category>
      <category>throttling</category>
    </item>
    <item>
      <title>Push vs Pull in Task Assignment</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Fri, 14 Apr 2023 09:35:27 +0000</pubDate>
      <link>https://dev.to/hiclab/push-vs-pull-in-task-assignment-lfg</link>
      <guid>https://dev.to/hiclab/push-vs-pull-in-task-assignment-lfg</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ned_okst--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bqeceaxmgnust63hypt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ned_okst--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bqeceaxmgnust63hypt.png" alt="Push vs Pull" width="586" height="233"&gt;&lt;/a&gt;&lt;br&gt;
In this post, we will explore the differences between push and pull approaches in task assignment, the advantages and disadvantages of each approach, and when each approach is most appropriate.&lt;br&gt;
In the push model, an authority figure such as a team lead or manager assigns tasks to individual team members. On the other hand, the pull model is more decentralized and empowers individual team members to take on tasks based on priorities, skills and their own interests. &lt;/p&gt;

&lt;h2&gt;
  
  
  Push Model
&lt;/h2&gt;

&lt;p&gt;In traditional software development methodologies, it is more common to use the push approach to task assignment where tasks are assigned to each team member. This approach is often hierarchical in nature, with a clear chain of command and centralized decision-making.&lt;br&gt;
There are several scenarios in which a task may be assigned, including situations that require specialization, experience, or when it is related to other tasks.&lt;br&gt;
This model has several negative impacts on team dynamics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Team members often tend to focus on their individual assignments over the shared goals of the team. When individuals focus solely on their own work, they may fail to see the bigger picture and miss opportunities for collaboration and collective problem-solving because of communication barriers.&lt;/li&gt;
&lt;li&gt;Team members may become disinterested and demotivated due to the absence of ownership and autonomy. When team members feel they have little control over the project's direction and outcomes, they may feel undervalued and unengaged. This can lead to a decrease in productivity and lower quality work.&lt;/li&gt;
&lt;li&gt;Someone needs to track and optimize each team member's individual queue of work. This is needed to maintain a well balanced distribution of tasks and an appropriate workload.&lt;/li&gt;
&lt;li&gt;Teams may face difficulties when trying to adapt to changing priorities, especially when new tasks with higher priorities are added to the existing workload. When team members are already focused on their assigned tasks and have a queue of work ahead of them, it can be difficult to shift their attention and resources towards the new high-priority tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pull Model
&lt;/h2&gt;

&lt;p&gt;This model is often used in agile methodologies to promote flexibility and collaboration among team members where they proactively select high-priority tasks from the to-do list or backlog. Following this approach, the focus is on working and completing high priority work rather than keeping team members constantly occupied.&lt;br&gt;
This approach has the following benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encouraging self-organizing teams can help optimize task management and allocation. Instead of assigning tasks to individuals, the team collaboratively manages the backlog. This approach not only ensures that tasks are distributed fairly but also creates a culture of open communication and collaboration within the team.&lt;/li&gt;
&lt;li&gt;Team members work on new tasks when they have capacity while ensuring that the existing work is completed. This approach allows team members to be more flexible and responsive to changes in the project scope or priorities. If a new high-priority task arises, team members who have capacity can quickly shift their focus to the new task.&lt;/li&gt;
&lt;li&gt;Each team member manages and takes responsibility for their tasks, including updating task status and relevant information as needed. This promotes a sense of autonomy and responsibility within the team which can lead to greater engagement and job satisfaction.&lt;/li&gt;
&lt;li&gt;The team lead and team members are focused on high value tasks instead of wasting efforts on assigning and monitoring tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While both push and pull models for task assignment have their advantages and disadvantages, the pull model is generally considered the default approach particularly in agile methodologies because it aligns with agile principles. For example, Kanban has one essential principle called Pull System which emphasizes the importance of pulling work from a prioritized backlog based on capacity. However this is not enough without limiting the work in progress (WIP). By limiting the number of tasks in progress, teams can focus on completing high-priority tasks, avoid multitasking and detect bottlenecks.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Check messages in Problems view with RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Tue, 28 Apr 2020 11:51:24 +0000</pubDate>
      <link>https://dev.to/hiclab/check-messages-in-problems-view-with-rcptt-l43</link>
      <guid>https://dev.to/hiclab/check-messages-in-problems-view-with-rcptt-l43</guid>
      <description>&lt;p&gt;When testing with RCPTT, it is common to check messages in Problems view to make sure that only the expected ones are shown. &lt;/p&gt;

&lt;p&gt;The Problems view in Eclipse groups messages by severity but we can also group them by type or other criteria or not at all. In our case, we will use the default grouping that is by severity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---aYUM5Dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5tj656nblx1zjgsu360v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---aYUM5Dg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5tj656nblx1zjgsu360v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Find a message in Problems view
&lt;/h2&gt;

&lt;p&gt;The following procedure basically constructs a path based on a regular expression in this format  &lt;code&gt;$severity "s \(.*item(s?)\)/" $message&lt;/code&gt; and checks whether an item with this path exists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Checks whether the Problems view contains a message with a given severity. */
proc problemExists [val message] [val severity Error] {
    with [get-view Problems | get-tree] {
        if [itemExists [concat $severity "s \\(.*item(s?)\\)/" $message]] {
            bool true
        }
    } | length | gt 0
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Notice that &lt;code&gt;itemExists&lt;/code&gt; is a procedure we created in the past to check whether an item is visible in a tree structure. For more details, see &lt;a href="https://dev.to/hiclab/how-to-check-if-an-item-exists-in-a-tree-or-table-in-rcptt-5d76"&gt;this post&lt;/a&gt;.&lt;br&gt;
The argument &lt;code&gt;Severity &lt;/code&gt; is optional since it has Error as default value. This is because in most cases, we look for error messages.&lt;/p&gt;

&lt;p&gt;Here are some examples of verifications done in Problems view.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// check an error message
problemExists -message "The local variable company may not have been initialized" | verify-true

// error message not expected
problemExists -message "The value of the field Company.name is not used" | verify-false

// check a warning message
problemExists -message "The value of the field Company.name is not used" -severity Warning | verify-true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Count messages in Problems view
&lt;/h2&gt;

&lt;p&gt;Another interesting verification we can do is to count the number of messages that appear in Problems view for a particular severity.&lt;/p&gt;

&lt;p&gt;Similarly to the procedure described above, we first check if an item exists for the provided severity then we go through its child items (messages) to count them. If we want to count the occurrences of a concrete message then we have to iterate over all those messages and consider only matches.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Counts how many times a message with a given severity appears in the Problems view.
If no message is specified then it counts all messages with the specified severity. 
*/
proc problemCount [val severity] [val message ""] {
    let [val severityNode [concat $severity "s \\(.*item(s?)\\)"]] {
        with [get-view Problems | get-tree] {
            if [itemExists $severityNode] {
                with [get-item $severityNode] {
                    expand
                    if [$message | eq ""] {
                        // count all messages of the specified severity
                        get-items | length
                    } -else {
                        // count only the specified message
                        get-items | foreach [val item] {
                            if [$item | get-property text -raw | eq $message] {
                                // message found
                                emit true
                            }
                        } | length
                    }
                }
            } -else {
                // no item is found for the specified severity
                int 0
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Expand&lt;/code&gt; ECL command is necessary to make sure that child items of severity items are visible, otherwise &lt;code&gt;get-items&lt;/code&gt; returns nothing.&lt;/p&gt;

&lt;p&gt;Here are some usage examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;problemCount Error | eq 1 | verify-true

problemCount Warning | eq 2 | verify-true

problemCount Warning "The value of the field Company.name is not used" | eq 1 | verify-true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>problemsview</category>
      <category>markers</category>
    </item>
    <item>
      <title>Help the team to define the sprint goal</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Mon, 27 Apr 2020 13:26:45 +0000</pubDate>
      <link>https://dev.to/hiclab/help-the-team-to-define-the-sprint-goal-2j3l</link>
      <guid>https://dev.to/hiclab/help-the-team-to-define-the-sprint-goal-2j3l</guid>
      <description>&lt;p&gt;We all know that having a good sprint goal is very important for any team, but do we all know how to define it?&lt;/p&gt;

&lt;p&gt;In some cases, the team is not able to define a sprint goal at all because they basically consider it optional or they don’t know how to do it and as result they don’t see how to benefit from it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Working without a sprint goal
&lt;/h2&gt;

&lt;p&gt;I admit that in the past, I worked in different teams who were used to work without a sprint goal. Here are some of the related issues we faced in our daily work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The team is not able to deliver working software at the end of a sprint&lt;/li&gt;
&lt;li&gt;Team members focus separately on their own goals and don’t work toward the same goal&lt;/li&gt;
&lt;li&gt;The team doesn’t focus always on implementing the most important features&lt;/li&gt;
&lt;li&gt;Bottlenecks occur frequently in testing and code review which prevent work from being completed&lt;/li&gt;
&lt;li&gt;Lack of collaboration between team members&lt;/li&gt;
&lt;li&gt;Team members remain specialized in a particular area of product&lt;/li&gt;
&lt;li&gt;The daily meeting becomes a simple status report&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bad sprint goal
&lt;/h2&gt;

&lt;p&gt;In one occasion we tried to define a sprint goal to tackle some of the problems mentioned above but we failed. At that moment, we thought that we did well but much later we discovered that we defined a bad goal. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complete user stories A and B&lt;/li&gt;
&lt;li&gt;Fix high-priority bugs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you have noticed, those goals do not describe any special purpose for the sprint; they are generic and encourage the team to focus on completing tasks instead of delivering value to customers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good sprint goal?
&lt;/h2&gt;

&lt;p&gt;With a good sprint goal, we enforce the importance of having a real objective that is aligned with customer expectations.  Now the question is, how do we actually define a good sprint goal?&lt;/p&gt;

</description>
      <category>scrum</category>
      <category>sprint</category>
      <category>goal</category>
      <category>issues</category>
    </item>
    <item>
      <title>Create a custom report for RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Sun, 26 Apr 2020 12:13:52 +0000</pubDate>
      <link>https://dev.to/hiclab/create-a-custom-report-for-rcptt-m6g</link>
      <guid>https://dev.to/hiclab/create-a-custom-report-for-rcptt-m6g</guid>
      <description>&lt;p&gt;RCPTT &lt;a href="https://www.eclipse.org/rcptt/"&gt;(RCP Testing Tool)&lt;/a&gt; includes a functionality that allows to generate reports in multiple formats based on the results obtained from executing test cases. However, the default reports might be insufficient for our needs but fortunately; RCPTT is flexible because it supports generating custom reports.&lt;/p&gt;

&lt;p&gt;In this post, we illustrate the basic steps needed to create a custom report renderer so it can be used in RCPTT whether IDE or Test Runner. We use Maven to configure and build the plugin and other related artifacts. By the way, we use a specific project to build an update site for our plugin.&lt;/p&gt;

&lt;p&gt;The full code is available at the following repository &lt;a href="https://github.com/hichlab/rcptt-reporting"&gt;rcptt-reporting&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a report renderer
&lt;/h2&gt;

&lt;p&gt;RCPTT provides the interface &lt;code&gt; IReportRenderer&lt;/code&gt; which is the entry point for report generation. Renderers implementing this interface receive a &lt;code&gt;Report&lt;/code&gt; iterable object to iterate over all internal reports generated for a given test execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;XMLCustomReportRenderer&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;IReportRenderer&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;IStatus&lt;/span&gt; &lt;span class="nf"&gt;generateReport&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IContentFactory&lt;/span&gt; &lt;span class="n"&gt;factory&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;reportName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Iterable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Report&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;reports&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

        &lt;span class="c1"&gt;// iterate over reports, process their information and create a file in your preferred format ...&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Status&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;OK_STATUS&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="nf"&gt;getGeneratedFileNames&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;reportName&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="n"&gt;reportName&lt;/span&gt; &lt;span class="o"&gt;};&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To access to the results of executed tests, we have to iterate over a collection of &lt;code&gt;Report&lt;/code&gt; objects and retrieve the information as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Iterator&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Report&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;reportIterator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reports&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;iterator&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reportIterator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasNext&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Report&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reportIterator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;next&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;Node&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRoot&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;Q7Info&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Q7Info&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getProperties&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IQ7ReportConstants&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ROOT&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Q7Info object contains the information of an executed test case&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Add an extension
&lt;/h2&gt;

&lt;p&gt;Once the report renderer is implemented, we have to add an extension for this plugin to be able to use it. The following entry must be added to plugin.xml.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;extension&lt;/span&gt; &lt;span class="na"&gt;point=&lt;/span&gt;&lt;span class="s"&gt;"org.eclipse.rcptt.reporting.reportRenderer"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;reportRenderer&lt;/span&gt;
        &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"com.hiclab.rcptt.reporting.XMLCustomReportRenderer"&lt;/span&gt;
        &lt;span class="na"&gt;description=&lt;/span&gt;&lt;span class="s"&gt;"XML Custom Report Renderer"&lt;/span&gt;
        &lt;span class="na"&gt;extension=&lt;/span&gt;&lt;span class="s"&gt;"xml"&lt;/span&gt;
        &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"XmlReport"&lt;/span&gt;
        &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Xml Custom Report"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/reportRenderer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/extension&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;id&lt;/code&gt; is needed especially when using Test Runner. For more details, check the description of the argument &lt;em&gt;report&lt;/em&gt; in &lt;a href="https://www.eclipse.org/rcptt/documentation/userguide/runner/arguments/"&gt;Test Runner documentation&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>custom</category>
      <category>report</category>
    </item>
    <item>
      <title>Zero Bug Policy, is it really worth it?</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Tue, 14 Apr 2020 08:37:57 +0000</pubDate>
      <link>https://dev.to/hiclab/zero-bug-policy-is-it-really-worth-it-346e</link>
      <guid>https://dev.to/hiclab/zero-bug-policy-is-it-really-worth-it-346e</guid>
      <description>&lt;p&gt;Years ago, I was on a project where the number of bugs was considerably growing day after day. This situation led to a poor backlog management because we had to spend a lot of effort to triage and prioritize hundred of bugs every few weeks, almost all them remained in the backlog for several months. As you have probably experienced, bugs tend to become obsolete as time passes.&lt;/p&gt;

&lt;p&gt;As a team, we were aware that most of reported bugs actually were not real bugs but enhancements and they were completely ignored because the priority was to implement new features and of course fix only critical defects. As you know, customers always want value.&lt;/p&gt;

&lt;p&gt;It took a time to figure out how to solve the problem. I remember that at the first opportunity, I proposed the &lt;em&gt;Zero Bug Policy&lt;/em&gt; based on what I read in articles and books. In my opinion, this was the optimal and effective way to handle the issue but for the team, it sounded a little bit extreme.&lt;/p&gt;

&lt;p&gt;The concept of Zero Bug Policy is very simple. There is basically one rule to follow: any identified bug should be either fixed immediately or rejected. In other words, an issue is either a high priority bug or it is not a bug at all.&lt;/p&gt;

&lt;p&gt;Here are some benefits of applying this rule:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce the effort spent in bug tracking&lt;/li&gt;
&lt;li&gt;Eliminate the need of triage and reprioritization of bugs&lt;/li&gt;
&lt;li&gt;Focus on fixing most relevant issues first&lt;/li&gt;
&lt;li&gt;Keep the backlog as small as possible&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our case, finally we adopted a conservative approach that consisted in fixing as soon as possible any critical bug and leave the others to be fixed later in the near future, as long as they are considered relevant.&lt;br&gt;
This rule contributes considerably to the better management of the backlog. However, an effort was still needed to review the existing bugs since their number could not be reduced to zero or close to zero.&lt;/p&gt;

&lt;p&gt;I was pretty sure that this could be an important step to apply the Zero Bug Policy in the future. &lt;/p&gt;

</description>
      <category>bugs</category>
      <category>zerobugpolicy</category>
      <category>backlog</category>
      <category>agile</category>
    </item>
    <item>
      <title>How to access HTML elements in RCPTT using Javascript</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Sun, 12 Apr 2020 11:01:57 +0000</pubDate>
      <link>https://dev.to/hiclab/how-to-access-html-elements-in-rcptt-using-javascript-2863</link>
      <guid>https://dev.to/hiclab/how-to-access-html-elements-in-rcptt-using-javascript-2863</guid>
      <description>&lt;p&gt;Did you ever have to write an RCPTT test to do some verification in an HTML?&lt;/p&gt;

&lt;p&gt;Suppose that our Eclipse application under test generates HTML files and we want to check that links, buttons, fields and other elements are valid. Here is where Javascript comes to the rescue.&lt;/p&gt;

&lt;p&gt;Javascript provides many functions that can be used to access elements on a web page through the browser. We assume that the page is opened in an internal browser so we can have access to it when testing with rcptt. This can be done using the ECL command &lt;code&gt;invoke&lt;/code&gt; and the Javascript function &lt;code&gt;evaluate&lt;/code&gt; executed on the control object &lt;code&gt;Browser&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accessing object properties
&lt;/h3&gt;

&lt;p&gt;In the following example, we want to check that a given link with its corresponding text exist at least once in a web page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proc linkExists [val href] [val text] {
    let [val script [concat
        "var elements = document.querySelectorAll(\"a[href='" $href "']\");"
        "for (var i = 0; i &amp;lt; elements.length; i++) {"
        "   if (elements[i].innerHTML != '" $text "') {"
        "       return false;"
        "   }"
        "}"
        "return true;"
        ]] {

        $script | log
        get-control Browser | get-object | invoke evaluate $script
    }
}
with [get-editor "Index"] {
    linkExists "/new" "Write a post" | verify-true
    linkExists "/new" "Write a post?" | verify-false
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Performing actions
&lt;/h3&gt;

&lt;p&gt;In this example, we just wanto to simulate a click on a given link identified by its HTML id.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proc clickOnLink [val id] {
    get-control Browser | get-object | invoke evaluate [concat "document.getElementById('" $id "').click()"]
}
get-editor "Index" | clickOnLink "connect-link"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>javascript</category>
      <category>evaluate</category>
    </item>
    <item>
      <title>How to run a Shell command in RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Fri, 10 Apr 2020 10:56:20 +0000</pubDate>
      <link>https://dev.to/hiclab/how-to-run-a-shell-command-in-rcptt-2gn</link>
      <guid>https://dev.to/hiclab/how-to-run-a-shell-command-in-rcptt-2gn</guid>
      <description>&lt;p&gt;There are several reasons to run an external process when writing automated test cases. Those are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unzip files&lt;/li&gt;
&lt;li&gt;Run a script or batch file&lt;/li&gt;
&lt;li&gt;Access to the processes that are running on the system&lt;/li&gt;
&lt;li&gt;Create folders and files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically, to execute a system command, we use &lt;code&gt;exec-process&lt;/code&gt; ECL command provided by RCPTT and pass the required parameters. Once executed, the command provides the following information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exit code&lt;/li&gt;
&lt;li&gt;Stdout&lt;/li&gt;
&lt;li&gt;Stderr&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The executed command depends on the operating system we are using. In our case, it is Windows so we have to pass the command as argument to cmd.exe shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a new folder
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exec-process cmd "/c" md "C:\\temp\\new_folder" -ignoreExitCode –ignoreStderr
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The parameters &lt;code&gt;ignoreExitCode&lt;/code&gt; and &lt;code&gt;ignoreStderr&lt;/code&gt; are added in this case to ignore any failure if for example, there is already a folder with the same name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unzip files
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let [val unzipCmd [concat "\"C:\\Program Files\\7-Zip\\7z\"" " x " "C:\\temp\\output.zip" " -aoa -oC:\\temp\\new_folder"]] {
    exec-process cmd "/c" $unzipCmd
} 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows processes
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// check if a given windows process is running
proc processExists [val name] {
    exec-process cmd "/c" tasklist "/FI" [concat "IMAGENAME eq " $name] | get stdout | invoke contains $name
}
processExists "rcptt.exe" | verify-true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>execprocess</category>
      <category>external</category>
    </item>
    <item>
      <title>Invoke a Java static method from RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Thu, 09 Apr 2020 10:11:34 +0000</pubDate>
      <link>https://dev.to/hiclab/invoke-a-java-static-method-from-rcptt-4b66</link>
      <guid>https://dev.to/hiclab/invoke-a-java-static-method-from-rcptt-4b66</guid>
      <description>&lt;p&gt;It makes no sense to spend lot of time writing complex procedures when we could reuse all the functions available in our application. We don’t want to reinvent the wheel; instead we want to focus on the main goal to test the application.&lt;br&gt;
The &lt;code&gt;invoke-static&lt;/code&gt; ECL command can be used for this purpose, to invoke any static method in a java class. Any class available in the plugins provided by the application under test can be used depending on argument types.&lt;br&gt;
Here are some situations where we can save time reusing utility functions provided by Java SE or Apache Commons.&lt;/p&gt;
&lt;h3&gt;
  
  
  Apache Commons &lt;em&gt;StringUtils&lt;/em&gt;
&lt;/h3&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
Returns true if the specified value is numeric.
*/
proc isNumeric [val value] {
    invoke-static -pluginId "org.apache.commons.lang3" -className "org.apache.commons.lang3.StringUtils" 
        -methodName isNumeric -args [str $value]
}

/*
Reverses a string.
*/
proc reverse [val string] {
    invoke-static -pluginId "org.apache.commons.lang3" -className "org.apache.commons.lang3.StringUtils" 
        -methodName reverse -args $string
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Some verifications&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;isNumeric "abc" | verify-false
isNumeric "123" | verify-true

reverse "abc" | equals "cba" | verify-true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Apache Commons &lt;em&gt;FileUtils&lt;/em&gt;
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// get the user directory path
invoke-static -pluginId "org.apache.commons.io" -className "org.apache.commons.io.FileUtils" 
        -methodName getUserDirectoryPath | log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Java &lt;em&gt;System&lt;/em&gt;
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// get the value of a environment variable
invoke-static -pluginId "org.eclipse.rcptt.ecl.core" -className "java.lang.System" 
    -methodName getenv -args "JAVA_HOME" | log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>invokestatic</category>
      <category>java</category>
    </item>
    <item>
      <title>How to check if an item exists in a tree or table in RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Wed, 08 Apr 2020 10:29:11 +0000</pubDate>
      <link>https://dev.to/hiclab/how-to-check-if-an-item-exists-in-a-tree-or-table-in-rcptt-5d76</link>
      <guid>https://dev.to/hiclab/how-to-check-if-an-item-exists-in-a-tree-or-table-in-rcptt-5d76</guid>
      <description>&lt;p&gt;When working with trees and tables, have you ever faced a case where you want to check whether a given item is visible?&lt;/p&gt;

&lt;p&gt;In RCPTT, an item is obtained using the &lt;code&gt;get-item&lt;/code&gt; ECL command. If you try to get an item that does not exist then an error is returned saying that the item could not be found and the test case fails immediately.&lt;/p&gt;

&lt;p&gt;In general, invoking &lt;code&gt;get-item&lt;/code&gt; can be enough to verify that an given item exists but what to do if we want to continue the execution of the test case to perform other verifications even if the item does not exist.&lt;/p&gt;

&lt;p&gt;We create a procedure to handle the case where an item is not found so the error can be captured using &lt;code&gt;try&lt;/code&gt; and &lt;code&gt;catch&lt;/code&gt; commands as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proc itemExists [val parent -input] [val path] {
    try {
        $parent | get-item $path
        bool true
    } -catch {
        bool false
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see, it is simple and lets us have control over the execution of any command that can fail. In this case, the procedure returns true if the item exists or false if an error occurs when getting the item.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example of general usage
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get-preferences-menu | click
with [get-window Preferences] {
    get-tree | itemExists Help | verify-true
    get-tree | itemExists HelpNotFound | verify-false
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Example of specific usage with conditions
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if [itemExists Help] {
    // item is found, do more verifications
} -else {
    // item is not found, do more verifications if you want
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>item</category>
      <category>tree</category>
    </item>
    <item>
      <title>Check if a list contains a value in RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Tue, 07 Apr 2020 10:54:25 +0000</pubDate>
      <link>https://dev.to/hiclab/check-if-a-list-contains-a-value-in-rcptt-3h7b</link>
      <guid>https://dev.to/hiclab/check-if-a-list-contains-a-value-in-rcptt-3h7b</guid>
      <description>&lt;p&gt;This post will focus on how to iterate over a list to check whether it contains a given element.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using &lt;em&gt;each&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;The ECL command &lt;code&gt;each&lt;/code&gt; is the one of most used commands in RCPTT. It is very useful because it makes the code clean, simple and much more readable in comparison with the command &lt;code&gt;loop&lt;/code&gt;. However, we have to take into account that it doesn’t support breaks. That is, we are forced to go through all elements of the list even if it is not necessary, for example when we have found the target element before reaching the end of the list.&lt;/p&gt;

&lt;p&gt;In the following example, we return a value if the list contains the specified element. Afterwards, we check whether the number of returned values is greater than 0 in order to return true or false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proc itemExists [val items -input] [val targetItem] {
    $items | each [val it] {
        if [$it | eq $targetItem] {
            bool true
        }
    } | length | gt 0
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Using &lt;em&gt;loop&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;The command &lt;code&gt;loop&lt;/code&gt; supports a kind of break using &lt;code&gt;recur&lt;/code&gt; which is another command. Basically, we invoke &lt;code&gt;recur&lt;/code&gt; to continue the execution of the loop. We are allowed to use variables and modify them when iterating.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proc itemExists [val items -input] [val targetItem] {
    loop [val index 0] [val max [$items | invoke elements | invoke size]] {
        if [$index | lt $max] {
            if [$items | get $index | not-eq $targetItem] {
                recur [$index | plus 1][$max]
            } -else {
                bool true
            }
        } -else {
            bool false
        }
    } | equals true
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you can see above, the code is too complex in comparison with the previous one and make sure that the list is not empty since it fails when running &lt;code&gt;$items | invoke elements&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>list</category>
      <category>loop</category>
    </item>
    <item>
      <title>Count occurrences of an element in a list in RCPTT</title>
      <dc:creator>hiclab</dc:creator>
      <pubDate>Mon, 06 Apr 2020 11:57:44 +0000</pubDate>
      <link>https://dev.to/hiclab/count-occurrences-of-an-element-in-a-list-in-rcptt-4clg</link>
      <guid>https://dev.to/hiclab/count-occurrences-of-an-element-in-a-list-in-rcptt-4clg</guid>
      <description>&lt;p&gt;For those who don’t know, RCPTT (RCP Testing Tool) originally known as Q7 IDE, is an open source project with a focus to test Eclipse plugins and RCP applications. For more details, visit &lt;a href="https://www.eclipse.org/rcptt/"&gt;the RCPTT website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s assume we have a list of strings and we want to count the frequency of a given string. We will use the command &lt;code&gt;each&lt;/code&gt; to iterate over the list and check whether it contains the string.&lt;/p&gt;

&lt;p&gt;Let’s create a procedure in ECL, the scripting language used by RCPTT.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;proc countOccurrences [val items -input] [val targetItem] {
    $items | each [val it] {
        if [$it | eq $targetItem] {
            bool true
        }
    } | length
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The trick here is to return some value in the &lt;code&gt;if&lt;/code&gt; section every time the string is found. In our example, we return a boolean but actually we can return any other value. This is important in order to count the number of returned values at the end.&lt;/p&gt;

&lt;p&gt;Run some tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;global [val items [list a b c a d e a a]]

$items | countOccurrences a | log
$items | countOccurrences p | log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!MESSAGE 4
!MESSAGE 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>rcptt</category>
      <category>eclipse</category>
      <category>occurrences</category>
      <category>list</category>
    </item>
  </channel>
</rss>
