@Test
  public void testCustomConstraintValidatorFactory() {

    Configuration<?> configuration = Validation.byDefaultProvider().configure();
    assertDefaultBuilderAndFactory(configuration);

    ValidatorFactory factory = configuration.buildValidatorFactory();
    Validator validator = factory.getValidator();

    Customer customer = new Customer();
    customer.setFirstName("John");

    Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(customer);
    assertEquals(constraintViolations.size(), 1, "Wrong number of constraints");
    ConstraintViolation<Customer> constraintViolation = constraintViolations.iterator().next();
    assertEquals("may not be empty", constraintViolation.getMessage(), "Wrong message");

    // get a new factory using a custom configuration
    configuration = Validation.byDefaultProvider().configure();
    configuration.constraintValidatorFactory(
        new ConstraintValidatorFactory() {

          public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
            if (key == NotNullValidator.class) {
              return (T) new BadlyBehavedNotNullConstraintValidator();
            }
            return new ConstraintValidatorFactoryImpl().getInstance(key);
          }
        });
    factory = configuration.buildValidatorFactory();
    validator = factory.getValidator();
    constraintViolations = validator.validate(customer);
    assertEquals(constraintViolations.size(), 0, "Wrong number of constraints");
  }
Example #2
0
 private void customerNameChooserActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_customerNameChooserActionPerformed
   String name = (String) customerNameChooser.getSelectedItem();
   Customer c = null;
   customersWos = new ArrayList<>();
   for (Customer cu : customerList) {
     if (cu.getCustomerID().equals(customerMap.get(name))) {
       c = cu;
       currentCustomer = c;
     }
   }
   for (Vehicle v : vehicleList) {
     if (v.getCustomerID().equals(c)) {
       makeField1.setText(v.getMake());
       modelField1.setText(v.getModel());
       yearComboBox1.addItem(v.getYear());
       vinField1.setText(v.getVin());
       licenseField1.setText(v.getLicencePlate());
     }
   }
   woComboBox1.removeAllItems();
   woComboBox2.removeAllItems();
   CustomerIDField.setText(c.getCustomerID().toString());
   for (WorkOrder wo : workOrderList) {
     if (wo.getVehicleID().getCustomerID().equals(c)) {
       woComboBox1.addItem(wo.getOrderNo());
       woComboBox2.addItem(wo.getOrderNo());
       customersWos.add(wo);
     }
   }
 } // GEN-LAST:event_customerNameChooserActionPerformed
  private void prepareTestData() {

    car1 = newCar("Black", "0B6 6835", "Å koda", 200.0);
    car2 = newCar("Red", "7B4 0044", "BMW", 500.0);
    car3 = newCar("White", "8B5 0983", "Volkwagen", 300.0);

    customer1 = newCustomer("Vitalii", "Chepeliuk", "Komarov", "5-20-86", "AK 373979");
    customer2 = newCustomer("Juraj", "Kolchak", "Komarov", "5-34-86", "AK 372548");
    customer3 = newCustomer("Martin", "Jirman", "Lazhot", "5-25-87", "AK 251245");

    carManager.addCar(car1);
    carManager.addCar(car2);
    carManager.addCar(car3);

    customerManager.addCustomer(customer1);
    customerManager.addCustomer(customer2);
    customerManager.addCustomer(customer3);

    carWithoutID = newCar("Green", "8B3 9763", "Audi", 400.0);
    carNotInDB = newCar("Blue", "3B6 8463", "Peugeot", 0.0);
    carNotInDB.setID(car3.getID() + 100);

    customerWithoutID = newCustomer("Martin", "Pulec", "Brno", "5-11-24", "AK 897589");
    customerNotInDB = newCustomer("Lukas", "Rucka", "Brno", "5-21-06", "AK 256354");
    customerNotInDB.setID(customer3.getID() + 100);
    customerNotInDB.setActive(true);
  }
 private Customer getNewCustomerWithUniqueName() {
   Customer c1 = getCustomerComponent().createNew();
   c1.setName("A" + System.currentTimeMillis());
   c1.setPhoneNumber("808-555-1212");
   getCustomerComponent().persist(c1);
   return c1;
 }
 public void testGetTextValueByXPath() {
   Customer customer = new Customer();
   customer.setFirstName(CONTROL_CUSTOMER_FIRST_NAME);
   String testValue =
       xmlContext.getValueByXPath(customer, "personal-info/first-name/text()", null, String.class);
   assertEquals(CONTROL_CUSTOMER_FIRST_NAME, testValue);
 }
Example #6
0
  @Override
  public Result execute(InteractionContext ctx) throws InteractionException {
    assert (ctx != null);
    // retrieve from a database, etc.
    String id = ctx.getId();
    Customer customer = daoHibernate.getCustomer(id);
    if (customer != null) {
      // Convert Customer object into Entity object
      EntityProperties addressFields = new EntityProperties();
      addressFields.setProperty(
          new EntityProperty("postcode", customer.getAddress().getPostcode()));
      addressFields.setProperty(
          new EntityProperty("houseNumber", customer.getAddress().getHouseNumber()));

      EntityProperties props = new EntityProperties();
      props.setProperty(new EntityProperty("name", customer.getName()));
      props.setProperty(new EntityProperty("address", addressFields));
      props.setProperty(new EntityProperty("dateOfBirth", customer.getDateOfBirth()));
      Entity entity = new Entity("Customer", props);

      ctx.setResource(createEntityResource(entity));
      return Result.SUCCESS;
    } else {
      return Result.FAILURE;
    }
  }
Example #7
0
  /**
   * Queries the given customer's order with the given identity.
   *
   * @param alias the customer alias
   * @param passwordHash the customer password-hash
   * @param orderIdentity the order identity
   * @return the customer's order
   * @throws IllegalStateException if the login data is invalid
   * @throws SQLException if there is a problem with the underlying JDBC connection
   */
  public Order queryOrder(final String alias, final byte[] passwordHash, final long orderIdentity)
      throws SQLException {
    final Order order = new Order();
    final Customer customer = this.queryCustomer(alias, passwordHash);

    synchronized (this.connection) {
      try (PreparedStatement statement = this.connection.prepareStatement(SQL_SELECT_PURCHASE)) {
        statement.setLong(1, orderIdentity);

        try (ResultSet resultSet = statement.executeQuery()) {
          if (!resultSet.next()) throw new IllegalStateException("purchase doesn't exist.");
          if (customer.getIdentity() != resultSet.getLong("customerIdentity"))
            throw new IllegalStateException("purchase not created by given customer.");

          order.setIdentity(resultSet.getLong("identity"));
          order.setCustomerIdentity(resultSet.getLong("customerIdentity"));
          order.setCreationTimestamp(resultSet.getLong("creationTimestamp"));
          order.setTaxRate(resultSet.getDouble("taxRate"));
        }
      }
    }

    this.populateOrderItems(order);
    return order;
  }
Example #8
0
  /**
   * Returns the customer data.
   *
   * @param alias the customer alias
   * @param passwordHash the customer password-hash
   * @return the customer
   * @throws IllegalStateException if the login data is invalid
   * @throws SQLException if there is a problem with the underlying JDBC connection
   */
  public Customer queryCustomer(final String alias, final byte[] passwordHash) throws SQLException {
    final Customer customer = new Customer();

    synchronized (this.connection) {
      try (PreparedStatement statement = this.connection.prepareStatement(SQL_SELECT_CUSTOMER)) {
        statement.setString(1, alias);
        statement.setBytes(2, passwordHash);

        try (ResultSet resultSet = statement.executeQuery()) {
          if (!resultSet.next()) throw new IllegalStateException("customer doesn't exist.");
          customer.setIdentity(resultSet.getLong("identity"));
          customer.setAlias(resultSet.getString("alias"));
          customer.setGivenName(resultSet.getString("givenName"));
          customer.setFamilyName(resultSet.getString("familyName"));
          customer.setStreet(resultSet.getString("street"));
          customer.setPostcode(resultSet.getString("postcode"));
          customer.setCity(resultSet.getString("city"));
          customer.setEmail(resultSet.getString("email"));
          customer.setPhone(resultSet.getString("phone"));
        }
      }
    }

    return customer;
  }
Example #9
0
  public void deposit(String accountNum, String depositAmount) {
    // actually deposits the appropriate amount into the account

    double deposit =
        Double.parseDouble(
            depositAmount); // the balance in the Account class is saved as a double so it must be
                            // converted here
    boolean accountFound = customer.addMoney(deposit, accountNum);

    if (accountFound == true) {
      // create the log file
      timestamp = date.getTime();
      String customerID = customer.returnID();
      AdminLog newTransaction =
          new AdminLog(timestamp, transaction_counter, customerID, accountNum, deposit);
      adminLogs.add(newTransaction);

      transaction_counter++;
      add_interest();
      String infoMessage = customer.builderToString();
      jf.displayInfo(infoMessage);
      try {
        saveFile(cust, DBfile);
        saveFile(adminLogs, logFile);
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      jf.errorMessage(
          "We cannot find that account number in our database"); // pops up an error message if the
                                                                 // account was not found
    }
    customer = null; // resets the customer and account after each transaction
    pin = null;
  }
Example #10
0
  public void open_account(boolean save) {
    // actually opens the account
    customer.addAccount(
        starting_account_number,
        save); // addAccount will create a new account based on whether it is savings/checkings

    StringBuilder text = new StringBuilder();
    text.append("<html>Account created!<br>");
    String result = customer.returnInfo();
    String subResult = result.substring(6);
    text.append(subResult);
    String infoText = text.toString();
    jf.displayInfo(infoText);

    transaction_counter++;
    add_interest();
    try {
      saveFile(cust, DBfile);
      saveFile(adminLogs, logFile);
    } catch (IOException e) {
      e.printStackTrace();
    }
    customer = null; // resets the customer and account after each transaction
    pin = null;
  }
Example #11
0
  public void printAllAccounts(String customerID) {
    // Sorts the customer based on ID, then prints the accounts information

    // change the withdrawal funcitons and deposit functions too
    ajf.dispose();
    ajf = new AdminRunningFrame(this);

    Collections.sort(cust, Customer.CompareIDs);
    String searchString = ajf.getCustomerID();

    StringBuilder stringResults = new StringBuilder();
    String header = header();
    stringResults.append(header);
    for (Customer customer : cust) {
      String id = customer.returnID();
      String name = customer.getName().toUpperCase();
      String pin = customer.returnPin();
      if (searchString.equals(id)) {
        ArrayList<Account> accounts = customer.getAccounts();
        if (!accounts.isEmpty()) {
          for (Account account : accounts) {
            if (account.checkActive()) {
              String accountNumber = account.returnNumber();
              double balance = account.returnBalance();
              String balanceAsString = formatter.format(balance);
              String customerInfo = printAdminInfo(name, id, accountNumber, pin, balanceAsString);
              stringResults.append(customerInfo);
            }
          }
        }
      }
    }
    String resultsAsString = stringResults.toString();
    ajf.printInfo(resultsAsString);
  }
  /**
   * Test case to show the usage of the geo-spatial APIs to lookup people within a given distance of
   * a reference point.
   */
  @Test
  public void exposesGeoSpatialFunctionality() {

    GeospatialIndex indexDefinition = new GeospatialIndex("address.location");
    indexDefinition.getIndexOptions().put("min", -180);
    indexDefinition.getIndexOptions().put("max", 180);

    operations.indexOps(Customer.class).ensureIndex(indexDefinition);

    Customer ollie = new Customer("Oliver", "Gierke");
    ollie.setAddress(new Address(new Point(52.52548, 13.41477)));
    ollie = repository.save(ollie);

    Point referenceLocation = new Point(52.51790, 13.41239);
    Distance oneKilometer = new Distance(1, Metrics.KILOMETERS);

    GeoResults<Customer> result =
        repository.findByAddressLocationNear(referenceLocation, oneKilometer);

    assertThat(result.getContent(), hasSize(1));

    Distance distanceToFirstStore = result.getContent().get(0).getDistance();
    assertThat(distanceToFirstStore.getMetric(), is(Metrics.KILOMETERS));
    assertThat(distanceToFirstStore.getValue(), closeTo(0.862, 0.001));
  }
Example #13
0
  public static void main(String[] args) {
    TravelOffice travelOffice = new TravelOffice();
    travelOffice.addTrip(new Trip());
    travelOffice.addTrip(new AbroadTrip());
    travelOffice.displayTrips();

    Customer test1 = new Customer();
    test1.setName("test1");
    test1.setNip("123");
    test1.setMail("EMAIL BITCH");
    test1.setNewsletterAccepted(true);
    Customer test2 = new Customer();
    test2.setName("test2");
    test2.setNip("234");
    test2.setMail("WA WA WEE WA");
    test2.setNewsletterAccepted(true);

    Trip trip1 = new Trip();
    Trip trip2 = new Trip();
    Trip trip3 = new Trip();

    travelOffice.addTrip(trip1);
    travelOffice.addTrip(trip2);
    travelOffice.addTrip(trip3);

    travelOffice.addCustomer(test1);
    travelOffice.addCustomer(test2);

    travelOffice.saveCustomers();
    travelOffice.displayCustomers();
    travelOffice.displayTrips();

    travelOffice.sendNewsletter();
  }
Example #14
0
  @Test
  public void onCustomer() {
    Result<Customer> customerResult =
        gateway.customer().create(new CustomerRequest().paymentMethodNonce(Nonce.Coinbase));
    assertTrue(customerResult.isSuccess());
    Customer customer = customerResult.getTarget();

    List<CoinbaseAccount> accounts =
        gateway.customer().find(customer.getId()).getCoinbaseAccounts();
    assertEquals(1, accounts.size());

    CoinbaseAccount account = accounts.get(0);
    assertNotNull(account);
    assertNotNull(account.getToken());
    assertNotNull(account.getUserId());
    assertThat(account.getUserId(), not(equalTo("")));
    assertNotNull(account.getUserName());
    assertThat(account.getUserName(), not(equalTo("")));
    assertNotNull(account.getUserEmail());
    assertThat(account.getUserEmail(), not(equalTo("")));

    String token = account.getToken();

    gateway.paymentMethod().delete(token);

    exception.expect(NotFoundException.class);
    gateway.paymentMethod().find(token);
  }
Example #15
0
  public List<Machine> getCustomerMachinesList(Customer cust) {
    try {
      ResultSet rs =
          executeQuery(
              "SELECT machines.* FROM customers JOIN machines ON customers.id=cid AND cid="
                  + cust.getId()
                  + ";");

      List list = new ArrayList();
      while (rs.next()) {
        MachineData machData = new MachineData();
        int id = rs.getInt(1);
        for (int i = 0; i < MachineData.fieldsName.length; i++) {
          String fieldValue = rs.getString(MachineData.fieldsName[i]);
          machData.updateByFieldName(MachineData.fieldsName[i], fieldValue);
        }
        Machine mach = new Machine(machData);
        mach.setId(id);
        mach.setCid(cust.getId());
        list.add(mach);
      }

      return list;
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return null;
  }
Example #16
0
  /** Hibernate Test class */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    // Session session = HibernateUtil.currentSession();
    Session session = HibernateSessionFactory.getSession();
    session.beginTransaction();
    // create query object
    Query query = session.createQuery("from Customer");
    // create customer list
    List<Customer> list = query.list();

    Customer cus = null;

    if (list != null && list.size() > 0) {
      /*for(int i = 0;i<list.size();i++){
      	cus = (Customer)list.get(i);
      	System.out.println("" +
      			"+i= " + i + "ID = "+ cus.getId()+
      			"name = "+ cus.getName()+"Age = " +cus.getAge());
      }*/
      for (Customer customer : list) {
        cus = customer;
        System.out.println(
            "ID = " + cus.getId() + " name = " + cus.getName() + " Age = " + cus.getAge());
      }
    }

    session.beginTransaction().commit(); // submit
  }
  @Test
  public void updateCreditCardFromTransparentRedirect() {
    Customer customer = gateway.customer().create(new CustomerRequest()).getTarget();
    CreditCardRequest request =
        new CreditCardRequest()
            .customerId(customer.getId())
            .number("5105105105105100")
            .expirationDate("05/12");
    CreditCard card = gateway.creditCard().create(request).getTarget();

    CreditCardRequest updateRequest = new CreditCardRequest();
    CreditCardRequest trParams =
        new CreditCardRequest()
            .paymentMethodToken(card.getToken())
            .number("4111111111111111")
            .expirationDate("10/10");
    String queryString =
        TestHelper.simulateFormPostForTR(
            gateway, trParams, updateRequest, gateway.transparentRedirect().url());

    Result<CreditCard> result = gateway.transparentRedirect().confirmCreditCard(queryString);

    assertTrue(result.isSuccess());
    CreditCard updatedCreditCard = gateway.creditCard().find(card.getToken());
    assertEquals("411111", updatedCreditCard.getBin());
    assertEquals("1111", updatedCreditCard.getLast4());
    assertEquals("10/2010", updatedCreditCard.getExpirationDate());
  }
Example #18
0
  public void withdraw(String withdrawAmount, String accountNum) {
    // actually performs the withdrawal service
    double withdrawal = Double.parseDouble(withdrawAmount);
    boolean accountFound = customer.removeMoney(withdrawal, accountNum);
    if (accountFound == true) {
      // creates the log file
      double logAmount = -withdrawal;
      timestamp = date.getTime();
      String customerID = customer.returnID();
      AdminLog newTransaction =
          new AdminLog(timestamp, transaction_counter, customerID, accountNum, logAmount);
      adminLogs.add(newTransaction);

      transaction_counter++;
      add_interest();
      String infoMessage = customer.builderToString();
      jf.displayInfo(infoMessage);

      try {
        saveFile(cust, DBfile);
        saveFile(adminLogs, logFile);
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      jf.errorMessage(
          "We cannot find that account number in our database"); // pops up an error message if the
                                                                 // account was not found
    }
    customer = null; // resets the customer and account after each transaction
    pin = null;
  }
Example #19
0
  /**
   * Cancels an order. Note that cancel requests for orders will be rejected if they are older than
   * one hour, or don't target the given customer.
   *
   * @param alias the customer alias
   * @param passwordHash the customer password-hash
   * @param orderIdentity the order identity
   * @throws IllegalStateException if the login data is invalid, if the order is too old, or if it
   *     is not targeting the given customer
   * @throws SQLException if there is a problem with the underlying JDBC connection
   */
  public void deleteOrder(final String alias, final byte[] passwordHash, final long orderIdentity)
      throws SQLException {
    final Customer customer = this.queryCustomer(alias, passwordHash);
    final Order order = this.queryOrder(alias, passwordHash, orderIdentity);
    if (order.getCustomerIdentity() != customer.getIdentity())
      throw new IllegalStateException("purchase not created by given customer.");
    if (System.currentTimeMillis() > order.getCreationTimestamp() + TimeUnit.HOURS.toMillis(1))
      throw new IllegalStateException("purchase too old.");

    synchronized (this.connection) {
      try (PreparedStatement statement = this.connection.prepareStatement(SQL_DELETE_PURCHASE)) {
        statement.setLong(1, orderIdentity);
        statement.executeUpdate();
      }
    }

    for (final OrderItem item : order.getItems()) {
      synchronized (this.connection) {
        try (PreparedStatement statement =
            this.connection.prepareStatement(SQL_RELEASE_ARTICLE_UNITS)) {
          statement.setLong(1, item.getCount());
          statement.setLong(2, item.getArticleIdentity());
          statement.executeUpdate();
        }
      }
    }
  }
  @Test
  public void testBasicExpectedBehavior() {
    Session session = getNewSession("jboss");
    session.beginTransaction();
    Customer steve = new Customer(1L, "steve");
    session.save(steve);
    session.getTransaction().commit();
    session.close();

    session = getNewSession("acme");
    try {
      session.beginTransaction();
      Customer check = (Customer) session.get(Customer.class, steve.getId());
      Assert.assertNull("tenancy not properly isolated", check);
    } finally {
      session.getTransaction().commit();
      session.close();
    }

    session = getNewSession("jboss");
    session.beginTransaction();
    session.delete(steve);
    session.getTransaction().commit();
    session.close();
  }
Example #21
0
  /**
   * Queries the given customer's orders.
   *
   * @param alias the customer alias
   * @param passwordHash the customer password-hash
   * @return the customer's orders
   * @throws IllegalStateException if the login data is invalid
   * @throws SQLException if there is a problem with the underlying JDBC connection
   */
  public SortedSet<Order> queryOrders(final String alias, final byte[] passwordHash)
      throws SQLException {
    final SortedSet<Order> orders = new TreeSet<Order>();
    final Customer customer = this.queryCustomer(alias, passwordHash);

    synchronized (this.connection) {
      try (PreparedStatement statement = this.connection.prepareStatement(SQL_SELECT_PURCHASES)) {
        statement.setLong(1, customer.getIdentity());

        try (ResultSet resultSet = statement.executeQuery()) {
          while (resultSet.next()) {
            final Order purchase = new Order();
            purchase.setIdentity(resultSet.getLong("identity"));
            purchase.setCustomerIdentity(resultSet.getLong("customerIdentity"));
            purchase.setCreationTimestamp(resultSet.getLong("creationTimestamp"));
            purchase.setTaxRate(resultSet.getDouble("taxRate"));
            orders.add(purchase);
          }
        }
      }
    }

    for (final Order purchase : orders) {
      this.populateOrderItems(purchase);
    }

    return orders;
  }
  /**
   * Get a customer by id
   *
   * @param id customer id
   * @return a customer
   */
  public Customer getACustomer(int id) {
    String sql = "Select * From Customer where cid = ?";

    try {

      PreparedStatement statement = (PreparedStatement) connection.prepareStatement(sql);
      statement.setInt(1, id);
      ResultSet rs = statement.executeQuery();

      if (rs.next()) {
        Customer customer = new Customer();
        customer.setEmail(rs.getString("email"));
        customer.setFirstName(rs.getString("firstName"));
        customer.setLastName(rs.getString("lastName"));
        customer.setId(rs.getInt("cid"));

        if (statement != null) statement.close();

        return customer;
      } else {
        return null;
      }

    } catch (SQLException e) {
      e.printStackTrace();
      System.out.println("Error at get a customer");
      return null;
    }
  }
 public void testSetCollectionValueByXPath() {
   Customer customer = new Customer();
   List<PhoneNumber> phoneNumbers = new ArrayList<PhoneNumber>(1);
   phoneNumbers.add(new PhoneNumber());
   xmlContext.setValueByXPath(customer, "contact-info/phone-number/", null, phoneNumbers);
   assertSame(customer.getPhoneNumbers(), phoneNumbers);
 }
Example #24
0
  void SaveSale() {

    if (!ValidateSaveSale()) {
      ShowErrorSaveSale();
      return;
    }

    // Header
    SaleHeader saleHeader = new SaleHeader(0, customer.getId_customer());
    saleHeader.setCustomer_name(customer.getName());
    saleHeader.setTotal(totalSale);
    saleHeader.setId_payment_type(GetIdPaymentTypes());
    saleHeader.setDate_sale(new Date());

    // Details
    for (int i = 0; i < productAdapter.getCount(); i++) {
      Product product = productAdapter.getItem(i);

      SaleDetail saleDetail = new SaleDetail(0, 0);
      saleDetail.setId_product(product.getId_product());
      saleDetail.setProduct_name(product.getName());
      saleDetail.setProduct_price(product.getPrice());
      saleHeader.addDetail(saleDetail);
    }

    saleHeaderHelper.InsertWithDetails(saleHeader);
    ResetGUI();
  }
Example #25
0
  public static ArrayList<Customer> getAllCustomers() {
    ArrayList<Customer> list = new ArrayList<Customer>();

    DBHelper db = new DBHelper();

    try {
      String queryString = "SELECT * FROM customer";
      ResultSet rs = db.executeQuery(queryString);

      while (rs.next()) {
        Customer customer = new Customer();

        customer.setId(rs.getInt("id"));
        customer.setFirstName(rs.getString("first_name"));
        customer.setLastName(rs.getString("last_name"));
        customer.setPhone(rs.getString("phone"));
        customer.setAddress(rs.getString("address"));
        customer.setZipCode(rs.getInt("zipcode"));
        customer.setCity(rs.getString("city"));
        customer.setEmail(rs.getString("email"));
        customer.setPassword(rs.getString("password"));

        list.add(customer);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    db.close();

    return list;
  }
  public void AddCustomer() {
    Customer customer =
        new Customer(
            txtUsername.getText(),
            txtPassword.getText(),
            txtFirstName.getText(),
            txtLastName.getText(),
            txtEmail.getText(),
            txtPhone.getText(),
            txtStreet1.getText(),
            txtStreet2.getText(),
            txtCity.getText(),
            txtState.getText(),
            txtZipcode.getText(),
            txtCountry.getText());
    customer.setIsActive(chkActive.isSelected());

    customer.setID(CustomerID);
    if (CustomerBL.UpdateCustomer(GetPU(), customer)) {
      JOptionPane.showMessageDialog(null, "Customer updated successfully.");
      com.omazan.Mobile.GUI.frmMain.ApplicationForm.ShowListCustomerDialog();
    } else {
      JOptionPane.showMessageDialog(null, "Could not update customer.");
    }
  }
  @Test
  public void getAllCustomerCars() {
    assertFalse(customer1.getActive());
    assertFalse(customer2.getActive());
    assertFalse(customer3.getActive());

    manager.rentCarToCustomer(
        car2, customer1, Date.valueOf("2012-03-21"), Date.valueOf("2012-03-31"));
    manager.rentCarToCustomer(
        car3, customer1, Date.valueOf("2012-03-25"), Date.valueOf("2012-04-02"));
    manager.rentCarToCustomer(
        car1, customer2, Date.valueOf("2012-03-15"), Date.valueOf("2012-03-27"));

    List<Car> carsRetnedtoCustomer1 = Arrays.asList(car2, car3);
    List<Car> carsRetnedtoCustomer2 = Arrays.asList(car1);

    assertCarDeepEquals(carsRetnedtoCustomer1, manager.getAllCustomerCars(customer1));
    assertCarDeepEquals(carsRetnedtoCustomer2, manager.getAllCustomerCars(customer2));
    assertFalse(customer3.getActive());

    try {
      manager.getAllCustomerCars(null);
      fail();
    } catch (IllegalArgumentException e) {
    }

    try {
      manager.getAllCustomerCars(customerWithoutID);
      fail();
    } catch (IllegalArgumentException e) {
    }
  }
  /**
   * searches all registry lists for a specific keyword and returns all matches in a a list
   *
   * <p>function is obsolete since 1.19
   *
   * @param req the "search keyword"
   * @return list of matching objects
   */
  public ArrayList<Object> search(String req) {
    ArrayList<Object> returnValues = new ArrayList<Object>();

    for (Customer c : getCustomers().values()) {
      if (c.getName().contains(req)
          || c.getAddress().contains(req)
          || c.getCivic().contains(req)
          || c.getPhone().contains(req)) {
        returnValues.add(c);
      }
    }

    for (Item i : getItems().values()) {
      if (i.getName().contains(req) || i.getPrice().contains(req) || i.getDetails().contains(req)) {
        returnValues.add(i);
      }
    }

    for (Order i : getOrders().values()) {
      if (i.getOrderNo().contains(req) || i.getCustomer().getName().contains(req)) {
        returnValues.add(i);
      }
    }
    return returnValues;
  }
 @Override
 public Customer findCustomerById(long customerId) {
   Customer customer = customerRepository.findOne(customerId);
   if (null == customer) throw new CustomerNotFoundException(customerId);
   Hibernate.initialize(customer.getUser());
   return customer;
 }
 public Customer mapRow(ResultSet rs, int rowNum) throws SQLException {
   Customer customer = new Customer();
   customer.setCustId(rs.getInt("CUST_ID"));
   customer.setName(rs.getString("NAME"));
   customer.setAge(rs.getInt("AGE"));
   return customer;
 }