TitleRule implements Validator<Patent> { @Override public boolean test(Patent patent) { if (patent.getTitle() == null || patent.getTitle().length() < 4 | patent.getTitle().length() > 500) { return false; } return true; }  @Override boolean test(Patent patent); @Override String getName(); @Override String getMessage();  }
@Test public void failMissingTitle() { PatentApplication patent = new PatentApplication(new DocumentId(CountryCode.US, "99999"), PatentType.UTILITY); assertFalse(titleRule.test(patent)); }
@Test public void failEmptyTitle() { PatentApplication patent = new PatentApplication(new DocumentId(CountryCode.US, "99999"), PatentType.UTILITY); patent.setTitle(""); assertFalse(titleRule.test(patent)); }
@Test public void failShortTitle() { PatentApplication patent = new PatentApplication(new DocumentId(CountryCode.US, "99999"), PatentType.UTILITY); patent.setTitle("Arr"); assertFalse(titleRule.test(patent)); }
@Test public void failLongTitle() { PatentApplication patent = new PatentApplication(new DocumentId(CountryCode.US, "99999"), PatentType.UTILITY); patent.setTitle( "Arrangement for improving availability of services in a communication system Arrangement for improving availability of services in a communication system Arrangement for improving availability of services in a communication system Arrangement for improving availability of services in a communication system Arrangement for improving availability of services in a communication system Arrangement for improving availability of services in a communication system Arrangement for improving availability of services in a communication system"); assertFalse(titleRule.test(patent)); }