Class MongoAdapterTest

  • All Implemented Interfaces:
    org.apache.calcite.schema.SchemaFactory
    Direct Known Subclasses:
    MongoAdapterIT

    public class MongoAdapterTest
    extends java.lang.Object
    implements org.apache.calcite.schema.SchemaFactory
    Testing mongo adapter functionality. By default runs with Fongo unless IT maven profile is enabled (via $ mvn -Pit install).
    See Also:
    MongoDatabasePolicy
    • Field Detail

      • MODEL

        protected static final java.net.URL MODEL
        Connection factory based on the "mongo-zips" model.
      • ZIPS_SIZE

        protected static final int ZIPS_SIZE
        Number of records in local file
        See Also:
        Constant Field Values
      • schema

        private static org.apache.calcite.adapter.mongodb.MongoSchema schema
    • Constructor Detail

      • MongoAdapterTest

        public MongoAdapterTest()
    • Method Detail

      • setUp

        public static void setUp()
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • populate

        private static void populate​(com.mongodb.client.MongoCollection<org.bson.Document> collection,
                                     java.net.URL resource)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • create

        public org.apache.calcite.schema.Schema create​(org.apache.calcite.schema.SchemaPlus parentSchema,
                                                       java.lang.String name,
                                                       java.util.Map<java.lang.String,​java.lang.Object> operand)
        Returns always the same schema to avoid initialization costs.
        Specified by:
        create in interface org.apache.calcite.schema.SchemaFactory
      • testSort

        public void testSort()
      • testSortLimit

        public void testSortLimit()
      • testOffsetLimit

        public void testOffsetLimit()
      • testLimit

        public void testLimit()
      • testFilterSort

        public void testFilterSort()
      • testFilterSortDesc

        public void testFilterSortDesc()
      • testUnionPlan

        public void testUnionPlan()
      • testFilterUnionPlan

        public void testFilterUnionPlan()
      • testFilterRedundant

        public void testFilterRedundant()
        Tests that we don't generate multiple constraints on the same column. MongoDB doesn't like it. If there is an '=', it supersedes all other operators.
      • testSelectWhere

        public void testSelectWhere()
      • testInPlan

        public void testInPlan()
      • testZips

        public void testZips()
        Simple query based on the "mongo-zips" model.
      • testCountGroupByEmpty

        public void testCountGroupByEmpty()
      • testCountGroupByEmptyMultiplyBy2

        public void testCountGroupByEmptyMultiplyBy2()
      • testGroupByOneColumnNotProjected

        public void testGroupByOneColumnNotProjected()
      • testGroupByOneColumn

        public void testGroupByOneColumn()
      • testGroupByOneColumnReversed

        public void testGroupByOneColumnReversed()
      • testGroupByAvg

        public void testGroupByAvg()
      • testGroupByAvgSumCount

        public void testGroupByAvgSumCount()
      • testGroupByHaving

        public void testGroupByHaving()
      • testGroupByHaving2

        public void testGroupByHaving2()
      • testGroupByMinMaxSum

        public void testGroupByMinMaxSum()
      • testGroupComposite

        public void testGroupComposite()
      • testDistinctCount

        public void testDistinctCount()
      • testDistinctCountOrderBy

        public void testDistinctCountOrderBy()
      • testProject

        public void testProject()
      • testFilter

        public void testFilter()
      • testFilterReversed

        public void testFilterReversed()
        MongoDB's predicates are handed (they can only accept literals on the right-hand size) so it's worth testing that we handle them right both ways around.
      • checkPredicate

        private void checkPredicate​(int expected,
                                    java.lang.String q)
      • mongoChecker

        private static java.util.function.Consumer<java.util.List> mongoChecker​(java.lang.String... expected)
        Returns a function that checks that a particular MongoDB query has been called.
        Parameters:
        expected - Expected query (as array)
        Returns:
        validation function