@Test public void testProcess() throws Exception { ConcatenatingHashStage chs = new ConcatenatingHashStage(); chs.setAlgorithm("MD5"); chs.setOutput("md5"); chs.setFields(Arrays.asList("content", "title")); chs.init(); testStringMD5(chs, RandomStringUtils.randomAscii(10000), RandomStringUtils.randomAlphanumeric(10000)); for (int i = 0; i < 1000; i++) { testStringMD5(chs, RandomStringUtils.random(100), RandomStringUtils.random(100)); } }
@Override public void process(LocalDocument doc) { StringBuilder sb = new StringBuilder(); for(String field: fields) { if(doc.hasContentField(field)) sb.append(doc.getContentField(field)); } if(!sb.toString().isEmpty()) doc.putContentField(output, hasher.hashString(sb.toString())); }
ConcatenatingHashStage extends AbstractProcessStage { @Override public void process(LocalDocument doc) { StringBuilder sb = new StringBuilder(); for(String field: fields) { if(doc.hasContentField(field)) sb.append(doc.getContentField(field)); } if(!sb.toString().isEmpty()) doc.putContentField(output, hasher.hashString(sb.toString())); } }
ConcatenatingHashStage extends AbstractProcessStage { @Override public void process(LocalDocument doc) { StringBuilder sb = new StringBuilder(); for(String field: fields) { if(doc.hasContentField(field)) sb.append(doc.getContentField(field)); } if(!sb.toString().isEmpty()) doc.putContentField(output, hasher.hashString(sb.toString())); }  }
ConcatenatingHashStage extends AbstractProcessStage { @Override public void process(LocalDocument doc) { StringBuilder sb = new StringBuilder(); for(String field: fields) { if(doc.hasContentField(field)) sb.append(doc.getContentField(field)); } if(!sb.toString().isEmpty()) doc.putContentField(output, hasher.hashString(sb.toString())); }  @Override void init(); @Override void process(LocalDocument doc); void setAlgorithm(String algorithm); void setFields(List<String> fields); void setOutput(String output); void setHasher(Hasher hasher); }
ConcatenatingHashStage extends AbstractProcessStage { @Override public void process(LocalDocument doc) { StringBuilder sb = new StringBuilder(); for(String field: fields) { if(doc.hasContentField(field)) sb.append(doc.getContentField(field)); } if(!sb.toString().isEmpty()) doc.putContentField(output, hasher.hashString(sb.toString())); }  @Override void init(); @Override void process(LocalDocument doc); void setAlgorithm(String algorithm); void setFields(List<String> fields); void setOutput(String output); void setHasher(Hasher hasher);  }