コード例 #1
0
  public void testGetAssociation() throws Exception {
    Class targetClass = Bride.class;
    Bride criteria = new Bride();
    criteria.setId(new Integer(1)); // A Bride with both a Mother- and Father-in-Law

    Object[] results = getQueryObjectResults(targetClass, criteria);

    assertNotNull(results);
    assertEquals(1, results.length);

    Bride result = (Bride) results[0];
    assertNotNull(result);
    assertNotNull(result.getId());
    assertNotNull(result.getName());

    Object[] fatherResults = getAssociationResults(result, "father", 0);
    assertEquals(1, fatherResults.length);
    InLaw fatherInLaw = (InLaw) fatherResults[0];
    assertNotNull(fatherInLaw);
    assertNotNull(fatherInLaw.getId());
    assertNotNull(fatherInLaw.getName());

    Object[] motherResults = getAssociationResults(result, "mother", 0);
    assertEquals(1, motherResults.length);
    InLaw motherInLaw = (InLaw) motherResults[0];
    assertNotNull(motherInLaw);
    assertNotNull(motherInLaw.getId());
    assertNotNull(motherInLaw.getName());
  }
コード例 #2
0
  /**
   * Uses Nested Search Criteria for search Verifies that the results are returned Verifies size of
   * the result set Verifies that none of the attribute is null
   *
   * @throws Exception
   */
  public void testEntireObjectNestedSearch1() throws Exception {
    Class targetClass = InLaw.class;
    InLaw criteria = new InLaw();

    Object[] results = getQueryObjectResults(targetClass, criteria);

    assertNotNull(results);
    assertEquals(4, results.length);

    for (Object obj : results) {
      InLaw result = (InLaw) obj;
      assertNotNull(result);
      assertNotNull(result.getId());
      assertNotNull(result.getName());
    }
  }