public void testLuceneQuery() {
String query = "ProductId:TestProductId";
cmdLineUtility
.run(("--url http://localhost:9000 --operation --luceneQuery"
+ " --query " + query).split(" "));
MethodCallDetails methodCallDetails = client.getLastMethodCallDetails();
assertEquals("complexQuery", methodCallDetails.getMethodName());
assertEquals("ProductId", ((TermQueryCriteria) ((Query) methodCallDetails
.getArgs().get(0)).getCriteria().get(0)).getElementName());
assertEquals("TestProductId",
((TermQueryCriteria) ((Query) methodCallDetails.getArgs().get(0))
.getCriteria().get(0)).getValue());
OptionPropertyRegister.clearRegister();
String reducedMetadataKeys = "ProductId ProductType";
String outputFormat = "$ProductId";
String reducedProductTypes = "TestProductType";
String sortBy = "ProductId";
String delimiter = ",";
cmdLineUtility
.run(("--url http://localhost:9000 --operation --luceneQuery"
+ " --query " + query + " --reducedMetadataKeys " + reducedMetadataKeys
+ " --outputFormat " + outputFormat
+ " --reducedProductTypes " + reducedProductTypes
+ " --sortBy " + sortBy
+ " --delimiter " + delimiter).split(" "));
methodCallDetails = client.getLastMethodCallDetails();
assertEquals("complexQuery", methodCallDetails.getMethodName());
ComplexQuery complexQuery = (ComplexQuery) methodCallDetails.getArgs().get(0);
assertEquals("ProductId", ((TermQueryCriteria) complexQuery.getCriteria().get(0)).getElementName());
assertEquals("TestProductId",
((TermQueryCriteria) complexQuery.getCriteria().get(0)).getValue());
assertEquals(Lists.newArrayList(reducedMetadataKeys.split(" ")), complexQuery.getReducedMetadata());
assertEquals(outputFormat, complexQuery.getToStringResultFormat());