private TargetServiceItem getTargetServiceItem(Target target) throws DuplicateKeyException {
   TargetServiceItem tsi = new TargetServiceItem();
   ServiceItem si = saveAndGetServiceItem("Solar Panel", "32000", 1);
   tsi.setAmount(si.getAmount());
   tsi.setServiceItem(si);
   tsi.setTarget(target);
   tsi.setServiceItemQty(1);
   return tsi;
 }
 private void saveTargetServiceItem(Target target) throws DuplicateKeyException {
   TargetServiceItem tsi = new TargetServiceItem();
   ServiceItem si = saveAndGetServiceItem("Solar Panel", "32000", 1);
   tsi.setAmount(si.getAmount());
   tsi.setServiceItem(si);
   tsi.setTarget(target);
   tsi.setServiceItemQty(1);
   hibernateTargetServiceItemDao.saveTargetServiceItem(tsi);
   assertEquals(1, hibernateTargetServiceItemDao.getAllTargetServiceItems().size());
 }
 public void testUpdateTargetServiceItem() throws DuplicateKeyException {
   assertDatabaseEmpty();
   saveTargetServiceItem(createTarget());
   TargetServiceItem tsi = hibernateTargetServiceItemDao.getAllTargetServiceItems().get(0);
   assertEquals(
       1, hibernateTargetServiceItemDao.getAllTargetServiceItems().get(0).getServiceItemQty());
   tsi.setServiceItemQty(13);
   hibernateTargetServiceItemDao.updateTargetServiceItem(tsi);
   assertEquals(
       13, hibernateTargetServiceItemDao.getAllTargetServiceItems().get(0).getServiceItemQty());
 }
 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());
 }
  protected Object getRow(Client client) {
    Object row = ui.createTableRow(client);

    ui.add(row, ui.createTableCell(client.getFullName()));
    ui.add(row, ui.createTableCell(client.getPhoneNumber()));

    String neededitems = "";

    for (TargetServiceItem tsi : reviewHandler.getSelectedServiceItems()) {
      if (neededitems.length() == 0) {
        neededitems = tsi.getServiceItem().getTargetName();
      } else {
        neededitems = neededitems + ", " + tsi.getServiceItem().getTargetName();
      }
    }

    ui.add(row, ui.createTableCell(neededitems));
    return addCustomData(client, row);
  }