/**
  * A non empty parameter (granularity)
  *
  * @expectedException \DruidFamiliar\Exception\EmptyParametersException
  */
 public function testEmptyParametersException()
 {
     $parametersInstance = new GroupByQueryParameters();
     $parametersInstance->setDataSource('referral-visit-old-format');
     $parametersInstance->setGranularity('');
     $parametersInstance->setDimensions(array('facility_id', 'referral_id', 'group'));
     $filter = new stdClass();
     $filter->type = 'selector';
     $filter->dimension = 'company_id';
     $filter->value = 1;
     $parametersInstance->setFilter($filter);
     $anAggregation = new stdClass();
     $anAggregation->type = 'longSum';
     $anAggregation->name = 'quantity';
     $anAggregation->fieldName = 'count';
     $parametersInstance->setAggregations(array($anAggregation));
     $parametersInstance->setIntervals(array('2008-01-01T00:00:00.000/2012-01-03T00:00:00.000'));
     $valid = $parametersInstance->validate();
 }
 /**
  * Test the query generation, "happy path"
  */
 public function testGenerateQuery()
 {
     $parametersInstance = new GroupByQueryParameters();
     $parametersInstance->setDataSource('referral-visit-old-format');
     $parametersInstance->setGranularity('all');
     $parametersInstance->setDimensions(array('facility_id', 'referral_id', 'group'));
     $filter = new stdClass();
     $filter->type = 'selector';
     $filter->dimension = 'company_id';
     $filter->value = 1;
     $parametersInstance->setFilter($filter);
     $anAggregation = new stdClass();
     $anAggregation->type = 'longSum';
     $anAggregation->name = 'quantity';
     $anAggregation->fieldName = 'count';
     $parametersInstance->setAggregations(array($anAggregation));
     $parametersInstance->setIntervals(array('2008-01-01T00:00:00.000/2012-01-03T00:00:00.000'));
     $queryInstance = new GroupByQueryGenerator();
     $expectedQuery = '{"queryType":"groupBy","dataSource":"referral-visit-old-format","dimensions":["facility_id","referral_id","group"],"granularity":"all","filter":{"type":"selector","dimension":"company_id","value":1},"aggregations":[{"type":"longSum","name":"quantity","fieldName":"count"}],"intervals":["2008-01-01T00:00:00.000\\/2012-01-03T00:00:00.000"]}';
     $query = $queryInstance->generateQuery($parametersInstance);
     $this->assertEquals($expectedQuery, $query);
 }