use of com.tangosol.util.Filter in project teiid by teiid.
the class TestCoherenceConnection method xtestEqualOnContainerObject.
/**
* this test will not work out-of-the-box. Coherence, from what I've found, doen'st support this, but can be developed.
* @throws Exception
*/
@Test
public void xtestEqualOnContainerObject() throws Exception {
CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
f.setCacheName(CACHE_NAME);
f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
long l = 1;
// NOTE: Coherence, because the datatype of ID is long, wants the "l" appended to the value
// Filter criteria = CoherenceFilterUtil.createFilter("Id = 1l");
Filter criteria = CoherenceFilterUtil.createCompareFilter("getLegs.getLegId", l, Comparison.Operator.EQ, Long.class);
List<?> trades = conn.get(criteria);
assertNotNull(trades);
assertEquals("Did not get expected number of trades", 1, trades.size());
}
use of com.tangosol.util.Filter in project teiid by teiid.
the class TestCoherenceConnection method testLike.
@Test
public void testLike() throws Exception {
CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
f.setCacheName(CACHE_NAME);
f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
Filter criteria = CoherenceFilterUtil.createFilter("Name like 'Name%'");
List<?> trades = conn.get(criteria);
assertNotNull(trades);
assertEquals("Did not get expected number of trades", 3, trades.size());
}
use of com.tangosol.util.Filter in project teiid by teiid.
the class TestCoherenceConnection method testAddAndRemoveTrade.
@Test
public void testAddAndRemoveTrade() throws Exception {
CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
f.setCacheName(CACHE_NAME);
f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
Trade trade = new Trade();
trade.setId(999);
trade.setName("NameIs " + 999);
trade.setLegs(null);
conn.add(999l, trade);
// NOTE: Coherence, because the datatype of ID is long, wants the "l" appended to the value
Filter criteria = CoherenceFilterUtil.createFilter("Id = 999l");
List<?> trades = conn.get(criteria);
assertNotNull(trades);
assertEquals("Did not get expected 999 trade", 1, trades.size());
long l = 999l;
criteria = CoherenceFilterUtil.createCompareFilter("Id", l, Comparison.Operator.EQ, Long.class);
trades = conn.get(CoherenceFilterUtil.createFilter("Id = 999l"));
assertNotNull(trades);
assertEquals("Did not get expected 999 trade", 1, trades.size());
conn.remove(l);
trades = conn.get(CoherenceFilterUtil.createFilter("Id = 999l"));
assertNotNull(trades);
assertEquals("Expected no trade", 0, trades.size());
}
use of com.tangosol.util.Filter in project teiid by teiid.
the class TestCoherenceConnection method testGet1Trade.
/**
* This will instantiate the {@link CoherenceManagedConnectionFactory} and
* obtain a connection to
*
* @throws Exception
*/
@Test
public void testGet1Trade() throws Exception {
CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
f.setCacheName(CACHE_NAME);
f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
List<Object> ids = new ArrayList<Object>();
ids.add(new Long(1));
Filter criteria = CoherenceFilterUtil.createInFilter("id", ids, Long.class);
List<?> trades = conn.get(criteria);
assertNotNull(trades);
assertEquals("Did not get expected number of trades", 1, trades.size());
// grab the first trade to confirm trade 1 was found in the cache.
Trade t = (Trade) trades.get(0);
Map legs = t.getLegs();
assertEquals("Did not get expected number of legs", NUMLEGS, legs.size());
}
use of com.tangosol.util.Filter in project teiid by teiid.
the class TestCoherenceConnection method testEqualOnTrade.
@Test
public void testEqualOnTrade() throws Exception {
CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
f.setCacheName(CACHE_NAME);
f.setCacheTranslatorClassName(OBJECT_TRANSLATOR);
CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
// NOTE: Coherence, because the datatype of ID is long, wants the "l" appended to the value
Filter criteria = CoherenceFilterUtil.createFilter("Id = 1l");
List<?> trades = conn.get(criteria);
assertNotNull(trades);
assertEquals("Did not get expected number of trades", 1, trades.size());
long l = 1;
criteria = CoherenceFilterUtil.createCompareFilter("Id", l, Comparison.Operator.EQ, Long.class);
trades = conn.get(criteria);
assertNotNull(trades);
assertEquals("Did not get expected number of trades", 1, trades.size());
}
Aggregations