{"id":1010,"date":"2013-04-29T09:26:50","date_gmt":"2013-04-29T15:26:50","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=1010"},"modified":"2014-09-13T08:40:23","modified_gmt":"2014-09-13T14:40:23","slug":"testing-with-pentaho-kettle-your-logic","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/1010","title":{"rendered":"Testing with Pentaho Kettle &#8211; business logic"},"content":{"rendered":"<p>So, the first step in building the test harness is to create a skeleton of the transformations we will need to run.\u00a0 These transforms contain the business logic of your ETL process.<\/p>\n<p>Pssssst. This article is part of a series. \u00a0Previous posts covered:<\/p>\n<ul>\n<li>The\u00a0<a href=\"\/wordpress\/archives\/995\">benefits of automated testing for ETL jobs<\/a><\/li>\n<li><a href=\"\/wordpress\/archives\/1031\">what parts of ETL processes to test<\/a><\/li>\n<li><a href=\"\/wordpress\/archives\/1026\">current options and frameworks for testing Kettle<\/a><\/li>\n<\/ul>\n<p>Typically, I find that my processing jobs break down into 4 parts:<\/p>\n<ul>\n<li>setup (typically job entries)<\/li>\n<li>loading data to a stream (extract)<\/li>\n<li>processing that data (transform)<\/li>\n<li>saving that data to a persistent datastore (load)<\/li>\n<\/ul>\n<p>Often, I combine the last two steps into a single transformation.<\/p>\n<p>So, for this sample project (final code is <a href=\"https:\/\/github.com\/mooreds\/pentaho-kettle-testing\/\">here<\/a>), we will create a couple of transformations containing business logic.\u00a0 (All transformations are built using Spoon on Windows with Pentaho Data Integration version 4.4.0.)<\/p>\n<p>The business needs to greet people appropriately, so our job will take a list of names and output that same list with a greeting customized for each person. \u00a0This is the logic we are going to be testing.<\/p>\n<p>First, the skeleton of the code that takes our input data and adds a greeting.\u00a0 This transformation is called &#8216;Greet The World&#8217;.<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1011\" alt=\"pentaho-basic-logic-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I also created a &#8216;Load People to Greet&#8217; transformation that is just a <a href=\"http:\/\/wiki.pentaho.com\/display\/EAI\/Text+File+Input\">text file input<\/a> step and a <a href=\"http:\/\/wiki.pentaho.com\/display\/EAI\/Copy+rows+to+result\">copy rows to results<\/a> step.<a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-load-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1023\" alt=\"pentaho-basic-logic-load-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-load-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-load-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-load-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-load-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The last piece you can see in this is the &#8216;GreetFolks&#8217; job which merely strings together these two transformations.\u00a0 This would be the real job that would be run regularly to serve the business&#8217; needs.<\/p>\n<p><a href=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-job-75.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1022\" alt=\"pentaho-basic-logic-job-75\" src=\"http:\/\/www.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-job-75-300x168.png\" width=\"300\" height=\"168\" srcset=\"http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-job-75-300x168.png 300w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-job-75-1024x575.png 1024w, http:\/\/edit.mooreds.com\/wordpress\/wp-content\/uploads\/2013\/04\/pentaho-basic-logic-job-75.png 1025w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This logic is not complicated, but could grow to be quite complex.\u00a0 Depending on the data we are being passed in, we could grow the logic in the &#8216;Greet The World&#8217; transformation to be quite complex&#8211;the variety of greetings could depend on the time of year, any special holidays happening, the gender or age or occupation of the person, etc, etc.<\/p>\n<p>Astute observers may note that I didn&#8217;t write a test first.\u00a0 The reason for this is that getting the test harness right before you write these skeletons is hard.\u00a0 It&#8217;s easier to write the simplest skeleton, add a test to it, and then for <strong>all<\/strong> future development, right a failing test first.<\/p>\n<p>As a reminder, I&#8217;ll be publishing another installment of this tutorial in a couple of days.\u00a0 But if you can&#8217;t wait, the full code is on <a href=\"https:\/\/github.com\/mooreds\/pentaho-kettle-testing\">github<\/a>.<\/p>\n<p>Signup for my <a href=\"http:\/\/eepurl.com\/x2Biz\">infrequent emails about pentaho testing<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, the first step in building the test harness is to create a skeleton of the transformations we will need to run.\u00a0 These transforms contain the business logic of your [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63,6,58],"tags":[],"class_list":["post-1010","post","type-post","status-publish","format-standard","hentry","category-pentaho-data-integration","category-programming","category-testing"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1010"}],"version-history":[{"count":22,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1010\/revisions"}],"predecessor-version":[{"id":1752,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/1010\/revisions\/1752"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}