<?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 Hüseyin Barış Göksu on Medium]]></title>
        <description><![CDATA[Stories by Hüseyin Barış Göksu on Medium]]></description>
        <link>https://medium.com/@huseyinbaris.goksu?source=rss-887efb862372------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*uHcwfvBGqjPQrh4C.</url>
            <title>Stories by Hüseyin Barış Göksu on Medium</title>
            <link>https://medium.com/@huseyinbaris.goksu?source=rss-887efb862372------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:19:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@huseyinbaris.goksu/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[Integration of Karate DSL with Spring Boot To Create Datasets at Trendyol]]></title>
            <link>https://medium.com/trendyol-tech/integration-of-karate-dsl-with-spring-boot-to-create-datasets-at-trendyol-1997ec3c4d04?source=rss-887efb862372------2</link>
            <guid isPermaLink="false">https://medium.com/p/1997ec3c4d04</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[karate-dsl]]></category>
            <dc:creator><![CDATA[Hüseyin Barış Göksu]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 11:27:27 GMT</pubDate>
            <atom:updated>2025-01-13T11:27:27.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*KRn7pwvXdzt_fwoyarsnmQ.png" /></figure><p>As the Private Label Management team, we are designing screens for products produced for the Trendyol Milla brand. These screens allow us to create products and place orders, enabling product manufacturing. While testing these processes, we often need datasets, and manually creating data repeatedly causes us to lose time. Additionally, we collaborate with other teams who also need access to data. Let’s take a look at how we have addressed this issue using Karate DSL.</p><p>In this article, we will explore a project we developed to facilitate data creation in test environments and address requests from other teams effectively.</p><p><strong>Objective:</strong> We enable users and dependent teams to create orders without relying on UI screens, eliminating manual data requests, and achieving time and cost savings.</p><h3>Problem Statement</h3><p>After completing the packaging process, the data often needs to be shared with other teams. These teams require this data for their testing purposes, but they can only generate it through our specific screens. However, they may not always have access to these screens, or even if they do, they may lack the business knowledge to quickly create the required datasets. As a result, they end up reaching out to the relevant individuals within the team to request the creation of the data. By implementing this project, we aim to enable the generation of the required data with a single button click.</p><p>​​ Our software developers often need to create special datasets and test scenarios. While they can do this through the UI, it results in significant time loss. Even if they use APIs, they need to send requests to multiple services, manually input the dynamic data required by each service, and create the dataset.With this project, orders can be generated with a single click, eliminating time loss and the need to fill in any dataset manually. Additionally, orders can be created based on the specified requirements. This not only ensures time efficiency but also enables the rapid and accurate creation of the desired cases. In addition, creating data through the site’s UI screens leads to time and effort inefficiencies.</p><h3>Solution</h3><p>We are introducing this project as a solution by designing a UI screen for use both within our team and by other teams. Whenever you need a dataset, you can create it directly through these screens. For any missing datasets, you can submit a request for us to develop them.</p><p>The inbound team requires data for their warehouse processes, and this data needs to be generated by creating an order through PLM screens and sending the order to the warehouse. After the order is sent to the warehouse, quantities must be entered, and boxes need to be created. Up to this stage, all data sets are handled through the pages under the responsibility of the PLM team. Following this step, during the box creation phase, this data flows to the inbound team. For this data to flow, these operations need to be performed sequentially. With the application we developed, the inbound team can access this data with the click of a single button.</p><h3>Project Goal</h3><p>The purpose of this project is to address the recurring situation where other teams approach to request data, as they often need multiple datasets. This process frequently requires significant manual effort to create the requested data, resulting in considerable time loss and an increased manual workload during the dataset preparation phase. Additionally, users can generate required data directly through the UI provided by the<strong> index.html</strong> page, making the process even faster and more user-friendly.</p><p>This project aims to empower teams and users to independently create data by:</p><ul><li><strong>Saving Time</strong>: Generating data without spending time on UI screens.</li><li><strong>Reducing Costs</strong>: Eliminating the workload of fulfilling manual data requests from other teams.</li><li><strong>Efficient Data Management</strong>: Enabling teams to quickly acquire the data they need.</li></ul><p>This project allows teams to generate the data they need by simply accessing the relevant page and clicking a single button. When other teams do not have knowledge of the business logic of a specific team, they may face challenges in generating the required data or need to contact the respective teams. During the data generation process, individuals from the responsible team must dedicate time to create the data, leading to both time loss and interruptions in their workflow.</p><p>With this project, other teams can easily create the desired data set by accessing the relevant pages. Additionally, developers within the team can quickly generate specific cases or create data to reproduce a bug by simply clicking a button.</p><p>For instance, if there is a bug in the system and a data set is required to reproduce it, this process can be completed within seconds, which is much faster and more convenient than manually creating the data.</p><p><strong>Why Karate DSL?</strong></p><p>The purpose of using <strong>Karate DSL</strong> in this project is to quickly generate data without having to deal with response models. In other open-source frameworks, you often need to create models for responses, which can be time-consuming and add unnecessary complexity to the process. Karate DSL allows for more rapid data generation, streamlining the process and saving valuable time. As the PLM team, we easily integrated the automation we developed using Karate DSL into this project. One of the main reasons for choosing Karate DSL is its simplicity in integration. We successfully brought this project to life by leveraging the existing API automation.</p><h3>Architecture and Technology Choices</h3><p>The technical architecture of the project was designed as follows:</p><h4>1. Backend Structure</h4><p>The project was developed using the Java Spring Boot framework. Key components include:</p><ul><li><strong>Controller</strong>: Provides RESTful API endpoints.</li><li><strong>Utilities</strong>: Performs data operations with helper methods.</li></ul><h4>2. Using Karate DSL</h4><p>Using Karate DSL, API endpoint validations and data creation functions were tested. This approach is ideal for integration testing.</p><ul><li><strong>features/purchase-order.feature:</strong> Contains test scenarios.</li><li><strong>karate-config.js</strong>: Configuration required for test scenarios.</li></ul><h4>3. Logging and Configuration</h4><ul><li><strong>Log4j2</strong>: Records application logs in detail.</li><li><strong>application.properties</strong>: Stores Spring Boot application settings.</li></ul><h4>4. UI Integration</h4><p>The<strong> index.html</strong> file provides a simple UI screen that allows users to quickly create the data they need. This screen demonstrates the basic logic of the solution and offers an additional layer of user convenience.</p><h3>Code Highlights</h3><h4>MyController.java</h4><p>The controller providing API endpoints is designed for data creation operations.</p><pre>@RestController<br>@RequestMapping(&quot;/api&quot;)<br>public class MyController {<br>   static Results results;<br>   @GetMapping(&quot;/purchaseOrder&quot;)<br>   public JsonNode purchaseOrder() {<br>       results = Runner<br>               .path(&quot;classpath:features/purchase-order.feature&quot;)<br>               .outputCucumberJson(true)<br>               .parallel(1);<br>       return convertStringToJson(System.getProperty(&quot;response&quot;));<br>   }<br>}</pre><h4>Code Walkthrough</h4><ol><li><strong>Mapping the API Endpoint:</strong> The<strong> @GetMapping(“/purchaseOrder”)</strong> annotation defines an endpoint that users can call via an HTTP GET request.</li><li><strong>Executing Karate Scenarios:</strong> The <strong>Runner</strong> class from Karate DSL is used to execute the <strong>purchase-order.feature</strong> file. We use .<strong>parallel</strong>(1) to ensure single-threaded execution, and .<strong>outputCucumberJson</strong>(<strong>true</strong>) ensures the results are returned in a Cucumber-compatible JSON format.</li><li><strong>Returning the Response:</strong> The response from the Karate scenario is retrieved using <strong>System.getProperty(“response”</strong>) and is converted into a JSON object using the <strong>convertStringToJson</strong> utility method.</li></ol><p><strong>Karate Config File</strong></p><p>In Karate DSL, you can define the base url in a karate-config.js file and use it across your tests.</p><pre>function fn() {<br>   let config = {<br>       baseUrl: &#39;https://medium-test.free.beeceptor.com/&#39;<br>   };<br>   const javaUtils = Java.type(&quot;util.Utilities&quot;);<br>   config = {...config, ...javaUtils};<br>   return config;<br>}</pre><ol><li><strong>Java.type(“util.Utilities”):</strong> ​​You can directly access Java classes from within a Karate feature file using the Java.type() approach. If you have utility classes within a Java package (for example, in the util package), you can access them in your Karate test by first referencing the Java class and then calling its methods.</li><li><strong>baseUrl : </strong>You can define the baseUrl in the karate-config.js file and use it directly within your Karate feature files. This allows you to centralize your configuration and access the baseUrl in all your feature files without redefining it in each one.</li></ol><h3>The Feature File</h3><p>The Karate feature file<strong> (purchase-order.feature)</strong> contains the business logic for generating purchase order data. Here’s a simplified version:</p><pre>Feature: Purchase Order Generation<br>Scenario: Generate a purchase order<br>Given def responses = []<br>Given url baseUrl<br>Given path &#39;create-purchase-order&#39;<br>When method POST<br>Given karate.appendTo(responses, response)<br>Given def response = setSystemProperties(&quot;response&quot;,karate.toString(responses))<br>Then status 200</pre><h3>Feature: Purchase Order Generation</h3><p>This is the feature being described in the Karate framework. It outlines a process for generating a purchase order, with a series of actions and checks.</p><h3>Scenario: Generate a purchase order</h3><p>This scenario describes the steps to generate a purchase order via an API request.</p><h4>1. Given def responses = []</h4><ul><li>This initializes an empty array of responses. This array will store the API responses during the execution of the scenario.</li></ul><h4>2. Given url baseUrl</h4><ul><li>This sets the target URL for the API request. In this case, baseUrl was defined on karate-config.js</li></ul><h4>3. When method GET</h4><ul><li>This step performs the actual HTTP request. It sends a <strong>GET</strong> request to the URL defined earlier <strong>(https://medium-test.free.beeceptor.com/create-purchase-order)</strong></li><li>The response from the API is captured in a variable called response automatically by Karate.</li></ul><h4>4. Given karate.appendTo(responses, response)</h4><ul><li>After receiving the response from the API, this step appends the response to the previously created responses array.</li><li>This is done to collect all the responses, in case multiple requests or results need to be stored for further processing.</li></ul><h4>5. Given def response = setSystemProperties(“response”, karate.toString(responses))</h4><ul><li>This step converts the<strong> responses</strong> array into a string using<strong> karate.toString(responses) </strong>and then stores it as a system property called <strong>response</strong>.</li><li>The method<strong> setSystemProperties(“response”, …)</strong> saves this string to the system properties. This makes it accessible globally (in subsequent steps, or in other contexts, e.g., Java code, or Spring Boot controllers).</li></ul><h4>6 . Then status = 200</h4><ul><li>This step verifies that the value of the variable<strong> responseStatus is 200</strong>. This is an additional check to ensure that the response from the previous API call had a successful HTTP status (status code 200).</li></ul><h3>Utility Class</h3><p>The<strong> Utilities</strong> class includes the<strong> convertStringToJson</strong> method, which parses a JSON string into a <strong>JsonNode</strong> object:</p><pre>public class Utilities {<br><br><br>   static Properties properties = System.getProperties();<br><br><br>   public static void setSystemProperties(String key, String value) {<br>       properties.setProperty(key, value);<br>       System.setProperties(properties);<br>   }<br><br><br>   public static String getSystemProperties(String key) {<br>       return properties.getProperty(key);<br>   }<br><br><br>   public static JsonNode convertStringToJson(String jsonString) {<br>       ObjectMapper objectMapper = new ObjectMapper();<br>       try {<br>          <br>           return objectMapper.readTree(jsonString);<br>       } catch (JsonProcessingException e) {<br>           e.printStackTrace();<br>           return null; <br>       }<br>   }<br>}</pre><p>This method uses Jackson’s <strong>ObjectMapper</strong> to convert a JSON string into a <strong>JsonNode</strong> object, making it easier to manipulate in Java.</p><p>In your Java code, you have two methods to set and get system properties using the <strong>System.setProperties()</strong> and<strong> properties.getProperty()</strong> methods. Here’s how they work:</p><ol><li><strong>setSystemProperties(String key, String value):</strong> This method sets a system property by updating the <strong>properties</strong> object and then calls<strong> System.setProperties()</strong> to apply the changes globally. This means the property can be accessed from anywhere in the system using <strong>System.getProperty().</strong></li><li><strong>getSystemProperties(String key):</strong> This method retrieves the value of the system property for a given <strong>key</strong> by calling<strong> properties.getProperty().</strong></li></ol><p>​​<strong>API in Action</strong></p><p>To call the API, use the following <strong>curl</strong> command:</p><pre>curl &quot;http://localhost:8080/api/purchaseOrder</pre><p><strong>Example Response</strong>:</p><pre>{&quot;orderId&quot;: &quot;12345&quot;,&quot;status&quot;: &quot;CREATED&quot;,&quot;name&quot;: &quot;CustomOrder&quot;}</pre><p><strong>Benefits of UI Integration with Spring Boot</strong></p><ol><li><strong>Easy Management:<br></strong>Spring Boot organizes files into logical directories:</li></ol><ul><li><strong>templates:</strong> For dynamic HTML files.</li><li><strong>static:</strong> For static assets (CSS, JS, images).</li></ul><p>2. <strong>Dynamic Data Support:</strong><br><strong>Easy Management:</strong><br>Spring Boot organizes files into logical directories:</p><ul><li><strong>templates:</strong> For dynamic HTML files.</li><li><strong>static:</strong> For static assets (CSS, JS, images).</li></ul><p><strong>Dynamic Data Support:</strong><br>With template engines like Thymeleaf, you can pass dynamic data from the backend to the UI.</p><p><strong>Simple and Fast Setup:</strong><br>No additional configuration is needed. Just place files in the right directories.</p><p><strong>Full Integration:</strong><br>Both backend (Spring Boot) and frontend (HTML, CSS, JS) coexist in the same project, reducing communication gaps and speeding up development.</p><p><strong>Ease of Testing and Development:</strong></p><ul><li>Developers can test the UI directly at<strong> </strong><a href="http://localhost:8080."><strong>http://localhost:8080.</strong></a></li><li>CSS/JS updates apply instantly during development.</li></ul><p><strong>SEO and Performance Optimization:</strong><br>Spring Boot’s efficient handling of static files ensures fast-loading, SEO-friendly pages.</p><p>The following code showcases the UI side of the project. Currently, four scenarios have been integrated into the project. Previously written tests were added to this project seamlessly and efficiently. Using the <strong>index.html</strong> file, these scenarios were linked to buttons or other visual elements, making the project open source. This approach allowed us to integrate a simple UI into the project without requiring extensive UI knowledge. As a result, the project was made available for users.The following code showcases the UI side of the project. Currently, four scenarios have been integrated into the project. Previously written tests were added to this project seamlessly and efficiently. Using the <strong>index.html</strong> file, these scenarios were linked to buttons or other visual elements, making the project open source. This approach allowed us to integrate a simple UI into the project without requiring extensive UI knowledge.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;tr&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Test Data Generator&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>&lt;div class=&quot;container&quot;&gt;<br>    &lt;h1&gt;Test Data Generator&lt;/h1&gt;<br>    &lt;div class=&quot;btn-container&quot;&gt;<br>        &lt;button id=&quot;purchaseOrderButton&quot; class=&quot;btn purchaseOrderButton&quot;&gt;Purchase Order Oluştur&lt;/button&gt;<br>    &lt;/div&gt;<br>    &lt;div id=&quot;resultCard&quot; class=&quot;card&quot;&gt;<br>        &lt;div class=&quot;card-header&quot;&gt;Sonuç&lt;/div&gt;<br>        &lt;div id=&quot;responseContent&quot; class=&quot;card-body&quot;&gt;<br>            &lt;p&gt;Sonuç burada görünecek.&lt;/p&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;<br><br>&lt;script src=&quot;https://code.jquery.com/jquery-3.6.0.min.js&quot;&gt;&lt;/script&gt;<br>&lt;script&gt;<br>    $(document).ready(function () {<br>        $(&quot;#purchaseOrderButton&quot;).click(function () {<br>            fetchResult(&#39;purchaseOrder&#39;);<br>        });<br><br>        function fetchResult(type) {<br>            $(&quot;#resultCard&quot;).show(); // Kartı göster<br>            $(&quot;#responseContent&quot;).html(&#39;&lt;p&gt;Yükleniyor...&lt;/p&gt;&#39;); // Kartı boşalt<br>            $.get(`/api/${type}`, {name: &#39;Test&#39;}, function (data) {<br>                // Gelen veriyi kartın içine yerleştir<br>                $(&quot;#responseContent&quot;).html(&#39;&lt;pre&gt;&#39; + JSON.stringify(data, null, 2) + &#39;&lt;/pre&gt;&#39;);<br>            }).fail(function () {<br>                $(&quot;#responseContent&quot;).html(&#39;&lt;p class=&quot;text-danger&quot;&gt;Bir hata oluştu!&lt;/p&gt;&#39;);<br>            });<br>        }<br>    });<br>&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>As a result, the project was made available for users.</p><pre>src/<br>├── main/<br>│   ├── java/<br>│   │   └── com/<br>│   │       └── example/<br>│   │           ├── controller/<br>│   │           │   └── MyController.java<br>│   │           ├── util/<br>│   │           │   └── Utilities.java   <br>│   │           └── TestDataGeneratorApplication.java<br>│   ├── resources/<br>│   │   ├── features/<br>│   │   │   └── purchase-order.feature<br>│   │   ├── templates/<br>│   │   │   └── index.html<br>│   │   └── application.properties<br>└── pom.xml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/0*BTuAtjLTDM1-AFOi" /></figure><p><strong>Conclusion:<br></strong>As the PLM team at Trendyol, this project addresses several key challenges faced in software development:</p><ul><li><strong>Time savings</strong> by automating the data creation process, reducing reliance on UI screens and manual data requests.</li><li><strong>Cost reduction</strong> by eliminating the workload associated with fulfilling manual data requests.</li><li><strong>Increased efficiency and reduced errors</strong> by automating data generation, ensuring consistent and accurate datasets for testing.</li></ul><p>By enabling teams to independently generate the test data they need, we enhance the speed and reliability of the development process. This allows teams to focus more on core development tasks rather than data management. This solution not only benefits individual teams but also fosters a more streamlined and effective environment for cross-team collaboration and development at Trendyol.</p><p>Tuğçe Akın, my teammate, has played a significant role in the creation and realization of this project. We designed the project together, and her support, ideas, and dedication were crucial in achieving the project’s objectives. I sincerely thank her for her contributions.</p><p>Thank you for reading! ❤️</p><p>We’re building a team of the brightest minds in our industry. Interested in joining us? Visit the pages below to learn more about our open positions.</p><p><a href="https://jobs.lever.co/trendyol?source=post_page-----4ced05e26b1e--------------------------------">Trendyol jobs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1997ec3c4d04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trendyol-tech/integration-of-karate-dsl-with-spring-boot-to-create-datasets-at-trendyol-1997ec3c4d04">Integration of Karate DSL with Spring Boot To Create Datasets at Trendyol</a> was originally published in <a href="https://medium.com/trendyol-tech">Trendyol Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>