Package com.mysema.query.types.path

Examples of com.mysema.query.types.path.StringPath


public class QListTest {

    @Test
    public void NewInstance() {
        QList qList = new QList(new StringPath("a"), new StringPath("b"));
        List<?> list = qList.newInstance("a", null);
        assertEquals(2, list.size());
        assertEquals("a", list.get(0));
        assertNull(list.get(1));
    }
View Full Code Here


        }
    };

    @Test
    public void Operation() {
        Expression<String> str = new StringPath(new PathImpl(Object.class, "customer"), "name");
        Expression<String> str2 = new StringPath("str");
        Expression<String> concat = Expressions.stringOperation(Ops.CONCAT, str, str2);
        assertEquals("customer.name + str", concat.toString());
        assertEquals("customer_.name + str_", concat.accept(visitor, null).toString());
    }
View Full Code Here

        assertEquals("customer_.name + str_", concat.accept(visitor, null).toString());
    }

    @Test
    public void TemplateExpression() {
        Expression<String> str = new StringPath(new PathImpl(Object.class, "customer"), "name");
        Expression<String> str2 = new StringPath("str");
        Expression<String> concat = Expressions.stringTemplate("{0} + {1}", str, str2);
        assertEquals("customer.name + str", concat.toString());
        assertEquals("customer_.name + str_", concat.accept(visitor, null).toString());
    }
View Full Code Here

    public void Alias() {
        Expression<?> expr = str1.as("s");
        QTuple qTuple = new QTuple(expr);
        Tuple tuple = qTuple.newInstance("arg");
        assertEquals("arg", tuple.get(expr));
        assertEquals("arg", tuple.get(new StringPath("s")));
    }
View Full Code Here

    private static final BooleanExpression a = new BooleanPath("a"), b = new BooleanPath("b");
   
    @Test
    public void As() {
        assertEquals("null as str", Expressions.as(null, str).toString());
        assertEquals("s as str", Expressions.as(new StringPath("s"), str).toString());
    }
View Full Code Here

     *
     * @param variable
     * @return
     */
    public static StringPath stringPath(String variable) {
        return new StringPath(PathMetadataFactory.forVariable(variable));
    }
View Full Code Here

     * @param parent
     * @param property
     * @return
     */
    public static StringPath stringPath(Path<?> parent, String property) {
        return new StringPath(PathMetadataFactory.forProperty(parent, property));
    }
View Full Code Here

        assertEquals(Color.RED, conversions.newInstance(2).get(color));
    }

    @Test
    public void Safe_Number_Conversion() {
        StringPath strPath = new StringPath("strPath");
        NumberPath<Integer> intPath = new NumberPath<Integer>(Integer.class, "intPath");
        QTuple qTuple = new QTuple(strPath, intPath);
        NumberConversions<Tuple> conversions = new NumberConversions<Tuple>(qTuple);
        assertNotNull(conversions.newInstance(1, 2));
    }
View Full Code Here

        assertNotNull(conversions.newInstance(1, 2));
    }

    @Test
    public void Number_Conversion() {
        StringPath strPath = new StringPath("strPath");
        NumberPath<Integer> intPath = new NumberPath<Integer>(Integer.class, "intPath");
        QTuple qTuple = new QTuple(strPath, intPath);
        NumberConversions<Tuple> conversions = new NumberConversions<Tuple>(qTuple);
        Tuple tuple = conversions.newInstance("a", Long.valueOf(3));
        assertEquals("a", tuple.get(strPath));
View Full Code Here

        query().from(survey).where(survey.name.in(Arrays.asList("a","b","c"))).count();
    }

    @Test
    public void Precedence() {
        StringPath fn = employee.firstname;
        StringPath ln = employee.lastname;
        Predicate where = fn.eq("Mike").and(ln.eq("Smith")).or(fn.eq("Joe").and(ln.eq("Divis")));
        assertEquals(2l, query().from(employee).where(where).count());
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.types.path.StringPath

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.