OddsCharsKeyGenerator implements WorkKeyGenerator { @Override public String generateKey(DocumentProtos.DocumentMetadata doc) { String docKey = DocumentWrapperUtils.getMainTitle(doc); docKey = StringTools.normalize(docKey); docKey = StringTools.removeStopWords(docKey); docKey = docKey.replaceAll("\\s", ""); StringBuilder oddCharsSB = new StringBuilder(); for (int i=0; i < docKey.length(); i += 2) { oddCharsSB.append(docKey.charAt(i)); } docKey = oddCharsSB.toString(); int keyLength = KEY_PART_LENGTH; if (docKey.length() > keyLength) { docKey = docKey.substring(0, keyLength); } return docKey; }  @Override String generateKey(DocumentProtos.DocumentMetadata doc);  }
@Test public void testGenerateKey() { DocumentProtos.DocumentMetadata doc = MockDocumentMetadataFactory.createDocumentMetadata("A comparison of associated dsd sd"); Assert.assertEquals("cmaio", keyGen.generateKey(doc)); }