Package er.erxtest.model

Examples of er.erxtest.model.Company


    }
   
    public void testNestedECs() {
      try {
        EOEditingContext ec = ERXEC.newEditingContext();
        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);
View Full Code Here


  /**
   * Test method for {@link er.extensions.eof.ERXEC#invalidateAllObjects()}.
   */
  public void _testInvalidateAllObjects() {

    Company toBeDeleted = null;
    Company toBeModified = null;

    ERXEC ec = new ERXEC();
   
    NSArray<Company> rows = EOUtilities.objectsForEntityNamed(ec, Company.ENTITY_NAME);

    String name = ERXTestUtilities.randomName("ERXEC_IAO");
   
    if (rows.count() < 1) {
      ((Company)EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME)).setName(name+"_1");
      ec.saveChanges();
      rows = EOUtilities.objectsForEntityNamed(ec, Company.ENTITY_NAME);
    }
    if (rows.count() < 2) {
      ((Company)EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME)).setName(name+"_2");
      ec.saveChanges();
      rows = EOUtilities.objectsForEntityNamed(ec, Company.ENTITY_NAME);
    }

    toBeDeleted = rows.get(0);
    toBeModified = rows.get(1);

    String deletedName = toBeDeleted.name();
    String preModifiedName = toBeModified.name();
   
    // Getting ready to modify the "toBeModified"...
    //
    int preModifiedNameCount = EOUtilities.objectsMatchingKeyAndValue(ec, Company.ENTITY_NAME, "name", preModifiedName).count();
    toBeModified.setName(name+"_3");
   
    // Now to add an object...
    //
    ((Company)EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME)).setName(name+"_4");

View Full Code Here

  public void testDelete() {
    EOEditingContext editingContext = ERXEC.newEditingContext();
    NSMutableArray<Company> companies = new NSMutableArray<Company>();
    for (int i = 0; i < 10; i++) {
      Company c = Company.createCompany(editingContext, "Test Company " + i);
      companies.addObject(c);
    }
    editingContext.saveChanges();

    for (Company c : companies) {
      c.delete();
      editingContext.saveChanges();
    }
  }
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();
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);
   
View Full Code Here

  public static EOGlobalID createCompanyAnd3Employees() {
   
    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
View Full Code Here

  public static EOGlobalID createCompanyAndNoEmployees() {
   
    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      Company c = (Company) EOUtilities.createAndInsertInstance(ec, Company.ENTITY_NAME);
      c.setName("Disney World");
      ec.saveChanges();
      return ec.globalIDForObject(c);
    } finally {
      ec.unlock();
    }
View Full Code Here

 
  public void testInsertEO() {
    // Create Company in OSC1
    String companyName = "Company" + ERXRandomGUID.newGid();
    EOEditingContext editingContext_osc1 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
    Company company_osc1 = Company.createCompany(editingContext_osc1, companyName);
    editingContext_osc1.saveChanges();
    Company company_osc1_fetched = Company.fetchCompany(editingContext_osc1, Company.NAME_KEY, companyName);
    assertNotNull(company_osc1_fetched);
    sleep();

    // Fetch Company in OSC2
    EOEditingContext editingContext_osc2 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
    Company company_osc2 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName);
    assertNotNull(company_osc2);
    assertEquals(companyName, company_osc1.name());
    assertEquals(companyName, company_osc2.name());
  }
View Full Code Here

  public void testUpdateEO() {
    // Create Company1 in OSC1
    String companyName = "Company" + ERXRandomGUID.newGid();
    EOEditingContext editingContext_osc1 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
    Company company_osc1 = Company.createCompany(editingContext_osc1, companyName);
    editingContext_osc1.saveChanges();
    sleep();

    // 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);

    for (int i = 0; i < 10; i++) {
      // Change Company1's name in OSC1
      String companyName_1 = "Company" + ERXRandomGUID.newGid() + "_osc1";
      company_osc1.setName(companyName_1);
      editingContext_osc1.saveChanges();
      sleep();
      assertEquals(companyName_1, company_osc2.name());
      assertEquals(companyName_1, company_osc1.name());

      // Fetch Company1 by name in OSC1
      Company company_osc1_with_companyName1 = Company.fetchCompany(editingContext_osc1, Company.NAME_KEY, companyName_1);
      assertEquals(company_osc1, company_osc1_with_companyName1);

      // Fetch Company1 by name in OSC2
      Company company_osc2_with_companyName1 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName_1);
      assertEquals(company_osc2, company_osc2_with_companyName1);

      // Change Company1's name in OSC2
      String companyName_2 = "Company" + ERXRandomGUID.newGid() + "_osc2";
      company_osc2.setName(companyName_2);
      editingContext_osc2.saveChanges();
      sleep();
      assertEquals(companyName_2, company_osc1.name());
      assertEquals(companyName_2, company_osc2.name());

      // Fetch Company1 by name in OSC1
      Company company_osc1_with_companyName2 = Company.fetchCompany(editingContext_osc1, Company.NAME_KEY, companyName_2);
      assertEquals(company_osc1, company_osc1_with_companyName2);

      // Fetch Company1 by name in OSC2
      Company company_osc2_with_companyName2 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName_2);
      assertEquals(company_osc2, company_osc2_with_companyName2);
    }
  }
View Full Code Here

  public void testMergeEOChanges() {
    // Create Company1 in OSC1
    String companyName = "Company" + ERXRandomGUID.newGid();
    EOEditingContext editingContext_osc1 = ERXEC.newEditingContext(ERXObjectStoreCoordinatorPool._pool().nextObjectStore());
    Company company_osc1 = Company.createCompany(editingContext_osc1, companyName);
    editingContext_osc1.saveChanges();
    sleep();

    // 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);

    for (int i = 0; i < 10; i++) {
      // Change Company1's name in OSC1
      String companyName_1 = "Company" + ERXRandomGUID.newGid() + "_osc1";
      String companyAddress1_1 = company_osc1.address1();
      company_osc1.setName(companyName_1);

      // Change Company1's address in OSC2
      String companyAddress1_2 = "Address" + ERXRandomGUID.newGid() + "_osc2";
      company_osc2.setAddress1(companyAddress1_2);

      // Save Company1's new name in OSC1, address in OSC2 should be untouched but merged with new name
      editingContext_osc1.saveChanges();
      sleep();
      assertEquals(companyName_1, company_osc2.name());
      assertEquals(companyName_1, company_osc1.name());
      assertEquals(companyAddress1_2, company_osc2.address1());
      assertEquals(companyAddress1_1, company_osc1.address1());

      // Fetch Company1 by name in OSC1
      Company company_osc1_with_companyName1 = Company.fetchCompany(editingContext_osc1, Company.NAME_KEY, companyName_1);
      assertEquals(company_osc1, company_osc1_with_companyName1);
      assertEquals(companyAddress1_1, company_osc1_with_companyName1.address1());

      // Fetch Company1 by name in OSC2
      Company company_osc2_with_companyName1 = Company.fetchCompany(editingContext_osc2, Company.NAME_KEY, companyName_1);
      assertEquals(company_osc2, company_osc2_with_companyName1);
      assertEquals(companyAddress1_2, company_osc2_with_companyName1.address1());

      // Save Company1's new address in OSC2
      editingContext_osc2.saveChanges();
      sleep();
      assertEquals(companyName_1, company_osc1.name());
View Full Code Here

TOP

Related Classes of er.erxtest.model.Company

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.