Package com.mysema.query.domain

Source Code of com.mysema.query.domain.QueryByExampleTest

package com.mysema.query.domain;

import static org.junit.Assert.*;

import org.junit.Test;

import com.mysema.query.annotations.QueryDelegate;
import com.mysema.query.types.Predicate;


public class QueryByExampleTest {
       
    @QueryDelegate(ExampleEntity.class)
    public static Predicate like(QExampleEntity qtype, ExampleEntity example) {
        return example.name != null ? qtype.name.eq(example.name) : null;
    }
   
    @Test
    public void Name_Not_Set() {
        ExampleEntity entity = new ExampleEntity();
        Predicate qbe = QExampleEntity.exampleEntity.like(entity);
        assertNull(qbe);
    }
   
    @Test
    public void Name_Set() {
        ExampleEntity entity = new ExampleEntity();
        entity.name = "XXX";
        Predicate qbe = QExampleEntity.exampleEntity.like(entity);
        assertEquals("exampleEntity.name = XXX", qbe.toString());
    }

}
TOP

Related Classes of com.mysema.query.domain.QueryByExampleTest

TOP
Copyright © 2018 www.massapi.com. 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.