Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenpojo throws BusinessException when a POJO references another POJO
    text
    copied!<p>I'm using OpenPojo to automate tests on my JPA Entities. I'm having troubles with entities that have reference to other entities.</p> <p>Example:</p> <pre><code>public class Person { @BusinessKey private Integer id; ...getters/setters @Override public boolean equals(Object obj) { return BusinessIdentity.areEqual(this, obj); } @Override public int hashCode() { return BusinessIdentity.getHashCode(this); } } public class Employee { @BusinessKey private Integer id; private Person person; ...getters/setters @Override public boolean equals(Object obj) { return BusinessIdentity.areEqual(this, obj); } @Override public int hashCode() { return BusinessIdentity.getHashCode(this); } } </code></pre> <p>Here is my test case:</p> <pre><code> // 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 DefaultValuesNullTester()); pojoValidator.addTester(new SetterTester()); pojoValidator.addTester(new GetterTester()); for (PojoClass pojoClass : pojoClasses) { pojoValidator.runValidation(pojoClass); } </code></pre> <p>I'm getting the following exception: </p> <pre><code>com.openpojo.business.exception.BusinessException: Field required and can't be null [PojoFieldImpl </code></pre> <p>If I remove the reference to Person from the Employee class the tests without any exception being thrown.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload