Java Code Examples for com.openpojo.reflection.impl.PojoClassFactory#getPojoClasses()

The following examples show how to use com.openpojo.reflection.impl.PojoClassFactory#getPojoClasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecordPojoTest.java    From cerberus with Apache License 2.0 6 votes vote down vote up
@Test
public void test_pojo_structure_and_behavior() {

  List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses("com.nike.cerberus.record");

  Assert.assertEquals(15, pojoClasses.size());

  Validator validator =
      ValidatorBuilder.create()
          .with(new GetterMustExistRule())
          .with(new SetterMustExistRule())
          .with(new SetterTester())
          .with(new GetterTester())
          .build();

  validator.validate(pojoClasses);
}
 
Example 2
Source File: TestEntityTest.java    From openpojo with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE);

  ValidatorBuilder validatorBuilder = ValidatorBuilder.create();

  // Create Rules to validate structure for POJO_PACKAGE
  validatorBuilder.with(new NoPublicFieldsRule());
  validatorBuilder.with(new NoPrimitivesRule());
  validatorBuilder.with(new NoStaticExceptFinalRule());
  validatorBuilder.with(new GetterMustExistRule());
  validatorBuilder.with(new NoNestedClassRule());
  validatorBuilder.with(new BusinessKeyMustExistRule());

  // Create Testers to validate behavior for POJO_PACKAGE
  validatorBuilder.with(new SetterTester());
  validatorBuilder.with(new GetterTester());
  validatorBuilder.with(new BusinessIdentityTester());

  pojoValidator = validatorBuilder.build();
}
 
Example 3
Source File: PojoPackageTestBase.java    From spring-batch-lightmin with Apache License 2.0 6 votes vote down vote up
@Test
public void testEquals() {
    if (this.withEquals) {
        final List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(this.pojoPackage, this.filterChain);
        for (final PojoClass pojoClass : pojoClasses) {
            final Class<?> clazz = pojoClass.getClazz();

            EqualsVerifier
                    .forClass(clazz)
                    .suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS)
                    .verify();
        }
    } else {
        log.info("Equals Test is disbabled");
    }

}
 
Example 4
Source File: DomainPojoTest.java    From cerberus with Apache License 2.0 5 votes vote down vote up
@Test
public void test_pojo_structure_and_behavior() {

  List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses("com.nike.cerberus.domain");

  pojoClasses.remove(PojoClassFactory.getPojoClass(CerberusAuthToken.class));
  pojoClasses.remove(
      PojoClassFactory.getPojoClass(CerberusAuthToken.CerberusAuthTokenBuilder.class));
  pojoClasses.remove(PojoClassFactory.getPojoClass(VaultStyleErrorResponse.Builder.class));
  pojoClasses.remove(PojoClassFactory.getPojoClass(IamPrincipalPermission.Builder.class));
  pojoClasses.remove(PojoClassFactory.getPojoClass(UserGroupPermission.Builder.class));
  pojoClasses.remove(PojoClassFactory.getPojoClass(SafeDepositBoxV2.Builder.class));
  pojoClasses.remove(
      PojoClassFactory.getPojoClass(SecureDataResponse.SecureDataResponseBuilder.class));

  Assert.assertTrue(pojoClasses.size() > 1);

  Validator validator =
      ValidatorBuilder.create()
          .with(new GetterMustExistRule())
          .with(new SetterMustExistRule())
          .with(new SetterTester())
          .with(new GetterTester())
          .build();

  validator.validate(pojoClasses);
}
 
Example 5
Source File: GetterTesterAndSetterTesterTest.java    From openpojo with Apache License 2.0 5 votes vote down vote up
private List<PojoClass> getGoodPojoClasses() {
  return PojoClassFactory.getPojoClasses(TESTPACKAGE, new PojoClassFilter() {
    public boolean include(PojoClass pojoClass) {
      return pojoClass.getClazz().getSimpleName().startsWith("Good_");
    }
  });
}
 
Example 6
Source File: PojoPackageTestBase.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
@Test
public void ensureExpectedPojoCount() {
    if (this.withExpectedCount) {
        final List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(this.pojoPackage,
                new FilterPackageInfo());
        Affirm.affirmEquals("Classes added / removed?", this.expectedClassCount, pojoClasses.size());
    } else {
        log.debug("WithExpectedCount is disbabled");
    }
}
 
Example 7
Source File: UnitPojo.java    From shipping with Apache License 2.0 4 votes vote down vote up
@Test
public void ensureExpectedPojoCount() {
    List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, filter);
    Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
}
 
Example 8
Source File: UnitPojo.java    From orders with Apache License 2.0 4 votes vote down vote up
@Test
public void ensureExpectedPojoCount() {
    List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, filter);
    Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
}
 
Example 9
Source File: DefaultValidator.java    From openpojo with Apache License 2.0 4 votes vote down vote up
public List<PojoClass> validate(String packageName, PojoClassFilter... filters) {
  PojoClassFilter pojoClassFilter = new FilterChain(filters);
  List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(packageName, pojoClassFilter);
  validate(pojoClasses);
  return pojoClasses;
}
 
Example 10
Source File: ModelTest.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Test
public void ensureExpectedPojoCount() {
    List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(DOMAIN_PACKAGE, new FilterPackageInfo());
    Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
}