DescriptionRule implements Validator<Patent> { @Override public boolean test(Patent patent) { if (PatentType.UTILITY.equals(patent.getPatentType())) { if (patent.getDescription() == null || patent.getDescription().getAllPlainText().length() < 100) { return false; } for (DescriptionSection section : patent.getDescription().getSections()) { if (section.getRawText().length() < 25) { return false; } if (section.getPlainText().length() < 25) { return false; } if (section.getSimpleHtml().length() < 25) { return false; } } } return true; }  @Override boolean test(Patent patent); @Override String getName(); @Override String getMessage();  }
@Test public void failMissing() { PatentApplication patent = new PatentApplication(new DocumentId(CountryCode.US, "99999"), PatentType.UTILITY); patent.setDescription(null); assertFalse(descriptionRule.test(patent)); }
@Test public void failTooSmall() { PatentApplication patent = new PatentApplication(new DocumentId(CountryCode.US, "99999"), PatentType.UTILITY); Description desc = new Description(); DescriptionSection descSection = new DescriptionSection(DescSection.BRIEF_SUMMARY, "", new DummyFormattedText()); desc.addSection(descSection); patent.setDescription(desc); assertFalse(descriptionRule.test(patent)); }