<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ali Mehdi Erçetin on Medium]]></title>
        <description><![CDATA[Stories by Ali Mehdi Erçetin on Medium]]></description>
        <link>https://medium.com/@ali-mehdi-ercetin?source=rss-a185d4fad737------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sCVzwnSEx4BxCrLHsAbbmA.jpeg</url>
            <title>Stories by Ali Mehdi Erçetin on Medium</title>
            <link>https://medium.com/@ali-mehdi-ercetin?source=rss-a185d4fad737------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:12:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ali-mehdi-ercetin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Default Execution Listener on Process Start with Camunda]]></title>
            <link>https://ali-mehdi-ercetin.medium.com/default-execution-listener-on-process-start-with-camunda-a956bf5b1547?source=rss-a185d4fad737------2</link>
            <guid isPermaLink="false">https://medium.com/p/a956bf5b1547</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[camunda]]></category>
            <dc:creator><![CDATA[Ali Mehdi Erçetin]]></dc:creator>
            <pubDate>Sun, 23 May 2021 13:33:04 GMT</pubDate>
            <atom:updated>2021-05-23T13:33:04.960Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*66IDf_E66Xi4aflSAn13tQ.png" /></figure><p>In my previous <a href="https://ali-mehdi-ercetin.medium.com/adding-default-task-listener-on-camunda-ce12ba0ef36e">article</a>, I mentioned about adding default task listener triggered on create event with a real world example. Task listeners are designed to react task events. There are six task events which are create, update, assignment, complete, timeout, and delete. Camunda offers also execution listener concept to react to events fired as execution progresses through the diagram like starting a process instance or end of an activity. There are two execuiton events which are start and end. In this article, I will mention about how you can add execution listener on process instance start event at runtime.</p><p>Firstly we will develop an execution listener that reads extension properties defined on start event and creates variables for these extension properties.</p><pre>public class ExtensionPropertiesExecutionListener implements ExecutionListener {<br><br>    @Override<br>    public void notify(DelegateExecution delegateExecution) throws Exception {<br>        CamundaProperties camundaProperties = delegateExecution.getBpmnModelElementInstance().getExtensionElements().getElementsQuery().filterByType(CamundaProperties.class).singleResult();<br>        for (CamundaProperty camundaProperty : camundaProperties.getCamundaProperties()) {<br>            delegateExecution.setVariable(camundaProperty.getCamundaName(), camundaProperty.getCamundaValue());<br>        }<br>    }<br>}</pre><p>ExecuitonListener interface is provided by Camunda Platform to use during execution listener development. This interface has notify method to store main listener business. ExtensionPropertiesExecutionListener firstly gets extension properties by using utilities that Camunda platform provides. delegationExecution property allows us to realize runtime operations and setVariable method, one of the methods that delegationExecution provides, adds process variable with given name value pair.</p><p>We have execution listener to realize what we aim but it should be triggered on process start event. For this, we will implement AddExecutionListenerParseListener.</p><pre>public class AddExecutionListenerParseListener extends AbstractBpmnParseListener {<br><br>    @Autowired<br>    private ExtensionPropertiesExecutionListener extensionPropertiesExecutionListener;<br><br>    @Override<br>    public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {<br>        processDefinition.addBuiltInListener(ListenerConstants.<em>START_EVENT_TYPE</em>, extensionPropertiesExecutionListener);<br>    }<br>}</pre><p>As we did for AddTaskListenerParseListener, we extend AbstractBpmnParseListener but this time we will use parseProcess method instead of parseUserTask to bound with process definition. Execution listener that we implemented before can be added to execution listener list on start event of the process with processDefinition.addBuiltInListener(ListenerConstants.<em>START_EVENT_TYPE</em>, extensionPropertiesExecutionListener). We need a last component to register AddExecutionListenerParseListener to Camunda platform. AddParseListenerPlugin is implemented for this purpose.</p><pre>public class AddParseListenerPlugin extends AbstractProcessEnginePlugin {<br><br>    @Autowired<br>    private AddExecutionListenerParseListener addExecutionListenerParseListener;<br><br>    @Override<br>    public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {<br>        List&lt;BpmnParseListener&gt; preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();<br>        if(preParseListeners == null) {<br>            preParseListeners = new ArrayList&lt;BpmnParseListener&gt;();<br>            processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);<br>        }<br>        preParseListeners.add(addExecutionListenerParseListener);<br>    }<br>}</pre><p>AddParseListenerPlugin helps us to add custom BPMN parse listeners and AddExecutionListenerParseListener is registered to Camunda platform. Now ExtensionPropertiesExecutionListener will be triggered on start event of all processes and the name value pair defined in extension properties of start event will be added as process variable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a956bf5b1547" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mutation Testing: How Well Your Unit Tests Cover?]]></title>
            <link>https://ali-mehdi-ercetin.medium.com/mutation-testing-how-well-your-unit-tests-cover-bdaf8541d5cc?source=rss-a185d4fad737------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdaf8541d5cc</guid>
            <category><![CDATA[mutation-testing]]></category>
            <category><![CDATA[pitest]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Ali Mehdi Erçetin]]></dc:creator>
            <pubDate>Sun, 16 May 2021 18:27:06 GMT</pubDate>
            <atom:updated>2021-05-16T18:27:06.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*V6RNRNXA40NfFFqqNIrCsw.jpeg" /></figure><p>Unit testing is a crucial point for software development and maintenance. From design phase to maintenance phase, unit tests allow software developers to provide robust design, reduce code complexity, detect and fix a defect at an early stage, and extend software functionality with lower cost. Because of this kind of benefits, unit test metrics and results are integrated on release and build pipelines. One of the most popular metrics is code coverage. Unit test line coverage is helpful for quantity based evaluation but relying only on this metric makes developers miss quality of the unit tests.</p><p>Mutation testing gauges how well your unit tests are written and whether they cover all the cases. Mutation testing functions as changing the code behavior. Every modification is called as mutation. With this mutation, all of unit tests are run and if at least one of them is failed, this mutation is caught and killed by your unit tests. But if your unit tests still pass after the mutation, your unit tests are unable to catch the mutation and it survives. Survival of the mutation means your unit tests cannot cover all cases. The percentage of the killed mutations shows the quality of your unit cases.</p><p>In this article, I will mention about how to perform mutation testing on Spring Boot application. In my project, I wrote my unit tests with JUnit 5. To perform mutation tests, <a href="http://pitest.org/">PITest</a> library will be used. Maven dependency of PITest can be added as following.</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.pitest&lt;/groupId&gt;<br>    &lt;artifactId&gt;pitest-parent&lt;/artifactId&gt;<br>    &lt;version&gt;1.6.6&lt;/version&gt;<br>    &lt;type&gt;pom&lt;/type&gt;<br>&lt;/dependency&gt;</pre><p>And also pitest-maven plugin will be added in our pom.xml in order to use PITest library.</p><pre>&lt;plugin&gt;<br>    &lt;groupId&gt;org.pitest&lt;/groupId&gt;<br>    &lt;artifactId&gt;pitest-maven&lt;/artifactId&gt;<br>    &lt;version&gt;1.6.6&lt;/version&gt;<br>    &lt;dependencies&gt;<br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.pitest&lt;/groupId&gt;<br>            &lt;artifactId&gt;pitest-junit5-plugin&lt;/artifactId&gt;<br>            &lt;version&gt;0.14&lt;/version&gt;<br>        &lt;/dependency&gt;<br>    &lt;/dependencies&gt;<br>    &lt;configuration&gt;<br>        &lt;targetClasses&gt;<br>            &lt;param&gt;com.sample.mutation.*&lt;/param&gt;<br>        &lt;/targetClasses&gt;<br>        &lt;targetTests&gt;<br>            &lt;param&gt;com.sample.mutation.*&lt;/param&gt;<br>        &lt;/targetTests&gt;<br>    &lt;/configuration&gt;<br>&lt;/plugin&gt;</pre><p>pitest-junit5-plugin is required to perform mutation tests with your unit tests implemented with JUnit 5. With configuration part, mutation testing can be performed on specific packages that you deserve. Creating mutations and running all unit tests for each mutation is costly operation and filtering target packages and tests according to requirements helps to reduce this cost. After these preparations, it is ready to perform mutation test. Now, let’s execute the pitest plugin with the command below and check the mutation testing result:</p><pre>mvn org.pitest:pitest-maven:mutationCoverage</pre><p>After the execution is completed, there will be reports in HTML format in the <strong><em>target/pit-reports/YYYYMMDDHHMI</em></strong> directory.</p><p>For better understanding, let’s focus on an example. We have following code that checks whether the given number is the ith fibonacci number.</p><pre>public class Fibonacci {<br><br>    private int getFibonacci(int index) {<br>        if(index == 0){<br>            return 0;<br>        }<br>        if(index == 1){<br>            return 1;<br>        }<br>        int firstPart = getFibonacci(index-1);<br>        int secondPart = getFibonacci(index-2);<br><br>        return firstPart + secondPart;<br>    }<br><br>    public boolean isCorrectFibonacci(int index, int number){<br>        return number == getFibonacci(index);<br>    }<br>}</pre><p>For this class, the following unit code is implemented.</p><pre>class FibonacciUnitTest {<br><br>    @Test<br>    void whenCorrectFibonacci_thenAccept() {<br>        Fibonacci fibonacciTester = new Fibonacci();<br>        <em>assertTrue</em>(fibonacciTester.isCorrectFibonacci(5, 5));<br>    }<br>}</pre><p>When mutation testing is performed, the result report appears as following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfrSQRuhAgEEEZALC3-Emw.jpeg" /></figure><p>As the report says nine mutations are created but one of them can’t be covered by the unit test and it is survived. Although line coverage is 100%, unit test isn’t good enough to cover all cases. To increase quality, the unit test should be added to cover the case that resulted in a survived mutation. In this case, the mutation changed the line 19 as ‘return true;’ and our unit test only covers positive results. We can handle this mutation by adding unit test checks whether the method returns false when it is required.</p><pre>void whenWrongFibonacci_thenReject() {<br>    Fibonacci fibonacciTester = new Fibonacci();<br>    <em>assertFalse</em>(fibonacciTester.isCorrectFibonacci(6, 11));<br>}</pre><p>After adding this test case, mutation testing is performed again and the new report becomes as following. As the report states, all mutations are killed and our test strength is 100%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*e5wVthi87UTpBudg5nZPeQ.jpeg" /></figure><p>Even though code coverage is an important metric, but sometimes it is not sufficient enough to guarantee a well-tested code. Mutation testing helps us to find possible missing test cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdaf8541d5cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Default Task Listener on Camunda]]></title>
            <link>https://ali-mehdi-ercetin.medium.com/adding-default-task-listener-on-camunda-ce12ba0ef36e?source=rss-a185d4fad737------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce12ba0ef36e</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[camunda]]></category>
            <dc:creator><![CDATA[Ali Mehdi Erçetin]]></dc:creator>
            <pubDate>Sun, 09 May 2021 18:51:23 GMT</pubDate>
            <atom:updated>2021-05-09T18:51:23.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I87ffmoG_E-dfCYA9Eg3Yw.jpeg" /></figure><p>Camunda is an open-source business process management(BPM) that users can create and deploy workflows and process them on it. As a developer, the definition that I like most is developer- friendly BPM tool because it allows developers to extend tool as they need. For some time, I had opportunity to work with Camunda to provide a ready-to-use platform for other developers in my company according to needs of our company.</p><p>In this article, I will mention about how to add default task listeners to user tasks of your processes at runtime. To understand more why we need this kind of development, let’s state a scenario. Camunda platform is configured to integrate with LDAP and all the users and the groups are gathered from LDAP. There is a only one LDAP environment to use in different stages and somehow you have to differentiate groups that are used in different environments because of security issues. One alternative to have different process definitions on different environments, so the process for test phase will have test candidate groups and one for production will have candidate groups for production. But the tested process won’t be same with the one deployed to production by this one and this approach is more error-prone.</p><p>Another way is deploying same process definition on every environment and Camunda platform will handle candidate groups according to the environment that it serves. To realize this, a task listener will be executed on user task creation event and this task listener will switch candidate groups with the ones appropriate with the current environment. We will develop SecurityGroupTaskCreateListener to switch candidate groups with the environment related ones by impelemented TaskListener interface provided by Camunda platform for task listener development.</p><pre>public class SecurityGroupTaskCreateListener implements TaskListener {<br><br>    @Value(&quot;${bpm.group.suffix}&quot;)<br>    private String suffix;<br><br>    @Override<br>    public void notify(DelegateTask delegateTask) {<br>        List&lt;String&gt; groupsToLink = new LinkedList&lt;&gt;();<br>        TaskEntity taskEntity = (TaskEntity) delegateTask;<br>        List&lt;IdentityLinkEntity&gt; candidates = taskEntity.getIdentityLinks();<br>        if (candidates == null || candidates.isEmpty()) {<br>            return;<br>        }<br>        ListIterator&lt;IdentityLinkEntity&gt; iterator = candidates.listIterator();<br>        while (iterator.hasNext()) {<br>            IdentityLinkEntity candidate = iterator.next();<br>            String groupId = candidate.getGroupId();<br>            if(groupId == null || StringUtils.<em>isEmpty</em>(groupId)){<br>                continue;<br>            }<br>            groupsToLink.add(groupId.concat(suffix));<br>            candidate.delete(false);<br>            iterator.remove();<br>        }<br><br>        if (groupsToLink.size() &gt; 0) {<br>            delegateTask.addCandidateGroups(groupsToLink);<br>        }<br>    }<br>}</pre><p>SecurityGroupTaskCreateListener firstly queries the candidates of the task by calling taskEntity.getIdentityLinks() and after validations on candidate list it iterates through this list and gets group id of the current candidate. The candidate group is removed with candidate.delete(false) and after the iteration ends, group list with ones concatenated with environment suffix added to candidate groups of the task with delegateTask.addCandidateGroups(groupsToLink).</p><p>We have task listener to realize what we aim but it should be triggered on user task creation event of user tasks of all processes. For this, we will implement AddTaskListenerParseListener.</p><pre>public class AddTaskListenerParseListener extends AbstractBpmnParseListener {<br><br>    @Autowired<br>    private SecurityGroupTaskCreateListener securityGroupTaskCreateListener;<br><br>    @Override<br>    public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {<br>        ActivityBehavior activityBehavior = activity.getActivityBehavior();<br>        if(activityBehavior instanceof UserTaskActivityBehavior){<br>            UserTaskActivityBehavior userTaskActivityBehavior = (UserTaskActivityBehavior) activityBehavior;<br>            TaskDefinition taskDefinition = userTaskActivityBehavior.getTaskDefinition();<br>            taskDefinition.addTaskListener(ListenerConstants.<em>CREATE_EVENT_TYPE</em>, securityGroupTaskCreateListener);<br>        }<br>    }<br>}</pre><p>AddTaskListenerParseListener extends AbstractBpmnParseListener that is provided to develop custom parse listener in Camunda Platform. AbstractBpmnParseListener has parse methods for different process definition elements and these methods are triggered when a process is parsed. Our case requires to add task listener on create event to user task, so AddTaskListenerParseListener overrides parseUserTask method. To add task listener to a task, the task definition of parsed user task is obtained. SecurityGroupTaskCreateListener is added in the task listener list of the user task for create event with taskDefinition.addTaskListener(ListenerConstants.<em>CREATE_EVENT_TYPE</em>, securityGroupTaskCreateListener). We need a last component to register AddTaskListenerParseListener to Camunda platform. AddTaskListenerParseListenerPlugin is implemented for this purpose.</p><pre>public class AddParseListenerPlugin extends AbstractProcessEnginePlugin {<br><br>    @Autowired<br>    private AddTaskListenerParseListener addTaskListenerParseListener;<br><br>    @Override<br>    public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {<br>        List&lt;BpmnParseListener&gt; preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();<br>        if(preParseListeners == null) {<br>            preParseListeners = new ArrayList&lt;BpmnParseListener&gt;();<br>            processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);<br>        }<br>        preParseListeners.add(addTaskListenerParseListener);<br>    }<br><br>}</pre><p>AddParseListenerPlugin helps us to add custom BPMN parse listeners and AddTaskListenerParseListener is registered to Camunda platform. Now for all user tasks in processes deployed to Camunda platform, SecurityGroupTaskCreateListener is triggered on task creation event and security groups are organized to be environment compatible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce12ba0ef36e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>