public void testGetTargetServiceItemByTargetId() throws DuplicateKeyException {
   assertDatabaseEmpty();
   saveTargetServiceItem(createTarget());
   TargetServiceItem tsi = hibernateTargetServiceItemDao.getAllTargetServiceItems().get(0);
   Target tgt = tsi.getTarget();
   assertEquals(
       "Solar Panel",
       hibernateTargetServiceItemDao
           .getAllTargetServiceItemByTarget(tgt.getId())
           .get(0)
           .getServiceItem()
           .getTargetName());
 }
 private Target createTarget(Account ac, String startDateStr, String endDateStr) {
   Target tgt = new Target();
   tgt.setAccount(ac);
   DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
   try {
     Date startDate = df.parse(startDateStr);
     Date endDate = df.parse(endDateStr);
     tgt.setStartDate(startDate);
     tgt.setEndDate(endDate);
     tgt.setCompletedDate(null);
     tgt.setTotalTargetCost(new BigDecimal("4500"));
   } catch (ParseException e) {
     e.printStackTrace();
   }
   return tgt;
 }