### Question:
TermSubQueryBuilder { public TermSubQueryFactory termToFactory(final String fieldname, final Term sourceTerm, final FieldBoost boost) throws IOException { final CacheKey cacheKey; if (termQueryCache != null) { cacheKey = new CacheKey(fieldname, sourceTerm); TermQueryCacheValue cacheValue = termQueryCache.get(cacheKey); if (cacheValue != null) { return (cacheValue.hasQuery()) ? new TermSubQueryFactory(cacheValue, boost) : null; } } else { cacheKey = null; } final LuceneQueryFactoryAndPRMSQuery root; TokenStream ts = null; try { ts = analyzer.tokenStream(fieldname, new CharSequenceReader(sourceTerm)); final CharTermAttribute termAttr = ts.addAttribute(CharTermAttribute.class); final PositionIncrementAttribute posIncAttr = ts.addAttribute(PositionIncrementAttribute.class); ts.reset(); final PositionSequence<org.apache.lucene.index.Term> sequence = new PositionSequence<>(); while (ts.incrementToken()) { final int inc = posIncAttr.getPositionIncrement(); if (inc > 0 || sequence.isEmpty()) { sequence.nextPosition(); } sequence.addElement(new org.apache.lucene.index.Term(fieldname, new BytesRef(termAttr))); } root = positionSequenceToQueryFactoryAndPRMS(sequence); } finally { if (ts != null) { try { ts.close(); } catch (IOException e) { } } } putQueryFactoryAndPRMSQueryIntoCache(cacheKey, root); return root == null ? null : new TermSubQueryFactory(root, boost); } TermSubQueryBuilder(final Analyzer analyzer, final TermQueryCache termQueryCache); TermSubQueryFactory termToFactory(final String fieldname, final Term sourceTerm, final FieldBoost boost); LuceneQueryFactoryAndPRMSQuery positionSequenceToQueryFactoryAndPRMS(PositionSequence<org.apache.lucene.index.Term> sequence);  }### Answer:
@Test public void testThatDeletingAllTermsInLuceneAnalysisDoesNotCauseException() throws Exception { TermSubQueryBuilder builder = new TermSubQueryBuilder(ANALYZER, cache); PositionSequence<org.apache.lucene.index.Term> sequence = new PositionSequence<>(); sequence.nextPosition(); querqy.model.Term term = new querqy.model.Term(null, "f", ".", false); builder.termToFactory("f", term, ConstantFieldBoost.NORM_BOOST); verify(cache, never()).put(any(CacheKey.class), any(TermQueryCacheValue.class)); }