<?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: Dan</title>
    <description>The latest articles on DEV Community by Dan (@ddold).</description>
    <link>https://dev.to/ddold</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%2F645947%2Fb68022c3-b26b-40f3-b3d4-94f09d88202d.png</url>
      <title>DEV Community: Dan</title>
      <link>https://dev.to/ddold</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ddold"/>
    <language>en</language>
    <item>
      <title>Get advice while stuck on a project</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Mon, 12 Sep 2022 12:21:53 +0000</pubDate>
      <link>https://dev.to/ddold/get-advice-while-stuck-on-a-project-1c4f</link>
      <guid>https://dev.to/ddold/get-advice-while-stuck-on-a-project-1c4f</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Not sure if this is the correct place to ask or not, but said I would try!&lt;br&gt;
I am creating a web app using a quarkus server, I am at a part of the app where I want my users to have an option of uploading files. There is a million+ tutorials on that and I am not stuck on that part.&lt;/p&gt;

&lt;p&gt;What I am having trouble is I don't want to just upload a file, I want to upload a file with with extra information too, such as the name, description, expiry date, if it's required etc. Now this is something I can't seem to find anywhere and I am not sure where to go with this.&lt;/p&gt;

&lt;p&gt;I dunno if the file is uploaded in it's own call and then the object is uploaded. Seems like a lot to me tbh.&lt;/p&gt;

&lt;p&gt;Also with file management, is it better to save the file to the db or is it better to save it in a location on the server and then attach the path to the object saved in the db? &lt;/p&gt;

&lt;p&gt;Really need help on this as I am stuck and haven't a clue.&lt;/p&gt;

&lt;p&gt;TL;DR&lt;br&gt;
Want to upload file over REST endpoint but also include other properties external to the file, like expiry date, required etc. &lt;/p&gt;

</description>
      <category>java</category>
      <category>discuss</category>
      <category>help</category>
      <category>webdev</category>
    </item>
    <item>
      <title>DB Testing with TestContainers</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Tue, 06 Jul 2021 19:50:48 +0000</pubDate>
      <link>https://dev.to/ddold/db-testing-with-testcontainers-390a</link>
      <guid>https://dev.to/ddold/db-testing-with-testcontainers-390a</guid>
      <description>&lt;p&gt;Testing, as we all know is a very important part of development, but it is not always easy to do!&lt;/p&gt;

&lt;p&gt;Trying to find a way to test querying databases was very tough, at least I thought so anyway. From doing some research online there was one of two ways to test this;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use mocks&lt;/li&gt;
&lt;li&gt;Use an embedded db - including &lt;a href="https://www.testcontainers.org/"&gt;testcontainers&lt;/a&gt; in this&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Personally I don't like mocks, so that was option 1 ruled out.&lt;/p&gt;

&lt;p&gt;Using testcontainers in code was great and worked very well but I had a slight problem. For the life of me I could not get the database to reset between tests. If I were to run the tests individually, all would be good. But when I run a suite of tests at once they fail because the db isn't reset.&lt;/p&gt;

&lt;p&gt;With a Quarkus setup I was able to find out that if you annotate the class with &lt;code&gt;@TestTransaction&lt;/code&gt;, then after each test the db is rolled back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@QuarkusTest
@TestTransaction
public class TestClass {

    @ClassRule
    private static PostgreSQLContainer dbContainer = new PostgreSQLContainer("postgres-image")
            .withDatabaseName("dbname")
            .withUsername("username")
            .withPassword("password");

    @Test
    public void myTest() {}


    @Test
    public void myTest_2() {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now with the two tests, you can run them as a suite and the db will be reset after each test is finished.&lt;/p&gt;

&lt;p&gt;Happy testing&lt;/p&gt;

</description>
      <category>java</category>
      <category>database</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
