Package er.erxtest.model

Examples of er.erxtest.model.Employee


      // No employees
      Integer count = ERXEOControlUtilities.objectCountForToManyRelationship(c, Company.EMPLOYEES_KEY);
      assertEquals(0, count.intValue());
     
      @SuppressWarnings("unused")
      Employee e1 = c.createEmployeesRelationship();
      @SuppressWarnings("unused")
      Employee e2 = c.createEmployeesRelationship();
      @SuppressWarnings("unused")
      Employee e3 = c.createEmployeesRelationship();
      // Expecting a new object for this call
      assertTrue(ERXEOControlUtilities.isNewObject(c));
      count = ERXEOControlUtilities.objectCountForToManyRelationship(c, Company.EMPLOYEES_KEY);
      assertEquals(3, count.intValue());
View Full Code Here


    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      Company c = (Company) ec.faultForGlobalID(cGid, ec);
      // Add a new item to employees relationship
      @SuppressWarnings("unused")
      Employee e4 = c.createEmployeesRelationship();
      // I expect relationship to NOT be a fault
      Object relationshipValue = c.storedValueForKey(Company.EMPLOYEES_KEY);
      assertFalse(EOFaultHandler.isFault(relationshipValue));
      Integer count = ERXEOControlUtilities.objectCountForToManyRelationship(c, Company.EMPLOYEES_KEY);
View Full Code Here

      } 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(
            "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());
      }

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

      // Test failure where key is to-one fault
      ec.revert();
      ec.invalidateAllObjects();

      e = (Employee) ec.faultForGlobalID(eGid, ec);
      assertTrue(EOFaultHandler.isFault(e.storedValueForKey(Employee.COMPANY_KEY)));
      try {
        // Company is a to-one fault
        count = ERXEOControlUtilities.objectCountForToManyRelationship(e, Employee.COMPANY_KEY);
      } catch (IllegalArgumentException exception) {
        assertEquals(
View Full Code Here

TOP

Related Classes of er.erxtest.model.Employee

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.