Package org.crank.crud.test.model

Examples of org.crank.crud.test.model.Employee


    group = and(Employee.class, between("age", 1, 100));
    string = CriteriaUtils.constructWhereClauseString(group, false);
    AssertJUnit.assertEquals(" WHERE  o.age BETWEEN :age_1 and :age_2 ",
        string);

    Employee employee = new Employee();
    employee.setFirstName("Ric");
    employee.setAge(0);
    Department department = new Department();
    department.setName("Eng");
    employee.setDepartment(department);
    group = like(employee).excludeProperty("employees").excludeProperty(
        "numberOfPromotions");
    string = CriteriaUtils.constructWhereClauseString(group, false);
    AssertJUnit
        .assertEquals(
View Full Code Here


  }

  @Test (groups="reads", dependsOnGroups="createsObjectInDB")
  public void testQBE() {

    Employee employee = new Employee();
    employee.setActive(true);
    employee.setAge(40);
    employee.setNumberOfPromotions(1);
    employee.setFirstName("Rick");
    employee.setLastName("Rick");
    employee.setTasks(null);

    Example ex =  like(employee).excludeProperty("lastName").excludeProperty("tasks");
    System.out.println(ex);
//    List<Employee> employees =
    employeeDao.find(ex);
    //    AssertJUnit.assertTrue(employees.size() > 0);

    employee = new Employee();
    employee.setFirstName("Ric%");
    employee.setLastName("High%");
    employee.setAge(40);
    employee.setActive(true);
    employee.setNumberOfPromotions(1);
    Department department = new Department();
    department.setName("Eng%");
    employee.setDepartment(department);
    employeeDao.find(like(employee)
        .excludeProperty("employees").excludeProperty("tasks"));
//    AssertJUnit.assertTrue(employees.size() > 0);

  }
View Full Code Here

  }

  @Test (groups="reads", dependsOnGroups="createsObjectInDB")
  public void testReadFully() {
   
    Employee employee = employeeDao.readPopulated(testEmployees.get(0).getId());
    AssertJUnit.assertNotNull(employee);

    Department dept = (Department) departmentDao.readPopulated(1L);
    AssertJUnit.assertNotNull(dept);
  }
View Full Code Here

      new TransactionTemplate(transactionManager);
   
    transactionTemplate.execute(
        new TransactionCallback() {
          public Object doInTransaction(TransactionStatus ts) {
            Employee employee =  employeeDao.readExclusive(testEmployees.get(0).getId());
            AssertJUnit.assertNotNull("Employee for id=1 not read.", employee);
            return null;
          }
        });   
View Full Code Here

  @Test (groups="reads", dependsOnGroups="createsObjectInDB")
    public void testEntityEquals () {
        Department department = departmentDao.merge(new Department("r&d"));
        department = departmentDao.read(department.getId());
        Employee employee = new Employee("Rick", "Hightower");
        employee.setDepartment(department);
        department.getEmployees().add(employee);
        departmentDao.merge(department);
        List<Employee> find = employeeDao.find(eq("department", department));
        String firstname = find.get(0).getFirstName();
        AssertJUnit.assertEquals("Rick", firstname);
View Full Code Here

   
  @Test (groups="reads", dependsOnGroups="createsObjectInDB")
    public void testPersistMultiple() {
        List<Employee> employees =Arrays.asList(
            new Employee[] {
                new Employee("PersistMultipleOne", "Hightower"),
                new Employee("PersistMultipleTwo", "Hightower"),
                new Employee("PersistMultipleThree", "Hightower")
                }
            );
        employeeDao.persist(employees);
         // clean up inserted data
        for (Employee e : employees) {
View Full Code Here

      xTemplate.execute(new TransactionCallback() {
   
      public Object doInTransaction(TransactionStatus arg0) {
            List<Employee> employees =Arrays.asList(
                new Employee[] {
                    new Employee("StoreMultipleOne", "Hightower"),
                    new Employee("StoreMultipleTwo", "Hightower"),
                    new Employee("StoreMultipleThree", "Hightower")
                    }
                );
            Collection<Employee> results = employeeDao.store(employees);
             // clean up inserted data
            for (Employee e : results) {
View Full Code Here

    @Test(groups="createsObjectInDB")
    public void testMergeMultiple() {
        List<Employee> employees =Arrays.asList(
            new Employee[] {
                new Employee("MergeMultipleOne", "Hightower"),
                new Employee("MergeMultipleTwo", "Hightower"),
                new Employee("MergeMultipleThree", "Hightower")
                }
            );
        Collection<Employee> results = employeeDao.merge(employees);
       
    AssertJUnit.assertTrue(results.size() > 0);
View Full Code Here

  @Test(groups="modifies", dependsOnGroups="reads")
    public void testDeleteMultiple() {       
      employeeDao.flushAndClear();
        List<Employee> employees =Arrays.asList(
            new Employee[] {
                new Employee("DeleteMultipleOne", "Hightower"),
                new Employee("DeleteMultipleTwo", "Hightower"),
                new Employee("DeleteMultipleThree", "Hightower")
                }
            );
        employeeDao.persist(employees);
        employeeDao.delete(employees);   
    }
View Full Code Here

   
    }
 
  @Test (groups="updates")
    public void testUpdateWithStore() {
    Employee employee = testEmployees.get(0);
    employee.setFirstName("monkey");
    employeeDao.store(employee);
    employee = employeeDao.read(employee.getId());
    assert employee.getFirstName().equals("monkey");
  }
View Full Code Here

TOP

Related Classes of org.crank.crud.test.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.