Package org.dayatang.domain

Examples of org.dayatang.domain.CriteriaQuery


    /**
     * Test of createCritriaQuery method
     */
    @Test
    public void testCreateCriteriaQuery() {
        CriteriaQuery query = repository.createCriteriaQuery(Dictionary.class);
        assertEquals(Dictionary.class, query.getEntityClass());
    }
View Full Code Here


    /**
     * Test of find method with CriteriaQuery as parameter
     */
    @Test
    public void testCriteriaQueryFind() {
        CriteriaQuery query = new CriteriaQuery(repository, Dictionary.class)
                .eq("category", education);
        List<Dictionary> results = repository.find(query);
        assertTrue(results.contains(graduate));
        assertTrue(results.contains(undergraduate));
    }
View Full Code Here

    /**
     * Test of getSingleResult method with CriteriaQuery as parameter
     */
    @Test
    public void testCriteriaQueryGetSingleResult() {
        CriteriaQuery query = new CriteriaQuery(repository, Dictionary.class)
                .eq("category", gender)
                .eq("code", "01");
        assertEquals(male, repository.getSingleResult(query));
    }
View Full Code Here

    private final CriterionBuilder criterionBuilder = InstanceFactory.getInstance(CriterionBuilder.class);

    @Before
    public void setUp() {
        super.setUp();
        instance = new CriteriaQuery(repository, Dictionary.class);
        instance2 = new CriteriaQuery(repository, DictionaryCategory.class);
        gender = createCategory("gender", 1);
        education = createCategory("education", 2);
        male = createDictionary("01", "男", gender, 100, "01");
        female = createDictionary("02", "女", gender, 150, "01");
        undergraduate = createDictionary("01", "本科", education, 200, "05");
View Full Code Here

    public void testStartsWithText() {
        instance.startsWithText("text", "本");
        List<Dictionary> results = repository.find(instance);
        assertTrue(results.contains(undergraduate));

        instance = new CriteriaQuery(repository, Dictionary.class).startsWithText("text", "科");
        results = repository.find(instance);
        assertFalse(results.contains(undergraduate));
    }
View Full Code Here

        instance.asc("sortOrder");
        List<Dictionary> results = repository.find(instance);
        assertTrue(results.indexOf(male) < results.indexOf(female));
        assertTrue(results.indexOf(female) < results.indexOf(undergraduate));

        instance = new CriteriaQuery(repository, Dictionary.class).desc("sortOrder");
        results = repository.find(instance);
        assertTrue(results.indexOf(male) > results.indexOf(female));
        assertTrue(results.indexOf(female) > results.indexOf(undergraduate));
    }
View Full Code Here

TOP

Related Classes of org.dayatang.domain.CriteriaQuery

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.