protected void buildExpectedResults() {
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(Employee.class);

    Vector employees = (Vector) getSession().executeQuery(query);
    Vector distinctEmployees = new Vector();

    // initialize distinctEmployees
    distinctEmployees.addElement(employees.elementAt(0));

    // check employees with duplicate province and add only distinct employees to distinctEmployees
    for (int i = 1; i < employees.size(); i++) {
      boolean duplicateFound = false;

      // iterate through distinctEmployees to check for duplicate provinces, if found, employee not
      // added
      for (int j = 0; j < distinctEmployees.size(); j++) {
        if ((((Employee) employees.elementAt(i)).getAddress().getProvince())
            .equals((((Employee) distinctEmployees.elementAt(j)).getAddress().getProvince()))) {
          duplicateFound = true;
        }
      }
      if (!duplicateFound) {
        distinctEmployees.addElement(employees.elementAt(i));
      }
    }

    for (Enumeration e = distinctEmployees.elements(); e.hasMoreElements(); ) {
      Employee emp = (Employee) e.nextElement();
      Object[] result = new Object[1];
      result[0] = emp.getAddress().getProvince();
      addResult(result, null);
    }
  }
Exemplo n.º 2
0
  protected void verify() {
    if (!employee.getAddress().getCity().equals("null")) {
      throw new TestErrorException("Null value not converted correctly for string.");
    }

    if (employee.getSalary() != -1) {
      throw new TestErrorException("Null value not converted correctly for int.");
    }
  }
 public void setup() {
   super.setup();
   ExpressionBuilder employees = new ExpressionBuilder();
   expression = employees.get("firstName").equal("Charles");
   expression = expression.and(employees.get("lastName").equal("Chanley"));
   // ensure our employee is in one of the distributed caches
   DistributedServer server =
       (DistributedServer) DistributedServersModel.getDistributedServers().get(0);
   Object result = server.getDistributedSession().readObject(Employee.class, expression);
   ((Employee) result).getManagedEmployees();
   ((Employee) result).getPhoneNumbers();
   ((Employee) result).getAddress();
   ((Employee) result).getManager();
   ((Employee) result).getProjects();
   ((Employee) result).getResponsibilitiesList();
 }
 protected void changeObject() {
   Employee employee = (Employee) this.workingCopy;
   // Direct to field
   employee.setFirstName(new String(employee.getFirstName().getBytes()));
   // Object type
   employee.setGender(new String(employee.getGender().getBytes()));
   // Transformation
   employee.setNormalHours(employee.getNormalHours().clone());
   // Aggregate
   employee.setPeriod(
       new EmploymentPeriod(
           employee.getPeriod().getStartDate(), employee.getPeriod().getEndDate()));
   // One to many private/public
   employee.setPhoneNumbers((Vector) employee.getPhoneNumbers().clone());
   employee.setProjects((Vector) employee.getProjects().clone());
   employee.setManagedEmployees((Vector) employee.getManagedEmployees().clone());
   // Direct collection
   employee.setResponsibilitiesList((Vector) employee.getResponsibilitiesList().clone());
   // One to one private/public
   employee.getAddress();
   employee.getManager();
 }