当前位置: 首页>>代码示例>>Java>>正文


Java PojoValidator.addTester方法代码示例

本文整理汇总了Java中com.openpojo.validation.PojoValidator.addTester方法的典型用法代码示例。如果您正苦于以下问题:Java PojoValidator.addTester方法的具体用法?Java PojoValidator.addTester怎么用?Java PojoValidator.addTester使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.openpojo.validation.PojoValidator的用法示例。


在下文中一共展示了PojoValidator.addTester方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:Pocketbrain,项目名称:androidnativeadslib,代码行数:25,代码来源:PojosTest.java

示例2: 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);
    }
}
 
开发者ID:eBay,项目名称:parallec,代码行数:33,代码来源:ParallecPojoClassTest.java

示例3: 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);
}
 
开发者ID:Livefyre,项目名称:livefyre-java-utils,代码行数:27,代码来源:PojoTest.java

示例4: 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);
}
 
开发者ID:aracrown,项目名称:ara-commons,代码行数:22,代码来源:AbstractSinglePojoClassTest.java

示例5: 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);
			}
		}
	});

}
 
开发者ID:ttwd80,项目名称:qir,代码行数:30,代码来源:AbstractPojoTest.java

示例6: testPojoStructureAndBehavior

import com.openpojo.validation.PojoValidator; //导入方法依赖的package包/类
@Test
public final void testPojoStructureAndBehavior() {

    final PojoClass pc = PojoClassFactory.getPojoClass(Target.class);

    final PojoValidator pv = new PojoValidator();

    pv.addRule(new NoPublicFieldsRule());
    pv.addRule(new NoFieldShadowingRule());

    pv.addTester(new DefaultValuesNullTester());
    pv.addTester(new SetterTester());
    pv.addTester(new GetterTester());

    pv.runValidation(pc);

}
 
开发者ID:fuinorg,项目名称:srcgen4j-commons,代码行数:18,代码来源:TargetTest.java

示例7: createPojoValidator

import com.openpojo.validation.PojoValidator; //导入方法依赖的package包/类
/**
 * Creates a configured POJO validator.
 * 
 * @return New instance.
 */
protected final PojoValidator createPojoValidator() {

    final PojoValidator pv = new PojoValidator();

    pv.addRule(new NoPublicFieldsRule());
    pv.addRule(new NoFieldShadowingRule());

    pv.addTester(new DefaultValuesNullTester());
    pv.addTester(new GetterTester());

    return pv;
}
 
开发者ID:fuinorg,项目名称:srcgen4j-commons,代码行数:18,代码来源:AbstractTest.java


注:本文中的com.openpojo.validation.PojoValidator.addTester方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。