{"id":758,"date":"2022-12-19T14:24:24","date_gmt":"2022-12-19T06:24:24","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=758"},"modified":"2022-12-19T14:24:26","modified_gmt":"2022-12-19T06:24:26","slug":"third-week-of-internship-at-tong-hin","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/","title":{"rendered":"Third Week of Internship at Tong Hin"},"content":{"rendered":"\n<p>I spend my third week mostly working on a complex command Update and fixing bugs in my code.<\/p>\n\n\n\n<p>I started off the week by adding more test cases in the Repository test file, the purpose behind this was to test if my repository is correctly performing the CRUD operations. After this, I realized that I\u2019m yet to write test cases for data which should have been done once the entities were created as these test cases help ensure the data type of each field is consistent.<\/p>\n\n\n\n<p>Next, I shifted my focus to correctly format my API test cases, of Create and Delete, according to the norms of 3 A\u2019s which are Arrange, Act and Assert. Moreover, I improved my test cases by adding more assertions.&nbsp;<\/p>\n\n\n\n<p>Finally, I started on coding the logic of the Update command which was challenging because Updating every field can have multiple possibilities.<\/p>\n\n\n\n<p>After coding the logic I realized there was a bug which was occurring when an existing line item was removed and a completely new one was added. Once the bug in the UpdateHandler was fixed, I added the controller which handles the whole PUT request.<\/p>\n\n\n\n<p>Lastly, I moved my focus on testing the Update Command. On running the test case gave me an error report <em>&#8216;database operation expected to affect 1 row(s) but actually affected 0 row(s)&#8217; error. <\/em>After a lot of unsuccessful debugging I finally sought help from my supervisor who helped me find the bug and explain to me the root cause of it. This error was due to the primary key which I was hardcoding inside my update logic. We are not supposed to set the primary key as the database does it for us automatically.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spend my third week mostly working on a complex command Update and fixing bugs in my code. I started off the week by adding more test cases in the Repository test file, the purpose behind this was to test if my repository is correctly performing the CRUD operations. After this, I realized that I\u2019m &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Third Week of Internship at Tong Hin&#8221;<\/span><\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Third Week of Internship at Tong Hin | Tong Hin&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Third Week of Internship at Tong Hin | Tong Hin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"I spend my third week mostly working on a complex command Update and fixing bugs in my code. I started off the week by adding more test cases in the Repository test file, the purpose behind this was to test if my repository is correctly performing the CRUD operations. After this, I realized that I\u2019m &hellip; Continue reading &quot;Third Week of Internship at Tong Hin&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-19T06:24:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-19T06:24:26+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\",\"name\":\"Third Week of Internship at Tong Hin | Tong Hin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2022-12-19T06:24:24+00:00\",\"dateModified\":\"2022-12-19T06:24:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/\",\"name\":\"Third Week of Internship at Tong Hin\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/70320e76a31dca264cb8173efc5130b4\"},\"headline\":\"Third Week of Internship at Tong Hin\",\"datePublished\":\"2022-12-19T06:24:24+00:00\",\"dateModified\":\"2022-12-19T06:24:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2022\/12\/19\/third-week-of-internship-at-tong-hin\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/70320e76a31dca264cb8173efc5130b4\",\"name\":\"Subhan Saadat Khan\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/96d592dced83cd4b497db189e9f44d90?s=96&d=mm&r=g\",\"caption\":\"Subhan Saadat Khan\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/758"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=758"}],"version-history":[{"count":2,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/758\/revisions"}],"predecessor-version":[{"id":763,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/758\/revisions\/763"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}