<?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 Vitor Hugo Salgado on Medium]]></title>
        <description><![CDATA[Stories by Vitor Hugo Salgado on Medium]]></description>
        <link>https://medium.com/@vtrsalgado?source=rss-e5c5907088df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A0I-wCxNhiGH02LgcYGCig.jpeg</url>
            <title>Stories by Vitor Hugo Salgado on Medium</title>
            <link>https://medium.com/@vtrsalgado?source=rss-e5c5907088df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:21:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vtrsalgado/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[Puma4j — An easy and convenient way to load file resources into JUnit 5 tests]]></title>
            <link>https://vtrsalgado.medium.com/puma4j-easier-way-to-load-and-convert-resource-files-in-your-junit-5-tests-f9b0bc5a95e2?source=rss-e5c5907088df------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9b0bc5a95e2</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Vitor Hugo Salgado]]></dc:creator>
            <pubDate>Tue, 01 Feb 2022 23:43:51 GMT</pubDate>
            <atom:updated>2022-09-22T01:17:32.694Z</atom:updated>
            <content:encoded><![CDATA[<h3>Puma4j — An easy way to load file resources into JUnit 5 tests</h3><h4>Load and parse file resources into JUnit5 tests with just a couple of annotations</h4><figure><img alt="Coding" src="https://cdn-images-1.medium.com/max/1024/0*we_tVB2nX6nFv5Fj" /><figcaption>Photo by <a href="https://unsplash.com/@jstrippa?utm_source=medium&amp;utm_medium=referral">James Harrison</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello developers, in this post, I want to present <strong>Puma4j</strong>, a new open source project I recently published that I hope will make your life writing <strong>JUnit 5</strong> tests a little bit easier.</p><blockquote>Check the project repository on <a href="https://github.com/vitorsalgado/puma4j">Github</a></blockquote><h3>The Project</h3><p>In testing<em> microservices</em>, we usually need to simulate the behavior of external integrations, mocking HTTP requests/responses and messages arriving in topics or queues. For this, we need to build a lot of payloads in our tests. <br>Instead of creating test data in our code which sometimes leaves our tests a little &quot;dirty,&quot; or creating the same boilerplate code all the time to read and parse resource files, why not leverage <em>JUnit 5</em> extensions to make a simple and standardized way to do this and also have some fun coding new stuff?<br>That&#39;s why <strong>Puma4j</strong> was created. With <strong>Puma4j</strong>, you can load and convert resources with just a couple of annotations.</p><p>Take a look at the usage example below:</p><h4>Installation with Gradle</h4><pre>implementation &quot;io.github.vitorsalgado.puma4j:puma4j-junit5-extension:4.0.2&quot;</pre><h4>Usage Example</h4><p>Consider a scenario where you have the following files in your <strong>test resources</strong> directory:</p><ul><li>model.json</li><li>test.txt</li><li>data.yml</li></ul><pre>@UsePuma4j<br>class YourJUnit5Test {<br><br>  static class Model {<br><br>    public String hello<strong>;<br>  </strong>}<br><br>  @Res(&quot;data.yml&quot;)<br>  private static Model <em>ymlData</em><strong>;<br><br>  </strong>@Res(&quot;test.txt&quot;)<br>  private String txt<strong>;<br><br>  </strong>@Test<br>  void test(@Res(&quot;model.json&quot;) Model model) {<br>    <em>assertEquals</em>(&quot;world&quot;<strong>, </strong>model.hello)<strong>;<br>    </strong><em>assertEquals</em>(&quot;world&quot;<strong>, </strong><em>ymlData</em>.hello)<strong>;<br>    </strong><em>assertEquals</em>(&quot;hello world&quot;<strong>, </strong>txt)<strong>;<br>  </strong>}<br>}</pre><p>Following the example above, to use <em>Puma4j</em>, we need to annotate our test class with &quot;<strong>@UsePuma4j&quot; </strong>and then, all fields and method parameters that we want resources to be injected need to be annotated with &quot;<strong>@Res(RESOURCE_NAME_AND_EXTENSION).&quot;</strong> <br>Puma4j will automatically load the resources and convert them based on field or parameter type. For example, you can load the raw file value using a String or byte array.</p><p><strong>Supported File Types</strong></p><p>Puma4j can convert the following resources into Java object instances:</p><ul><li><strong>JSON</strong></li><li><strong>YAML</strong></li><li><strong>Properties</strong></li></ul><p>The content of other file types, like <strong>.txt</strong>, can be loaded into a <strong>String</strong> or <strong>byte array</strong>.</p><p><strong>Custom Converters</strong></p><p>We can use a custom converter for your resources. Implement the interface Unmarshaller&lt;O&gt; and provide the class reference to the annotation &quot;<strong>@Use(YourCustomConverter.class)&quot;</strong>. The annotation &quot;<strong>@Use</strong>&quot; can be applied to the class, field, and method parameters.</p><p><strong>Switching JSON Converters</strong></p><p>By default, Puma4j uses Jackson Object Mapper to convert JSON resources into Java objects. To switch to Gson, use the annotation &quot;<strong>@UseGson.&quot;</strong> The annotation can be applied to class, field, and method parameters. In addition, there is a &quot;<strong>@UseJackson</strong>&quot; to force a specific resource to use Object Mapper.</p><p>Take a look at the project documentation and source code on:</p><p><a href="https://github.com/vitorsalgado/puma4j">GitHub - vitorsalgado/puma4j: Easy and convenient way to load file resources into your tests using only annotations.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9b0bc5a95e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Simple Node.js Boilerplate With TypeScript]]></title>
            <link>https://vtrsalgado.medium.com/a-simple-node-js-boilerplate-with-typescript-647c2601f04?source=rss-e5c5907088df------2</link>
            <guid isPermaLink="false">https://medium.com/p/647c2601f04</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[boilerplate]]></category>
            <dc:creator><![CDATA[Vitor Hugo Salgado]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 02:51:01 GMT</pubDate>
            <atom:updated>2022-09-22T01:27:31.188Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using <a href="https://github.com/vitorsalgado/create-nodejs-ts">create-nodejs-ts</a> to set up new projects quickly</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KkRQPbkVIO_Rha5k" /><figcaption>Photo by <a href="https://unsplash.com/@codestorm?utm_source=medium&amp;utm_medium=referral">Safar Safarov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hello developers, greetings from Santiago 🇨🇱. This is my first post here, and I want to present an NPM package I recently published, <a href="https://www.npmjs.com/package/create-nodejs-ts">create-nodejs-ts</a>.</p><p>Suppose you want to start a new project with a healthy and consistent development environment. In that case, there are several configurations you may need to do, like setting up “linters,” code style tools, test frameworks, git hooks, etc. <a href="https://www.npmjs.com/package/create-nodejs-ts">create-nodejs-ts</a> comes with all those boring stuff already configured so you can focus on the fun stuff, coding. <br>The idea is very similar to scripts like <em>create-react-app. <br></em>Below I will briefly explain how to use and the tooling contained in this boilerplate.</p><blockquote>The <a href="https://github.com/vitorsalgado/create-nodejs-ts">GitHub</a> project contains more details :)</blockquote><h3>Starting a New Project</h3><p>It is easy to use this boilerplate, just a command, and done! The preferred way to use the package is with <strong>npx</strong>. Take a look at the sample below:</p><pre>npx create-nodejs-ts --no --app=new-app</pre><p>The command above will create a new Node.js project on the folder <strong>new-app</strong> in the current directory. You can omit the argument <strong>app; </strong>the new project will be created on <strong>my-app</strong>. You can use <strong>npm init</strong> too:</p><pre>npm init nodejs-ts --app=new-app</pre><p><strong>This boilerplate focus on tools that are usually common on Node.js projects</strong>. For now, there’s no boilerplate for an HTTP server or stuff like that. That’s not the idea of this project. <br>Run the script and start coding with your preferred libraries.</p><p>The generated boilerplate will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*Zj-OphyIoUf7thOoxUVVCg.png" /><figcaption>Generated Project Structure</figcaption></figure><h3>Tooling</h3><p>These are the tools already configured on this boilerplate:</p><ul><li><a href="https://www.typescriptlang.org/">TypeScript</a></li><li><a href="https://jestjs.io/">Jest</a></li><li><a href="https://eslint.org/">ESLint</a></li><li><a href="https://prettier.io/">Prettier</a></li><li><a href="https://typicode.github.io/husky/#/">Husky</a></li><li><a href="https://github.com/okonet/lint-staged">Lint Staged</a></li><li><a href="https://github.com/conventional-changelog/commitlint">Commit Lint</a></li><li><a href="https://nodemon.io/">Nodemon</a></li><li><a href="https://www.docker.com/">Docker and Docker Compose</a></li><li><a href="https://docs.github.com/en/actions">CI with GitHub Actions</a></li></ul><p>ESLint and Prettier ensure code style and good practices.<br>Husky, Lint Staged, and Commit Lint ensures that no files are committed without following project standards. <br>Jest is the test framework and comes with <a href="https://github.com/kulshekhar/ts-jest">ts-jest</a> for TypeScript.<br>Nodemon is used to reload the application on changes.<br>Docker is used for local development, and it comes with a Dockerfile that generates a minimum image with gcr.io/distroless/nodejs.</p><p>Take a look at the source code on <a href="https://github.com/vitorsalgado/create-nodejs-ts">https://github.com/vitorsalgado/create-nodejs-ts</a> repository if you want to know more details.</p><p>Thanks for reading, and I hope you enjoy :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=647c2601f04" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>