Package com.googlecode.objectify.test.entity

Examples of com.googlecode.objectify.test.entity.Employee


  {
    fact().register(Employee.class);

    Key<Employee> bobKey = Key.create(Employee.class, "bob");

    Employee fred = new Employee("fred", bobKey);
    ofy().save().entity(fred).now();

    Iterator<Employee> it = ofy().load().type(Employee.class).filter("manager", bobKey).iterator();

    assert it.hasNext();
    Employee fetched = it.next();
    assert !it.hasNext();
    assert fred.getName().equals(fetched.getName());
  }
View Full Code Here


  @Test
  public void testFilteringByEntityField() throws Exception
  {
    fact().register(Employee.class);

    Employee bob = new Employee("bob");
    ofy().save().entity(bob).now();

    Employee fred = new Employee("fred", bob);
    ofy().save().entity(fred).now();

    Iterator<Employee> it = ofy().load().type(Employee.class).filter("manager2", bob).iterator();

    assert it.hasNext();
    Employee fetched = it.next();
    assert !it.hasNext();
    assert fred.getName().equals(fetched.getName());
  }
View Full Code Here

  public void testINfilteringWithKeyField() throws Exception
  {
    fact().register(Employee.class);

    Key<Employee> bobKey = Key.create(Employee.class, "bob");
    Employee fred = new Employee("fred", bobKey);

    ofy().save().entity(fred).now();

    Set<Key<Employee>> singleton = Collections.singleton(bobKey);
View Full Code Here

  /** */
  @Test
  public void testManyToOne() throws Exception {
    fact().register(Employee.class);

    Employee fred = new Employee("fred");
    ofy().save().entity(fred).now();

    Key<Employee> fredKey = Key.create(fred);

    List<Employee> employees = new ArrayList<>(100);
    for (int i = 0; i < 100; i++)
    {
      Employee emp = new Employee("foo" + i, fredKey);
      employees.add(emp);
    }

    ofy().save().entities(employees).now();

    assert employees.size() == 100;

    int count = 0;
    for (Employee emp: ofy().load().type(Employee.class).filter("manager", fred))
    {
      emp.getName(); // Just to make eclipse happy
      count++;
    }
    assert count == 100;
  }
View Full Code Here

TOP

Related Classes of com.googlecode.objectify.test.entity.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.