use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.
the class CON662 method test.
@Test
public void test() {
Criteria criteria = Criteria.parse("foo.bar eq 1");
client.find(criteria);
// lack of Exception means the test passes
Assert.assertTrue(true);
}
use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.
the class CON670 method repro.
@Test
public void repro() {
client.add("name", "jeffrey o");
client.add("name", "jeffrey a");
client.add("name", "jeff n");
client.add("name", "jeffe c");
client.add("name", "jefferson nel");
Criteria condition = Criteria.where().key("name").operator(Operator.LIKE).value("%jeff%");
Set<Long> a = client.find(condition);
Set<Long> b = client.select(condition).keySet();
Iterator<Long> ait = a.iterator();
Iterator<Long> bit = b.iterator();
while (ait.hasNext()) {
long anext = ait.next();
long bnext = bit.next();
Assert.assertEquals(anext, bnext);
}
}
use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.
the class Command method init.
/**
* Inspect the operation and populate the operation variables if they
* haven't already been {@link #initialized}.
*/
private void init() {
if (!initialized) {
String function = method.getName();
String[] toks = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, function).split("-");
Association args = Association.of();
if (function.equals("getServerVersion")) {
operation = function;
} else if (function.equals("verifyOrSet")) {
operation = function;
args.put("key", params[0]);
args.put("value", params[1]);
args.put("record", params[2]);
} else if (function.equals("verifyAndSwap")) {
operation = function;
args.put("key", params[0]);
args.put("record", params[2]);
args.put("values", ImmutableList.of(params[1], params[3]));
} else if (function.equals("findOrInsertCclJson")) {
operation = "findOrInsert";
args.put("ccl", params[0]);
} else if (function.equals("findOrInsertCriteriaJson")) {
operation = "findOrInsert";
args.put("criteria", params[0]);
} else if (function.equals("findOrAddKeyValue")) {
operation = "findOrAdd";
args.put("key", params[0]);
conditionKeys = ImmutableSet.of((String) params[0]);
} else {
operation = toks[0];
for (int i = 1; i < toks.length; ++i) {
args.put(toks[i].toLowerCase(), params[i - 1]);
}
}
// Parser
if (args.containsKey("ccl")) {
String ccl = args.fetch("ccl");
conditionTree = (ConditionTree) ConcourseCompiler.get().parse(ccl);
} else if (args.containsKey("criteria")) {
TCriteria tcriteria = args.fetch("criteria");
Criteria criteria = Language.translateFromThriftCriteria(tcriteria);
conditionTree = (ConditionTree) ConcourseCompiler.get().parse(criteria.ccl());
} else {
conditionTree = null;
}
// operationKeys
if (args.containsKey("key")) {
String key = args.fetch("key");
operationKeys = Sets.newHashSet(key);
} else if (args.containsKey("keys")) {
Collection<String> keys = args.fetch("keys");
operationKeys = Sets.newHashSet(keys);
} else {
operationKeys = ImmutableSet.of();
}
// operationRecords
if (args.containsKey("record")) {
long record = args.fetch("record");
operationRecords = Sets.newHashSet(record);
} else if (args.containsKey("records")) {
Collection<Long> records = args.fetch("records");
operationRecords = Sets.newHashSet(records);
} else {
operationRecords = ImmutableSet.of();
}
// order
if (args.containsKey("order")) {
TOrder torder = args.fetch("order");
order = JavaThriftBridge.convert(torder);
} else {
order = null;
}
// methods above.
if (conditionKeys == null && conditionTree != null) {
conditionKeys = ConcourseCompiler.get().analyze(conditionTree).keys();
} else if (function.startsWith("findKey")) {
conditionKeys = ImmutableSet.of((String) params[0]);
} else if (conditionKeys == null) {
conditionKeys = ImmutableSet.of();
}
// operationTimestamp
if (args.containsKey("time")) {
operationTimestamp = args.fetch("time");
}
initialized = true;
}
}
use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.
the class CON167 method testRoundTrip.
@Test
public void testRoundTrip() {
String value = "`bar`";
Criteria expected = Criteria.where().key("foo").operator(Operator.EQUALS).value(value).build();
Criteria actual = Language.translateFromThriftCriteria(Language.translateToThriftCriteria(expected));
Assert.assertEquals(expected, actual);
}
use of com.cinchapi.concourse.lang.Criteria in project concourse by cinchapi.
the class CON672 method reproString.
@Test
public void reproString() {
String value = "a=b";
Criteria criteria = Criteria.where().key("foo").operator(Operator.EQUALS).value(value);
System.out.println(criteria.ccl());
client.find(criteria);
// lack of Exception means the test passes
Assert.assertTrue(true);
}
Aggregations