### Question:
ChildNodeFacetTreeBuilder extends AbstractFacetTreeBuilder { @Override public void initialiseParameters(SolrParams localParams) throws SyntaxError { super.initialiseParameters(localParams); childField = localParams.get(FacetTreeParameters.CHILD_FIELD_PARAM); if (StringUtils.isBlank(childField)) { throw new SyntaxError("Missing child field definition in " + localParams); } maxLevels = localParams.getInt(FacetTreeParameters.LEVELS_PARAM, 0); docFields.addAll(Arrays.asList(getNodeField(), childField)); if (hasLabelField()) { docFields.add(getLabelField()); } } ChildNodeFacetTreeBuilder(); @Override void initialiseParameters(SolrParams localParams); @Override List<TreeFacetField> processFacetTree(SolrIndexSearcher searcher, Map<String, Integer> facetMap);  }### Answer:
@Test(expected=org.apache.solr.search.SyntaxError.class) public void initialiseParameters_nullParams() throws Exception { final SolrParams params = null; ChildNodeFacetTreeBuilder ftb = new ChildNodeFacetTreeBuilder(); ftb.initialiseParameters(params); }
@Test(expected=org.apache.solr.search.SyntaxError.class) public void initialiseParameters_missingNodeFieldParam() throws Exception { final SolrParams params = mock(SolrParams.class); when(params.get(FacetTreeParameters.NODE_FIELD_PARAM)).thenReturn(null); when(params.get(QueryParsing.V)).thenReturn(null); ChildNodeFacetTreeBuilder ftb = new ChildNodeFacetTreeBuilder(); ftb.initialiseParameters(params); verify(params).get(FacetTreeParameters.NODE_FIELD_PARAM); verify(params).get(QueryParsing.V); }
@Test(expected=org.apache.solr.search.SyntaxError.class) public void initialiseParameters_missingChildField() throws Exception { final String nodeField = "node"; final String childField = null; final SolrParams params = mock(SolrParams.class); when(params.get(FacetTreeParameters.NODE_FIELD_PARAM)).thenReturn(null); when(params.get(QueryParsing.V)).thenReturn(nodeField); when(params.get(FacetTreeParameters.CHILD_FIELD_PARAM)).thenReturn(childField); ChildNodeFacetTreeBuilder ftb = new ChildNodeFacetTreeBuilder(); ftb.initialiseParameters(params); verify(params).get(FacetTreeParameters.NODE_FIELD_PARAM); verify(params).get(QueryParsing.V); verify(params).get(FacetTreeParameters.CHILD_FIELD_PARAM); }
@Test public void initialiseParameters() throws Exception { final String nodeField = "node"; final String childField = "child"; final SolrParams params = mock(SolrParams.class); when(params.get(FacetTreeParameters.NODE_FIELD_PARAM)).thenReturn(nodeField); when(params.get(FacetTreeParameters.CHILD_FIELD_PARAM)).thenReturn(childField); ChildNodeFacetTreeBuilder ftb = new ChildNodeFacetTreeBuilder(); ftb.initialiseParameters(params); verify(params).get(FacetTreeParameters.NODE_FIELD_PARAM); verify(params).get(FacetTreeParameters.CHILD_FIELD_PARAM); verify(params).get(FacetTreeParameters.LABEL_FIELD_PARAM, null); verify(params).getInt(FacetTreeParameters.LEVELS_PARAM, 0); }