Package com.pardot.rhombus

Examples of com.pardot.rhombus.Criteria


                return input.get("id").toString();
            }});
        // Confirm get by index_1 query
        SortedMap<String, Object> indexValues = Maps.newTreeMap();
        indexValues.put("index_1", "index1");
        Criteria criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        List<Map<String, Object>> results = om.list(testUniqueTableName, criteria);
        Map<String, Map<String, Object>> indexedResults;
        indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>, String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
            }
        });
        Map<String, Map<String, Object>> indexedExpected1 = Maps.newHashMap(indexedExpected);
        // Index_1 test data doesn't include value 4
        indexedExpected1.remove("864f1400-2a7e-11b2-8080-808080808080");
        assertEquals(indexedExpected1, indexedResults);

        // Confirm get by index_2 query
        indexValues = Maps.newTreeMap();
        indexValues.put("index_2", "index2");
        criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        results = om.list(testUniqueTableName, criteria);

        indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>,String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
View Full Code Here


                return input.get("id").toString();
            }});
        // Confirm get by index_1 query
        SortedMap<String, Object> indexValues = Maps.newTreeMap();
        indexValues.put("index_1", "index1");
        Criteria criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        List<Map<String, Object>> results = om.list(testUniqueTableName, criteria);
        Map<String, Map<String, Object>> indexedResults;
        indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>, String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
            }
        });
        Map<String, Map<String, Object>> indexedExpected1 = Maps.newHashMap(indexedExpected);
        // Index_1 test data doesn't include value 4
        indexedExpected1.remove("864f1400-2a7e-11b2-8080-808080808080");
        assertEquals(indexedExpected1, indexedResults);

        // Confirm get by index_2 query
        indexValues = Maps.newTreeMap();
        indexValues.put("index_2", "index2");
        criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        results = om.list(testUniqueTableName, criteria);

        indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>,String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
View Full Code Here

                return input.get("value").toString();
            }});
        // Confirm get by index_1 query
        SortedMap<String, Object> indexValues = Maps.newTreeMap();
        indexValues.put("index_1", "index1");
        Criteria criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        List<Map<String, Object>> results = om.list(testUniqueTableName, criteria);
        assertEquals("Index 1 values were null for this test, query on index 1 should return 0 results", 0, results.size());

        // Confirm get by index_2 query
        indexValues = Maps.newTreeMap();
        indexValues.put("index_2", "index2");
        criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        results = om.list(testUniqueTableName, criteria);

        // Index results by the value, which we will use as a faux index for testing
        Map<String, Map<String, Object>> indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>,String>() {
            public String apply(Map<String, Object> input) {
View Full Code Here

    //now run the processor
    UpdateProcessor up = new UpdateProcessor(om);
    up.process(9999L);

    //But is should be present in the correct index
    Criteria criteria = new Criteria();
    SortedMap<String,Object> values = Maps.newTreeMap();
    values.put("foreignid", Long.valueOf(77));
    criteria.setIndexKeys(values);
    List<Map<String,Object>> indexObjects = om.list("testtype", criteria);
    assertEquals(1, indexObjects.size());
    assertEquals(null,indexObjects.get(0).get("instance"));
    assertEquals(77L,indexObjects.get(0).get("foreignid"));
    assertEquals(101,indexObjects.get(0).get("type"));
View Full Code Here

    //testObject.put("foreignid", Long.valueOf(33339999));
    //Query it back out
    //Make sure that we have the proper number of results
    SortedMap<String, Object> indexValues = Maps.newTreeMap();
    indexValues.put("foreignid", Long.valueOf(33339999));
    Criteria criteria = new Criteria();
    criteria.setIndexKeys(indexValues);
    Thread.sleep(4000);
    int count = om.list("testtype",criteria).size();
    logger.info("======================");
    logger.info("Retrieved count of " + count);
    logger.info("======================");
View Full Code Here

    assertEquals(100L,staticTableObject.get("foreignid"));
    assertEquals(101,staticTableObject.get("type"));
    assertEquals(103,staticTableObject.get("filtered"));
    assertEquals("This is data 1",staticTableObject.get("data1"));

    Criteria criteria = new Criteria();
    SortedMap<String,Object> values = Maps.newTreeMap();
    values.put("foreignid", Long.valueOf(200L));
    criteria.setIndexKeys(values);
    criteria.setLimit(0L);
    List<Map<String, Object>> indexObjects = om.list("testtype", criteria);
    assertEquals(1, indexObjects.size());
    assertEquals(staticTableObject.get("data1"),indexObjects.get(0).get("data1"));
    assertEquals(200L,indexObjects.get(0).get("foreignid"));
    assertEquals(201,indexObjects.get(0).get("type"));
    assertEquals(203,indexObjects.get(0).get("filtered"));


    //wait for consistency
    Thread.sleep(3000);

    //now run the processor
    UpdateProcessor up = new UpdateProcessor(om);
    up.process(9999L);

    //verify that the object is no longer present in the invalid indexes

    //Should be missing from the bad index
    criteria = new Criteria();
    values = Maps.newTreeMap();
    values.put("foreignid", Long.valueOf(200));
    criteria.setIndexKeys(values);
    criteria.setLimit(0L);
    indexObjects = om.list("testtype", criteria);
    assertEquals(0, indexObjects.size());

    //But is should be present in the correct index
    criteria = new Criteria();
    values = Maps.newTreeMap();
    values.put("foreignid", Long.valueOf(100));
    criteria.setIndexKeys(values);
    indexObjects = om.list("testtype", criteria);
    assertEquals(1, indexObjects.size());
    assertEquals(staticTableObject.get("data1"),indexObjects.get(0).get("data1"));
    assertEquals(100L,indexObjects.get(0).get("foreignid"));
    assertEquals(101,indexObjects.get(0).get("type"));
View Full Code Here

    //Query it back out
    //Make sure that we have the proper number of results
    SortedMap<String, Object> indexValues = Maps.newTreeMap();
    indexValues.put("account_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
    indexValues.put("user_id", UUID.fromString("00000003-0000-0030-0040-000000030000"));
    Criteria criteria = new Criteria();
    criteria.setIndexKeys(indexValues);
    criteria.setLimit(50L);
    List<Map<String, Object>> results = om.list("object1", criteria);
    assertEquals(3, results.size());

    cm.teardown();
  }
View Full Code Here

    //Query it back out, make sure that we are using the shard index, because if we are not, we will surpass reasonable statement limit
    SortedMap<String, Object> indexValues = Maps.newTreeMap();
    indexValues.put("account_id", accountId);
    indexValues.put("user_id", userId);
    Criteria criteria = new Criteria();
    criteria.setIndexKeys(indexValues);
    criteria.setEndTimestamp(DateTime.now().getMillis());
    criteria.setLimit(50L);
    List<Map<String, Object>> results = om.list("object1", criteria);

    assertEquals(1, results.size());

    cm.teardown();
View Full Code Here

    insertNObjects(om, insertNum, null);

    // Get 50 back
    long limit = 50l;
    Criteria criteria = new Criteria();
    SortedMap<String, Object> indexKeys = Maps.newTreeMap();
    indexKeys.put("account_id", accountId);
    indexKeys.put("user_id", userId);
    criteria.setIndexKeys(indexKeys);
    criteria.setLimit(limit);
    List<Map<String, Object>> results = om.list(objectType, criteria);

    assertEquals(insertNum, results.size());

    cm.teardown();
View Full Code Here

    ObjectMapper om = cm.getObjectMapper();
    om.setLogCql(true);

    // Get 50 back
    long limit = 50l;
    Criteria criteria = new Criteria();
    SortedMap<String, Object> indexKeys = Maps.newTreeMap();
    indexKeys.put("account_id", accountId);
    indexKeys.put("user_id", userId);
    criteria.setIndexKeys(indexKeys);
    criteria.setLimit(limit);
    List<Map<String, Object>> results = om.list(objectType, criteria);

    assertEquals(0, results.size());

    cm.teardown();
View Full Code Here

TOP

Related Classes of com.pardot.rhombus.Criteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.