Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOGlobalID


   */
  public void testObjectCountForToManyRelationship_Snapshot() {
    // Make no assumptions about state of stack or if OSC pool active
    EOObjectStoreCoordinator osc = new EOObjectStoreCoordinator();
    // Setup
    EOGlobalID cGid = ERXTestUtilities.createCompanyAnd3Employees();
    EOGlobalID cGid0 = ERXTestUtilities.createCompanyAndNoEmployees();
   
    EOEditingContext ec1 = ERXEC.newEditingContext(osc);
    EOEditingContext ec2 = ERXEC.newEditingContext(osc);
   
    // Fetch again into this ec to ensure snapshots are in the database
View Full Code Here


   * <li> A snapshot array does not exist.
   * <li> The count is done in the database
   */
  public void testObjectCountForToManyRelationship_DatabaseCount() {
    // Setup
    EOGlobalID cGid = ERXTestUtilities.createCompanyAnd3Employees();

    // Virgin OSC with no snapshots
    EOObjectStoreCoordinator osc = new EOObjectStoreCoordinator();
    EOEditingContext ec1 = ERXEC.newEditingContext(osc);
    ec1.lock();
View Full Code Here

  /**
   * Test obvious invalid arguments.
   */
  public void testObjectCountForToManyRelationship_BadArgumentsFailure() {
    // Setup
    EOGlobalID cGid = ERXTestUtilities.createCompanyAnd3Employees();

    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {

      // Test using null eo
      Integer count;

      try {
        // Company is null
        count = ERXEOControlUtilities.objectCountForToManyRelationship(null, Employee.COMPANY_KEY);
      } catch (NullPointerException exception) {
        assertEquals("object argument cannot be null", exception.getMessage());
      }

      // Test using a key that is not a toMany on a new object
      Employee e = (Employee) EOUtilities.createAndInsertInstance(ec, Employee.ENTITY_NAME);

      try {
        // key is null
        count = ERXEOControlUtilities.objectCountForToManyRelationship(e, null);
      } catch (NullPointerException exception) {
        assertEquals("relationshipName argument cannot be null", exception.getMessage());
      }

      try {
        // Company is null
        count = ERXEOControlUtilities.objectCountForToManyRelationship(e, Employee.COMPANY_KEY);
      } catch (IllegalArgumentException exception) {
        assertEquals(
            "The attribute named 'company' in the entity named 'Employee' is not a toMany relationship! Expected an NSArray, but got null.",
            exception.getMessage());
      }

      Company c = (Company) EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME);
      e.setCompanyRelationship(c);

      try {
        // Company is not null
        count = ERXEOControlUtilities.objectCountForToManyRelationship(e, Employee.COMPANY_KEY);
      } catch (IllegalArgumentException exception) {
        assertEquals(
            "The attribute named 'company' in the entity named 'Employee' is not a toMany relationship! Expected an NSArray, but got a er.erxtest.model.Company",
            exception.getMessage());
      }

      // ----------------------------------------------------------
      // Test using a key that is not a toMany on an existing object

      c = (Company) ec.faultForGlobalID(cGid, ec);

      try {
        // address1 attribute is null
        count = ERXEOControlUtilities.objectCountForToManyRelationship(c, Company.ADDRESS1_KEY);
      } catch (IllegalArgumentException exception) {
        assertEquals(
            "The attribute named 'address1' in the entity named 'Company' is not a toMany relationship! Expected an NSArray, but got null.",
            exception.getMessage());
      }

      e = c.employees().objectAtIndex(0);

      EOGlobalID eGid = ec.globalIDForObject(e);
      try {
        // Company is not null
        count = ERXEOControlUtilities.objectCountForToManyRelationship(e, Employee.COMPANY_KEY);
      } catch (IllegalArgumentException exception) {
        assertEquals(
View Full Code Here

TOP

Related Classes of com.webobjects.eocontrol.EOGlobalID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.