### Question:
MyCommand extends ClusterServerReadCommandSingleTable<Long> { @Override public Long execute(IndexContext context) throws IOException { return new Long(context.getIndexReader().totalTermFreq(new Term(fieldName, term))); } TotalTermFreqCommand();  TotalTermFreqCommand(String fieldName, String term); @Override Long execute(IndexContext context); @Override Long combine(CombiningContext context, Map<? extends Location<?>, Long> results); @Override String getName(); String getFieldName(); void setFieldName(String fieldName); String getTerm(); void setValue(String term);  }### Answer:
@Test public void termInAllDocsShouldBeCorrect() throws IOException { Long returned = new MyCommand("val", "val").execute(ctx); Long expected = 26l; assertEquals(expected, returned); }
@Test public void singleDocFreq() throws IOException { Long returned = new MyCommand("dupVal", "dupVal").execute(ctx); Long expected = 52l; assertEquals(expected, returned); }