@Test public void testPojoStructureAndBehavior() { Validator validator = ValidatorBuilder.create() // Add Rules to validate structure for POJO_PACKAGE // See com.openpojo.validation.rule.impl for more ... .with(new GetterMustExistRule()) .with(new SetterMustExistRule()) // Add Testers to validate behaviour for POJO_PACKAGE // See com.openpojo.validation.test.impl for more ... .with(new SetterTester()) .with(new GetterTester()) .build(); validator.validate(POJO_PACKAGE, new FilterPackageInfo()); LOGGER.info("Done"); }
@Test public void shouldBeValidPojo() { // given PojoClass keywordPojo = PojoClassFactory.getPojoClass(getPojoClass()); // when Validator validator = ValidatorBuilder.create() .with(new GetterMustExistRule()) .with(new SetterMustExistRule()) .with(new NoFieldShadowingRule()) .with(new SerializableMustHaveSerialVersionUIDRule()) .with(new NoPublicFieldsExceptStaticFinalRule()) .with(identityTester()) .with(getterSetterTester()) .build(); // then validator.validate(keywordPojo); }
@Test public void testSetter() { pojoValidator = ValidatorBuilder.create().with(new SetterTester()).build(); pojoValidator.validate(pojoClass); }