title: What do I do about database loading with Cucumber JVM/JUnit
body: <p>I want to use a feature file with cucumber jvm that will hold the data for the test.</p>
  
  <ul>
  <li><p>I am testing a method that uses hibernate to load an object before processing.</p>
  
  <pre><code>public Deal getDealById(Long dealId) {
     deal = template.get(Deal.class, dealId);
     BigDecimal totalAmount = new BigDecimal();
     //loop through all of the loans related to this deal to add up a value
     for (Loan tempLoan: deal.loanList) {
         //add amount from each loan together
         BigDecimal totalAmount = totalAmount + tempLoan.amount;
     }
     //set the total amount value on the deal object
     deal.setTotalAmount(totalAmount);
     return deal;
  }
  </code></pre></li>
  </ul>
  
  <p>What do I do about the loading since I have to specify a dealId to load?</p>
  
  <p>My understanding is that I need to "mock" the connection and the object resulting from the mocked connection.</p>
  
  <p>I have looked at Jmock, mockito and dbunit respectively, but I don't understand what to do.</p>
  
  <p>I would appreciate any input.</p>
  
  <p><em><strong>EDIT NOTES</em></strong></p>
  
  <p>I added more code, we are retrieving an object from the database.  Next, we are looping through a list of objects related to the deal (many to one) and adding the amount of each loan to the deal amount.  Finally, we set the total amount on the deal before returning the deal.</p>
  
  <p>So how can I write a Junit test for this method considering I want to supply test information from a feature file?  </p>
  
  <p>In a "real" scenario this works, we load the deal in our application and add the loan amounts of each loan and set it onto the deal before returning it.  But I don't understand how to write a JUnit for this test considering we have to load from the database inside this method.</p>