@Test public void testConvert_ValidStatisticalQueryJson() throws Exception { String variableName = "RES_FIRST_HEIGHT"; IndexManagerHelper indexManagerHelper = createIndexManagerHelper( "opal-data", "StandingHeight", "opal-data-standingheight", variableName, createContinuousVariable(variableName)); QueryTermConverter converter = new QueryTermConverter(indexManagerHelper); Search.QueryTermsDto dtoQuery = createSimpleQueryDto(variableName); JSONObject jsonExpected = new JSONObject( "{\"query\":{\"match_all\":{} }, \"size\":0, " + // "\"facets\":{\"0\":{\"statistical\":{\"field\":\"opal-data" + // "-standingheight-RES_FIRST_HEIGHT\"} } } }"); JSONObject jsonResult = converter.convert(dtoQuery); assertThat(jsonResult).isNotNull(); JsonAssert.assertEquals(jsonExpected, jsonResult); }
@Test public void testConvert_ValidCategoricalQueryJson() throws Exception { String variableName = "LAST_MEAL_WHEN"; IndexManagerHelper indexManagerHelper = createIndexManagerHelper( "opal-data", "CIPreliminaryQuestionnaire", "opal-data-cipreliminaryquestionnaire", variableName, createCategoricalVariable(variableName)); QueryTermConverter converter = new QueryTermConverter(indexManagerHelper); Search.QueryTermsDto dtoQuery = createSimpleQueryDto(variableName); JSONObject jsonExpected = new JSONObject( "{\"query\":{\"match_all\":{} }, \"size\":0, " + // "\"facets\":{\"0\":{\"terms\":{\"field\":\"opal-data-cipreliminaryquestionnaire-LAST_MEAL_WHEN\" } } } }"); JSONObject jsonResult = converter.convert(dtoQuery); assertThat(jsonResult).isNotNull(); JsonAssert.assertEquals(jsonExpected, jsonResult); }