use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class SearchContextImplTest method doTestFiqlSearchBean.
private void doTestFiqlSearchBean(String queryString) {
Message m = new MessageImpl();
m.put(Message.QUERY_STRING, queryString);
SearchContext context = new SearchContextImpl(m);
SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
assertNotNull(sc);
List<SearchBean> beans = new ArrayList<>();
SearchBean sb1 = new SearchBean();
sb1.set("name", "CXF is cool");
beans.add(sb1);
SearchBean sb2 = new SearchBean();
sb2.set("name", "CXF Rocks");
sb2.set("id", "124");
beans.add(sb2);
List<SearchBean> found = sc.findAll(beans);
assertEquals(1, found.size());
assertEquals(sb2, found.get(0));
assertTrue(sc instanceof AndSearchCondition);
assertNull(sc.getStatement());
List<SearchCondition<SearchBean>> scs = sc.getSearchConditions();
assertEquals(2, scs.size());
SearchCondition<SearchBean> sc1 = scs.get(0);
assertEquals("name", sc1.getStatement().getProperty());
SearchCondition<SearchBean> sc2 = scs.get(1);
assertEquals("id", sc2.getStatement().getProperty());
assertTrue("123".equals(sc1.getStatement().getValue()) && "CXF Rocks".equals(sc2.getStatement().getValue()) || "123".equals(sc2.getStatement().getValue()) && "CXF Rocks".equals(sc1.getStatement().getValue()));
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class SearchContextImplTest method testWrongQueryException.
@Test(expected = SearchParseException.class)
public void testWrongQueryException() {
Message m = new MessageImpl();
m.put(Message.QUERY_STRING, "_s=ab");
new SearchContextImpl(m).getCondition(Book.class);
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class SearchContextImplTest method testPrimitiveStatementSearchBeanComlexName.
@Test
public void testPrimitiveStatementSearchBeanComlexName() {
Message m = new MessageImpl();
m.put(Message.QUERY_STRING, "_s=complex.name==CXF");
SearchContext context = new SearchContextImpl(m);
SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
assertNotNull(sc);
PrimitiveStatement ps = sc.getStatement();
assertNotNull(ps);
assertEquals("complex.name", ps.getProperty());
assertEquals("CXF", ps.getValue());
assertEquals(ConditionType.EQUALS, ps.getCondition());
assertEquals(String.class, ps.getValueType());
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class SearchContextImplTest method testSingleEquals.
@Test
public void testSingleEquals() {
Message m = new MessageImpl();
m.put(Message.QUERY_STRING, "_s=name=CXF");
m.put("fiql.support.single.equals.operator", "true");
SearchContext context = new SearchContextImpl(m);
SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
assertNotNull(sc);
PrimitiveStatement ps = sc.getStatement();
assertNotNull(ps);
assertEquals("name", ps.getProperty());
assertEquals("CXF", ps.getValue());
assertEquals(ConditionType.EQUALS, ps.getCondition());
assertEquals(String.class, ps.getValueType());
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class SearchContextImplTest method testPlainQuery3.
@Test
public void testPlainQuery3() {
Message m = new MessageImpl();
m.put("search.use.plain.queries", true);
m.put(Message.QUERY_STRING, "a=b&c=d");
String exp = new SearchContextImpl(m).getSearchExpression();
assertEquals("(a==b;c==d)", exp);
}
Aggregations