本文整理汇总了Java中com.openpojo.validation.PojoValidator类的典型用法代码示例。如果您正苦于以下问题:Java PojoValidator类的具体用法?Java PojoValidator怎么用?Java PojoValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PojoValidator类属于com.openpojo.validation包,在下文中一共展示了PojoValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Before
public void setup() {
pojoClasses = PojoClassFactory.getPojoClassesRecursively(POJO_PACKAGE, new PojoClassFilter() {
@Override
public boolean include(PojoClass pojoClass) {
if(pojoClass.getName().contains("abstract")) {
return false;
}
if(!pojoClass.getName().contains("pocketmedia")) {
return false;
}
return true;
}
});
pojoValidator = new PojoValidator();
// Create Testers to validate behavior for POJO_PACKAGE
pojoValidator.addTester(new SetterTester());
pojoValidator.addTester(new GetterTester());
}
示例2: setup
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@BeforeTest
public void setup() {
this.pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, new PojoClassFilter() {
@Override
public boolean include(final PojoClass pojoClass) {
System.out.println(pojoClass.getName());
return pojoClass.getName().endsWith("Style");
}
});
this.pojoValidator = new PojoValidator();
// Create Testers to validate behavior for POJO_PACKAGE
this.pojoValidator.addTester(new SetterTester());
this.pojoValidator.addTester(new GetterTester());
}
示例3: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
/**
* Unit Test the POJO classes.
*
* @throws ClassNotFoundException
* the class not found exception
* @throws InstantiationException
* the instantiation exception
* @throws IllegalAccessException
* the illegal access exception
*/
@Test
public void testPojoStructureAndBehavior() throws ClassNotFoundException,
InstantiationException, IllegalAccessException {
final PojoValidator pojoValidator = new PojoValidator();
for (final Class<? extends Rule> ruleClass : getValidationRules()) {
final Rule rule = ruleClass.newInstance();
pojoValidator.addRule(rule);
}
// Load tester classes
for (Class<? extends Tester> testerClass : getTesters()) {
final Tester testerInstance = testerClass.newInstance();
pojoValidator.addTester(testerInstance);
}
for (final Class<?> c : getPOJOClasses()) {
final PojoClass pojoClass = PojoClassFactory.getPojoClass(c);
pojoValidator.runValidation(pojoClass);
}
}
示例4: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
@Category(UnitTest.class)
@SuppressWarnings("unchecked")
public void testPojoStructureAndBehavior() {
if (this.getClass() == PojoTest.class) {
return;
}
Class<T> typeParameterClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
PojoValidator pojoValidator = new PojoValidator();
// Create Rules to validate structure for POJO_PACKAGE
pojoValidator.addRule(new NoPublicFieldsRule());
pojoValidator.addRule(new NoPrimitivesRule());
pojoValidator.addRule(new NoStaticExceptFinalRule());
pojoValidator.addRule(new GetterMustExistRule());
pojoValidator.addRule(new SetterMustExistRule());
pojoValidator.addRule(new NoNestedClassRule());
// Create Testers to validate behaviour for POJO_PACKAGE
pojoValidator.addTester(new SetterTester());
pojoValidator.addTester(new GetterTester());
PojoClass pojoClass = PojoClassFactory.getPojoClass(typeParameterClass);
pojoValidator.runValidation(pojoClass);
}
示例5: testPojo
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public void testPojo() {
PojoValidator pojoValidator = new PojoValidator();
// Create Rules to validate structure for POJO_PACKAGE
pojoValidator.addRule(new NoPublicFieldsRule());
pojoValidator.addRule(new NoPrimitivesRule());
pojoValidator.addRule(new NoStaticExceptFinalRule());
pojoValidator.addRule(new GetterMustExistRule());
pojoValidator.addRule(new SetterMustExistRule());
pojoValidator.addRule(new NoNestedClassRule());
pojoValidator.addRule(new NoPublicFieldsExceptStaticFinalRule());
pojoValidator.addRule(new NoStaticExceptFinalRule());
pojoValidator.addRule(new SerializableMustHaveSerialVersionUIDRule());
// Create Testers to validate behaviour for POJO_PACKAGE
pojoValidator.addTester(new SetterTester());
pojoValidator.addTester(new GetterTester());
PojoClass pojoClass = PojoClassFactory.getPojoClass(getPojoClass());
pojoValidator.runValidation(pojoClass);
}
示例6: init
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Before
public void init() {
pojoValidator = new PojoValidator();
pojoValidator.addRule(new NoPublicFieldsRule());
pojoValidator.addRule(new NoStaticExceptFinalRule());
pojoValidator.addRule(new NoFieldShadowingRule());
pojoValidator.addRule(new GetterMustExistRule());
pojoValidator.addRule(new SetterMustExistRule());
pojoValidator.addTester(new SetterTester());
pojoValidator.addTester(new GetterTester());
pojoValidator.addTester(new Tester() {
@Override
public void run(PojoClass pojoClass) {
List<PojoMethod> list = pojoClass.getPojoConstructors();
for (PojoMethod method : list) {
Class<?>[] types = method.getParameterTypes();
int count = types.length;
Object[] values = new Object[count];
for (int i = 0; i < count; i++) {
values[i] = RandomFactory.getRandomValue(types[i]);
}
method.invoke(null, values);
}
}
});
}
示例7: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory.getPojoClass(ParserConfig.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}
示例8: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory.getPojoClass(Project.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}
示例9: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory.getPojoClass(Folder.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}
示例10: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory
.getPojoClass(GeneratedArtifact.class);
final PojoValidator pv = createPojoValidator();
pv.addRule(new SetterMustExistRule());
pv.runValidation(pc);
}
示例11: testStructureAndBehaviour
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public void testStructureAndBehaviour() {
final PojoClass pc = PojoClassFactory.getPojoClass(JaxbHelper.class);
final PojoValidator pv = createPojoValidator();
pv.addRule(new SetterMustExistRule());
pv.runValidation(pc);
}
示例12: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory.getPojoClass(Generators.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}
示例13: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory.getPojoClass(Parsers.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}
示例14: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory.getPojoClass(Classpath.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}
示例15: testPojoStructureAndBehavior
import com.openpojo.validation.PojoValidator; //导入依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {
final PojoClass pc = PojoClassFactory
.getPojoClass(BinClasspathEntry.class);
final PojoValidator pv = createPojoValidator();
pv.runValidation(pc);
}