use of com.hazelcast.query.SampleObjects.ValueType in project hazelcast by hazelcast.
the class QueryBasicTest method testIndexingEnumAttributeWithSqlIssue597.
/**
* see pull request 616
*/
@Test(timeout = 1000 * 60)
public void testIndexingEnumAttributeWithSqlIssue597() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<Integer, Value> map = instance.getMap("default");
map.addIndex("state", true);
for (int i = 0; i < 4; i++) {
Value v = new Value(i % 2 == 0 ? State.STATE1 : State.STATE2, new ValueType(), i);
map.put(i, v);
}
Collection<Value> values = map.values(new SqlPredicate("state = 'STATE1'"));
int[] expectedValues = new int[] { 0, 2 };
assertEquals(expectedValues.length, values.size());
int[] indexes = new int[2];
int index = 0;
for (Value configObject : values) {
indexes[index++] = configObject.getIndex();
}
Arrays.sort(indexes);
assertArrayEquals(indexes, expectedValues);
}
use of com.hazelcast.query.SampleObjects.ValueType in project hazelcast by hazelcast.
the class QueryBasicTest method testIndexingEnumAttributeIssue597.
@Test(timeout = 1000 * 60)
public void testIndexingEnumAttributeIssue597() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<Integer, Value> map = instance.getMap("default");
map.addIndex("state", true);
for (int i = 0; i < 4; i++) {
Value v = new Value(i % 2 == 0 ? State.STATE1 : State.STATE2, new ValueType(), i);
map.put(i, v);
}
Predicate predicate = new PredicateBuilder().getEntryObject().get("state").equal(State.STATE1);
Collection<Value> values = map.values(predicate);
int[] expectedValues = new int[] { 0, 2 };
assertEquals(expectedValues.length, values.size());
int[] indexes = new int[2];
int index = 0;
for (Value configObject : values) {
indexes[index++] = configObject.getIndex();
}
Arrays.sort(indexes);
assertArrayEquals(indexes, expectedValues);
}
use of com.hazelcast.query.SampleObjects.ValueType in project hazelcast by hazelcast.
the class QueryBasicTest method testIteratorContract.
@Test(timeout = 1000 * 60)
public void testIteratorContract() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, SampleObjects.ValueType> map = instance.getMap("testIteratorContract");
map.put("1", new ValueType("one"));
map.put("2", new ValueType("two"));
map.put("3", new ValueType("three"));
Predicate predicate = new SqlPredicate("typeName in ('one','two')");
assertEquals(2, map.values(predicate).size());
assertEquals(2, map.keySet(predicate).size());
testIterator(map.keySet().iterator(), 3);
testIterator(map.keySet(predicate).iterator(), 2);
testIterator(map.entrySet().iterator(), 3);
testIterator(map.entrySet(predicate).iterator(), 2);
testIterator(map.values().iterator(), 3);
testIterator(map.values(predicate).iterator(), 2);
}
use of com.hazelcast.query.SampleObjects.ValueType in project hazelcast by hazelcast.
the class QueryBasicTest method testInPredicate.
@Test(timeout = 1000 * 60)
public void testInPredicate() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, SampleObjects.ValueType> map = instance.getMap("testIteratorContract");
map.put("1", new ValueType("one"));
map.put("2", new ValueType("two"));
map.put("3", new ValueType("three"));
map.put("4", new ValueType("four"));
map.put("5", new ValueType("five"));
map.put("6", new ValueType("six"));
map.put("7", new ValueType("seven"));
Predicate predicate = new SqlPredicate("typeName in ('one','two')");
for (int i = 0; i < 10; i++) {
Collection<SampleObjects.ValueType> values = map.values(predicate);
assertEquals(2, values.size());
}
}
Aggregations