Package er.erxtest.model

Examples of er.erxtest.model.Employee


        Company c = (Company) EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME);
        c.setName("Name");
        ec.saveChanges();
        EOEditingContext nested = ERXEC.newEditingContext(ec);
        Company nestC = c.localInstanceIn(nested);
        Employee e = (Employee) EOUtilities.createAndInsertInstance(nested, Employee.ENTITY_NAME);
        e.setFirstName("First");
        e.setLastName("Last");
        e.setManager(Boolean.FALSE);
        e.addObjectToBothSidesOfRelationshipWithKey(nestC, Employee.COMPANY_KEY);
        nested.saveChanges();
        ec.saveChanges();
        System.gc();
        c.delete();
        ec.saveChanges();
      } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
      }
    }
View Full Code Here


  }
 
  public void testSnapshot() {
    EOEditingContext ec = ERXEC.newEditingContext();
    Company company = Company.createCompany(ec, "Test Company");
    Employee employee = Employee.createEmployee(ec, "John", "Doe", Boolean.FALSE, company);
    Role role1 = Role.createRole(ec);
    employee.addToRoles(role1);
   
    NSDictionary<String, Object> snapshot = employee.snapshot();
    NSDictionary committedSnapshot = employee.committedSnapshot();
   
    /*
     * Snapshot should have same values as the eo and committed snapshot should be all
     * null values as eo has not yet been saved.
     */
    EOEntity entity = employee.entity();
    for (String key : (NSArray<String>) entity.classPropertyNames()) {
      Object snapshotValue = snapshot.valueForKey(key);
      assertEquals(employee.valueForKey(key), ERXValueUtilities.isNull(snapshotValue) ? null : snapshotValue);
      assertTrue(ERXValueUtilities.isNull(committedSnapshot.valueForKey(key)));
    }
   
    ec.saveChanges();
   
    Role role2 = Role.createRole(ec);
    employee.addToRoles(role2);
    employee.removeFromRoles(role1);
   
    NSDictionary changesFromCommittedSnapshot = employee.changesFromCommittedSnapshot();
   
    /*
     * We changed only the role relationship so the only recorded change should be
     * roles with the added and removed object.
     */
 
View Full Code Here

 
  public void testFetchWithRelationshipQualifier() {
    EOEditingContext ec = ERXEC.newEditingContext();
   
    Company company = Company.createCompany(ec, "Fetch Test Company");
    Employee employee = Employee.createEmployee(ec, "Fetch", "Test", Boolean.FALSE, company);
    Role role = Role.createRole(ec);
    employee.addToRoles(role);
    Paycheck paycheck = Paycheck.createPaycheck(ec, new BigDecimal(10), Boolean.FALSE, new NSTimestamp(), employee);
   
    ec.saveChanges();
   
    EOQualifier baseQualifier = Employee.FIRST_NAME.is("Fetch");
View Full Code Here

    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      Company c = (Company) EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME);
      c.setName(randomName("Disney World"));
      Employee e1 = c.createEmployeesRelationship();
      e1.setFirstName(randomName("Mickey"));
      e1.setLastName(randomName("Mouse"));
      e1.setManager(Boolean.FALSE);
      Employee e2 = c.createEmployeesRelationship();
      e2.setFirstName(randomName("Donald"));
      e2.setLastName(randomName("Duck"));
      e2.setManager(Boolean.FALSE);
      Employee e3 = c.createEmployeesRelationship();
      e3.setFirstName(randomName("Goofy"));
      e3.setLastName(randomName("Dog"));
      e3.setManager(Boolean.FALSE);
     
      // Give Mickey a paycheck
      Paycheck p = (Paycheck) EOUtilities.createAndInsertInstance(ec, Paycheck.ENTITY_NAME);
      p.setAmount(BigDecimal.valueOf(12345.67));
      p.setCashed(Boolean.FALSE);
View Full Code Here

    assertNotNull(company_osc2);

    // Create and Save Employee1 in Company1 in OSC1
    String employeeFirstName = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName = "Jones";
    Employee employee_osc1 = Employee.createEmployee(editingContext_osc1, employeeFirstName, employeeLastName, Boolean.FALSE, company_osc1);
    editingContext_osc1.saveChanges();

    // Fetch employees relationship of Company1 in OSC1
    assertContainsExactlyEOs(new NSArray<Employee>(employee_osc1), company_osc1.employees());
View Full Code Here

  NSArray employees_osc2 = company_osc2.employees();

    // Create and Save Employee1 for Company1 in OSC1
    String employeeFirstName = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName = "Jones";
    Employee employee_osc1 = Employee.createEmployee(editingContext_osc1, employeeFirstName, employeeLastName, Boolean.FALSE, company_osc1);
    editingContext_osc1.saveChanges();
    sleep();

    // Check employees for Company1 in OSC1
    assertContainsExactlyEOs(new NSArray<Employee>(employee_osc1), company_osc1.employees());

    // Check employees for Company1 in OSC2
    assertContainsExactlyEOs(new NSArray<Employee>(employee_osc1), company_osc2.employees());

    // Create employee for Company1 in OSC2 and Save
    String employeeFirstName2 = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName2 = "Jones";
    Employee employee_osc2 = Employee.createEmployee(editingContext_osc2, employeeFirstName2, employeeLastName2, Boolean.FALSE, company_osc2);
    editingContext_osc2.saveChanges();
    sleep();

    // Check employees for Company1 in OSC1
    assertContainsExactlyEOs(new NSArray<Employee>(new Employee[] { employee_osc1, employee_osc2 }), company_osc1.employees());
View Full Code Here

    assertNotNull(company_osc2);

    // Create (but do not save) Employee1 for Company1 in OSC2
    String employeeFirstName1 = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName1 = "Jones";
    Employee employee1_osc2 = Employee.createEmployee(editingContext_osc2, employeeFirstName1, employeeLastName1, Boolean.FALSE, company_osc2);

    // Check employees for Company1 in OSC1 (should contain uncommitted Employee)
    NSArray employees_osc2_BeforeInsert = company_osc2.employees();
    assertEquals(1, employees_osc2_BeforeInsert.count());
    assertEOEquals(employee1_osc2, employees_osc2_BeforeInsert.objectAtIndex(0));

    // Create and save Employee2 for Company1 in OSC1
    String employeeFirstName2 = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName2 = "Jones";
    Employee employee2_osc1 = Employee.createEmployee(editingContext_osc1, employeeFirstName2, employeeLastName2, Boolean.FALSE, company_osc1);
    editingContext_osc1.saveChanges();
    sleep();

    // Check employees for Company1 in OSC2 (should contain both Employees)
    assertContainsExactlyEOs(new NSArray<Employee>(new Employee[] { employee1_osc2, employee2_osc1 }), company_osc2.employees());
View Full Code Here

    sleep();

    // Create and Save Employee1 and Employee2 for Company1 in OSC1
    String employeeFirstName1 = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName1 = "Jones";
    Employee employee1_osc1 = Employee.createEmployee(editingContext_osc1, employeeFirstName1, employeeLastName1, Boolean.FALSE, company_osc1);
    String employeeFirstName2 = "Employee" + ERXRandomGUID.newGid();
    String employeeLastName2 = "Jones";
    Employee employee2_osc1 = Employee.createEmployee(editingContext_osc1, employeeFirstName2, employeeLastName2, Boolean.FALSE, company_osc1);
    editingContext_osc1.saveChanges();
    sleep();

    // Fetch employees for Company1 in OSC1
    assertContainsExactlyEOs(new NSArray<Employee>(new Employee[] { employee1_osc1, employee2_osc1 }), company_osc1.employees());

    // Fetch Company1 in OSC2
    EOEditingContext editingContext_osc2 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
    Company company_osc2 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName);
    assertNotNull(company_osc2);
    // Fetch and check employees for Company1 in OSC2
    assertContainsExactlyEOs(new NSArray<Employee>(new Employee[] { employee1_osc1, employee2_osc1 }), company_osc2.employees());

    // gonna break
    NSArray employees_osc2 = company_osc2.employees();
    Employee employee2_osc2 = (Employee) employees_osc2.objectAtIndex(0);
    Employee employee1_osc2 = (Employee) employees_osc2.objectAtIndex(1);

    Employee secondEmployee_osc2;
    if (ERXEOControlUtilities.eoEquals(employee1_osc1, employee1_osc2)) {
      secondEmployee_osc2 = employee2_osc2;
    }
    else {
      secondEmployee_osc2 = employee1_osc2;
View Full Code Here

    assertEquals("Elena", fetched);
  }

  @Test
  public void testObjectAtIndexInteger() {
    Employee fetched = (Employee) Company.EMPLOYEES.atFetchSpec("plebs").dot(ERXKey.objectAtIndex(Integer.valueOf(1))).valueInObject(shinraInc);
    assertEquals(rude, fetched);
  }
View Full Code Here

    assertEquals(rude, fetched);
  }

  @Test
  public void testAtObjectAtIndexInteger() {
    Employee fetched = (Employee) Company.EMPLOYEES.atFetchSpec("plebs").atObjectAtIndex(Integer.valueOf(2)).valueInObject(shinraInc);
    assertEquals(sephiroth, fetched);
  }
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.