Package org.crank.crud.test.model

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


        group.toString());
  }

  @Test(groups = { "broken" })
  public void example() {
    Employee employee = new Employee();
    employee.setActive(true);
    employee.setAge(40);
    employee.setFirstName("Rick");
    employee.setLastName("Rick");
    Example example = Example.like(employee).excludeProperty("lastName");
    assertEquals(
        "1",
        "(AND [active_EQ_true, age_EQ_40, firstName_LIKE_CONTAINS_Rick])",
        example.toString());

    example = Example.createExample(employee).excludeZeroes();
    employee.setAge(0);
    employee.setLastName(null);
    assertEquals("2", "(AND [active_EQ_true, firstName_EQ_Rick])", example
        .toString());

    example = Example.createExample(employee).excludeZeroes();
    employee.setAge(40);
    employee.setLastName(null);
    assertEquals("3",
        "(AND [active_EQ_true, age_EQ_40, firstName_EQ_Rick], numberOfPromotions_EQ_0, tasks_EQ_[]])", example
            .toString());

    example = Example.createExample(employee).excludeZeroes().excludeNone();
    employee.setAge(0);
    employee.setLastName(null);
    assertEquals(
        "4",
        "(AND [active_EQ_true, address_EQ_null, department_EQ_null, description_EQ_null, firstName_EQ_Rick, id_EQ_null, lastName_EQ_null, numberOfPromotions_EQ_null, rank_EQ_null, status_EQ_null])",
        example.toString());
View Full Code Here


  }

  @Test
  public void test2() {
    for (int index = 0; index < 100; index++) {
      Employee employee = new Employee();
      employee.setFirstName("FOO" + index);
      employee.setNumberOfPromotions(1);
      employeeDao.persist(employee);
    }
    employeeDao.flushAndClear();
    paginatableDataSource.group().clear();
    paginatableDataSource.group().add(
View Full Code Here

        return "data/Employee.xml";
    }
   
    @Test(groups="broken")
    public void testPreloadWithCount() {
        Employee employee = preloadingEmployeeDao.read( 1l );
        employee.setNumberOfPromotions( 5 );
        preloadingEmployeeDao.merge( employee );
        assert preloadingEmployeeDao.read( 1l ) != null;
    }
View Full Code Here

    }
   
    @Test(groups="broken")
    public void testPreloadWithHQL() {
        //Validation of this in
        Employee employee = preloadingWithHQLEmployeeDao.read( 1l );
        assert employee != null;
        assert employee.getDepartment() != null;
    }
View Full Code Here

    @Test(groups={"broken"})
    public void test() {
        FilteringPaginator paginator = new FilteringPaginator(paginatableDataSource, Employee.class );
       
        for (int index = 0; index < 100; index++) {
            Employee employee = new Employee();
            employee.setFirstName( "FOO" + index);
            employee.setNumberOfPromotions( 1 );
            employeeDao.persist(employee);
        }
       
        paginator.getFilterableProperties().get( "firstName" ).getComparison().setValue("FOO");
        paginator.getFilterableProperties().get( "firstName" ).getComparison().setEnabled( true );
        paginator.filter();
        Employee employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("FOO0", employee.getFirstName());
        AssertJUnit.assertEquals(10, paginator.getPageCount());

        paginator.getFilterableProperties().get( "firstName" ).getComparison().setValue("R");
        paginator.filter();
        employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("Rick", employee.getFirstName());
        AssertJUnit.assertEquals(1, paginator.getPageCount());
   
        paginator.getFilterableProperties().get( "firstName" ).getComparison().disable();
        paginator.filter();
        employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("Rick", employee.getFirstName());
        AssertJUnit.assertEquals(11, paginator.getPageCount());

        paginator.getFilterableProperties().get( "firstName" ).getComparison().enable();
        paginator.getFilterableProperties().get( "firstName" ).getComparison().setValue("FOO");
        paginator.filter();
        employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("FOO0", employee.getFirstName());
        AssertJUnit.assertEquals(10, paginator.getPageCount());

       
        paginator.getFilterableProperties().get( "firstName" ).getComparison().disable();
        paginator.getFilterableProperties().get( "firstName" ).getOrderBy().toggle();
        employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("Scott", employee.getFirstName());
        AssertJUnit.assertEquals(11, paginator.getPageCount());
       
        paginator.getFilterableProperties().get( "firstName" ).getOrderBy().toggle();
        employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("Bob", employee.getFirstName());
        AssertJUnit.assertEquals(11, paginator.getPageCount());

        paginator.getFilterableProperties().get( "department.name" ).getOrderBy().toggle();
        employee = (Employee)paginator.getPage().get( 0 );
        AssertJUnit.assertEquals("Bob", employee.getFirstName());
        AssertJUnit.assertEquals(11, paginator.getPageCount());
       
        paginator.getFilterableProperties().get( "address.zipCode" ).getOrderBy().toggle();
        employee = (Employee)paginator.getPage().get( 0 );
       
View Full Code Here

    Department engineeringDept = departmentDao.read(1L);
    Department itDept = departmentDao.read(2L);
    Department hrDept = departmentDao.read(3L);

    Employee[] employees = {
      new Employee("Rick", "Hightower", engineeringDept, true, 40, 1, "333333331"),
      new Employee("Chris", null, engineeringDept, true, 40, 1, "333333332"),
      new Employee("Scott", null, engineeringDept, true, 40, 1, "333333333"),
      new Employee("Bob", null, itDept, true, 40, 1, "333333334"),     
      new Employee("Joe", null, itDept, true, 40, 1, "333333335"),
      new Employee("Same", null, itDept, true, 40, 1, "333333336"),
      new Employee("Juan", "Highb", hrDept, true, 40, 1, "333333337"),
      new Employee("Carlos", null, hrDept, true, 40, 1, "333333338"),
      new Employee("Marcello", null, hrDept, true, 40, 1, "333333339"),
      new Employee("Richard", "Higha", hrDept, true, 40, 1, "333333310"),
      new Employee("Rickard", null, hrDept, true, 40, 1, "333333311"),
      new Employee("Rich", null, hrDept, true, 40, 1, "333333312"),
      new Employee("Ric", null, hrDept, true, 40, 1, "333333313"),
      new Employee("Vanilla", "GORILLA", hrDept, true, 40, 1, "333333314")
    };
    testEmployees = Arrays.asList(employees);
   
    employeeDao.persist(testEmployees);
  }
View Full Code Here

    }
  }
 
  @Test (groups="reads", dependsOnGroups="createsObjectInDB")
  public void testLazyEmployees() {
    Employee emp = employeeDao.read(testEmployees.get(0).getId());
    System.out.println(emp.getDepartmentId());
    System.out.println(emp.getDepartment().getId());
  }
View Full Code Here

  }

  @SuppressWarnings("static-access")
  @Test(groups="modifies", dependsOnGroups="reads")
  public void testDeleteObject() throws Exception {
    Employee employee = (Employee) employeeDao.find(
        eq("firstName", "Rick").eq("lastName", "Hightower")).get(0);
    Long id = employee.getId();
    AssertJUnit.assertNotNull(employee);
    AssertJUnit.assertEquals(((Employee) employee).getId(), id);
    employeeDao.delete(id);
    employeeDao.flushAndClear();
    employee = (Employee) employeeDao.read(id);
View Full Code Here

    employeeDao.flushAndClear();
  }

  @Test(groups="createsObjectInDB")
  public void testFetchWithOrderBy() throws Exception {
    Employee employee = new Employee();
    employee.setFirstName("Rick");
    employee.setNumberOfPromotions(1);
    employee = employeeDao.merge(employee);
    Map<String, Object> params = new HashMap<String, Object>();
    List<Employee> employees = employeeDao.find(params,
        new String[] { "firstName" });
    AssertJUnit.assertEquals("Bob",((Employee) employees.get(0)).getFirstName());
View Full Code Here

  }

  @Test (groups="reads" ,dependsOnGroups="createsObjectInDB")
  public void testGetObject() {
    Long id = testEmployees.get(0).getId();
    Employee employee = employeeDao.read(id);
    AssertJUnit.assertNotNull(employee);
    AssertJUnit.assertEquals(employee.getId(), id);
    AssertJUnit.assertEquals("Rick", employee.getFirstName());
  }
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.